A Practical Approach to High-Performance Computing by Sergei Kurgalin & Sergei Borzunov

A Practical Approach to High-Performance Computing by Sergei Kurgalin & Sergei Borzunov

Author:Sergei Kurgalin & Sergei Borzunov
Language: eng
Format: epub
ISBN: 9783030275587
Publisher: Springer International Publishing


(c) // filling the array res[] in the order in which

// iterations follow in a sequential loop

#pragma omp parallel ordered

for(int i=0;i<ceil(log2(N));i++)

res[i]=func(1.0/(i+1));

(d) // writing the values of func() into a file,

// the order of the lines does not matter

#pragma omp parallel private(k,y)

{

k = omp_get_thread_num();

y = func(k);

fprintf(fp, "%d\t %lf\n", k, y);

}

5.3.Suppose that the size m of the blocks for parallelizing a loop of N iterations in a static way is given. What is the number k of the thread that will implement the i-th loop iteration if the number of threads in the team is equal to p?



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.