Question: The following code: __________________ #include #include #include #include #define SIZE 10000000 volatile float a[SIZE]; volatile float b[SIZE]; int main(int argc, char **argv) { long int
The following code:
__________________
#include
#define SIZE 10000000
volatile float a[SIZE]; volatile float b[SIZE];
int main(int argc, char **argv) { long int i; double sum; struct timeval time1, time2;
srand(time(0)); for (i = 0; i < SIZE; i++) { a[i] = rand(); b[i] = rand(); } gettimeofday(&time1, 0); sum = 0.0; for (i = 0; i < SIZE; i++) { sum = sum + a[i]*b[i]; }
gettimeofday(&time2, 0); printf("Elapsed time (us) = %d ", (time2.tv_sec-time1.tv_sec)*1000000 + time2.tv_usec - time1.tv_usec);
return 0; }
__________________
TASKS:
We are to write a parallel MPI version of it.
1. What code do you need to add to the program? What MPI primitives are useful? Write a parallel MPI version of dotprod.c
2. Run your resulting code on di erent number of processors and produce a plot of speedup versus number of processors up to 16 processors. How do you get statistically sound measurements? For each point what efficiency do you get? What do you think are the underlying overheads leading to the efficiency
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
