Question
#include //this library is needed for printf function #include //this library is needed for rand() function #include //this library is needed for pause() function #include
#include //this library is needed for printf function #include //this library is needed for rand() function #include //this library is needed for pause() function #include //this library is needed for clock() function #include //this library is needed for abs() #include //this library is needed for SSE //#include //#include //#include #include //this library is needed for AVX
void init(); void AVX();
#define N 256 //input size __declspec(align(64)) float A[N][N], B[N][N],Btranspose[N][N],C[N][N],test[N][N];
#define TIMES_TO_RUN 1 //how many times the function will run #define EPSILON 0.0001
int main() {
//define the timers measuring execution time clock_t start_1, end_1; //ignore this for now
init();
start_1 = clock(); //start the timer
for (int i = 0; i
end_1 = clock(); //end the timer
printf(" clock() method: %ldms ", (end_1 - start_1) / (CLOCKS_PER_SEC / 1000));//print the ex.time
system("pause"); //this command does not let the output window to close
return 0; /ormally, by returning zero, we mean that the program ended successfully. }
void init() {
float e = 0.1234f, p = 0.7264f, r = 0.11f;
//MMM for (unsigned int i = 0; i
}
void AVX() { __m256 ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, ymm12, ymm13, ymm14, ymm15; __m128 xmm1, xmm2; int i, j, k; float temp;
for (j = 0; j
for (i = 0; i
ymm2 = _mm256_permute2f128_ps(ymm0, ymm0, 1); ymm0 = _mm256_add_ps(ymm0, ymm2); ymm0 = _mm256_hadd_ps(ymm0, ymm0); ymm0 = _mm256_hadd_ps(ymm0, ymm0); xmm2 = _mm256_extractf128_ps(ymm0, 0); _mm_store_ss(&C[i][j], xmm2);
}
}
B. Dowload the avx.cpp file. Convert the 'avx()' assembly routine to plain C code (without AVX intrinsics) (15 Marks)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started