Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Show that P[A\B] P[A] P[A[B] P[A]P[B].

Answered: 1 week ago

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago

Question

Language in Context?

Answered: 1 week ago