Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Recommended Textbook for

Modern Datalog Engines In Databases

Authors: Bas Ketsman ,Paraschos Koutris

1st Edition

ISBN: 1638280428, 978-1638280422

More Books

Students also viewed these Databases questions

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago