Question: Program below is sequential code calculating a dot product. Study the code carefully. Your task is to conceptually write a parallel version running on an

Program below is sequential code calculating a dot product. Study the code carefully.

Your task is to conceptually write a parallel version running on an arbitrary number of processors. You do not write code but rather you informally describe what parts of the code remain serial and what parts can be made parallel. You can, but you are not required to use pseudo code if you feel that is clearer.

__________________________

#include #include #include #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:

1. What opportunities for parallelism do you see? 2. What problems or challenges do you see limiting performance? 3. How could the problems be overcome? 4. Measure the time it takes to execute di erent parts of the serial program on the HPC machines, see last databar for login information. If a part of a program has very shortexecution time, how can you still measure the time relatively accurately? 5. Use your measurements to estimate performance of your parallel approach. How efficient do you expect your code to be? Why? How many times faster than the sequential version do you expect your code to run on N processors? N being the number of processorsavailable to you. In other words, what speedup do you expect? 6. Can you enforesee any overheads that can make your estimations inaccurate? What could these overheads be, if any?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!