You are an application developer for your company. Users report that the performance of an application installed on your company s net wor k i s sl ow You use a profiler to identify the problem. You discover that in a parallel loop, one type of task takes only a few seconds to complete, whereas another type of task takes a few minutes to complete. You also discover that the tasks do not modify input data. The parallel loop is shown in the following code segment. (Line numbers are included for reference only.)
01 #pragma omp parallel shared(x) private(i, res)
03 {
04 #pragma omp for
05 for (i=0; i < N; i++)
06 {
07 res = f(i);
08 if (res < 7)
09 smallwork(x[i]);
10 else
11 bigwork(x[i]);
12 }
13 }
You need to ensure that the workload is balanced among the processors that run the application, regardless of the OpenMP API default settings. Which line of code should you use to replace the code at line 04?
A.
#pragma omp for nowait
B.
#pragma omp parallel for schedule(static)
C.
#pragma omp for schedule(static,CHUNKSIZE) nowait
D.
#pragma omp for schedule(dynamic,CHUNKSIZE) nowait