Which two lines of code should you remove?

You create an OpenMP application by using Microsoft Visual C++. You write the following lines of code. (Line numbers are included for reference only.)

01 omp_set_num_threads(10);
02 int dataA, dataB, dataC, dataD;
03 #pragma omp parallel private(dataC)
04 {
05 #pragma omp critical
06 dataC=dataA++;
07 #pragma omp atomic
08 dataC++;
09 #pragma omp master
10 {
11 #pragma omp critical
12 dataD++;
13 }
14 #pragma omp atomic
15 dataB++;
16 }

You need to remove unnecessary synchronization constructs. Which two lines of code should you remove? (Each correct answer presents part of the solution. Choose two.)

You create an OpenMP application by using Microsoft Visual C++. You write the following lines of code. (Line numbers are included for reference only.)

01 omp_set_num_threads(10);
02 int dataA, dataB, dataC, dataD;
03 #pragma omp parallel private(dataC)
04 {
05 #pragma omp critical
06 dataC=dataA++;
07 #pragma omp atomic
08 dataC++;
09 #pragma omp master
10 {
11 #pragma omp critical
12 dataD++;
13 }
14 #pragma omp atomic
15 dataB++;
16 }

You need to remove unnecessary synchronization constructs. Which two lines of code should you remove? (Each correct answer presents part of the solution. Choose two.)

A.
line 05

B.
line 07

C.
line 11

D.
line 15



Leave a Reply 0

Your email address will not be published. Required fields are marked *