You create an OpenMP application by using Microsoft Visual C++. You write the following code segment. (Line numbers are included for reference only.)
01 #pragma omp parallel for
02 for(int i=0;i<10000;i++)
03 {
04 //Do some calculations
06 }
07 #pragma omp parallel for
08 for(int j=0;j<22000;j++)
09 {
10 //Do some calculations
11 }
Both for loops are mutually independent and no load imbalance occurs. You need to rewrite the code segment to remove any overhead and to improve the performance of the application.
Which code segment should you write?
A.
#pragma omp parallel for ordered
for(int i=0;i<10000;i++) {
//Do some calculations
}
#pragma omp parallel for
for(int j=0;j<22000;j++) {
//Do some calculations
}
B.
#pragma omp parallel for schedule(dynamic)
for(int i=0;i<10000;i++) {
//Do some calculations
}
#pragma omp parallel for schedule(dynamic)
for(int j=0;j<22000;j++) {
//Do some calculations
}
C.
#pragma omp parallel {
#pragma omp for nowait
for(int i=0;i<10000;i++) {
//Do some calculations
#pragma omp for
for(int j=0;j<22000;j++) {
//Do some calculations
}
}
D.
#pragma omp parallel {
int i,j;
#pragma omp for private(i)
for(i=0;i<10000;i++) {
//Do some calculations
}
#pragma omp for private(j)
for(j=0;j<22000;j++) {
//Do some calculations
}
}