Question: The given code : #include #include #include #include #include #include #ifdef __cplusplus extern C { #endif void generateMergeSortData (int* arr, size_t n); void checkMergeSortResult (int*

 The given code : #include #include #include #include #include #include #ifdef

The given code :

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

#ifdef __cplusplus extern "C" { #endif void generateMergeSortData (int* arr, size_t n); void checkMergeSortResult (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]); // get arr data int * arr = new int [n]; generateMergeSortData (arr, n);

//insert sorting code here.

checkMergeSortResult (arr, n); delete[] arr;

return 0; }

4 Merge Sort Question: Implement a parallel function using OpenMP parallel loop constructs to perform merge sort on an array of integer. Use the template of mergesort.cpp. Output the time it took on stderr. Note that the data is generated by function generateMergeSortData and the results is checked by checkMergeSortResult. Question: Run the code on mamba using make bench mergesort. And then plot the results using make plot mergesort. Does the plot make sense? Why? 4 Merge Sort Question: Implement a parallel function using OpenMP parallel loop constructs to perform merge sort on an array of integer. Use the template of mergesort.cpp. Output the time it took on stderr. Note that the data is generated by function generateMergeSortData and the results is checked by checkMergeSortResult. Question: Run the code on mamba using make bench mergesort. And then plot the results using make plot mergesort. Does the plot 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!