Question: Implement a parallel function using OpenMP parallel loop constructs to perform merge sort on an array of integer. Output the time it took on stderr.

Implement a parallel function using OpenMP parallel loop constructs to perform merge sort on an array of integer. Output the time it took on stderr.

#include #include #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<<"something is amiss"< "<

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

generateMergeSortData (arr, atoi(argv[1])); //write code here

checkMergeSortResult (arr, atoi(argv[1])); delete[] arr;

return 0; }

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!