You develop an application that reads data from a file, performs calculations on the data, and writes the result to another file. The read and write operations are atomic and are not parallelized.You divide the calculation tasks across a set of threads by using the following do construct. (Line numbers are included for reference only.)
01 #pragma omp parallel shared(in, out, len)
02 {
03 read_array(in, len);
05 #pragma omp for private(j)
06 for(j=1; j<len; j++)
07 compute_result(out(j),in,len);
08 write_array(out, len);
09 }
You need to ensure that the read and write tasks are performed by a single thread. Which two actions should you perform? (Each correct answer presents part of the solution.
Choose two.)
A.
Insert the following line of code after line 07:
#pragma omp barrier
B.
Insert the following line of code after line 07:
#pragma omp single nowait
C.
Insert the following line of code after line 02:
#pragma omp single
D.
Insert the following line of code after line 02:
#pragma omp single nowait