Question: Reduce.cpp #include #include #include #include #include #include #include #ifdef __cplusplus extern C { #endif void generateReduceData (int* arr, size_t n); #ifdef __cplusplus } #endif int

 Reduce.cpp #include #include #include #include #include #include #include #ifdef __cplusplus extern

Reduce.cpp

#include #include #include #include #include #include #include

#ifdef __cplusplus extern "C" { #endif void generateReduceData (int* arr, size_t n); #ifdef __cplusplus } #endif

int main (int argc, char* argv[]) { //forces openmp to create the threads beforehand #pragma omp parallel { int fd = open (argv[0], O_RDONLY); if (fd != -1) { close (fd); } else { std::cerr "

int n = atoi(argv[1]); int * arr = new int [n];

generateReduceData (arr, atoi(argv[1]));

//insert reduction code here delete[] arr;

return 0; }

1 Reduce Question: Write a program that compute the sum of an array in parallel using the OpenMP for loop construct. Measure the time computing the sum takes. Write the program so that you can control the length of the array, the number of thread and the scheduling policy; passed as parameters to main. Output the value of the reduction to stdout and the time taken to compute it to stderr. Use the template of reduce. cpp; note that the array to reduce is obtain by calling the provided generateReduceData function. Test it works with make test.reduce. Question: Run the code on mamba using make bench reduce. Plot speedup charts with make plot reduce. Does the plots make sense? Why

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!