Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
11 Views

In OpenMP, Reduction Clause

Why?

#pragma omp parallel for
for (i=0; i{
sum+ = a * b;
}
and

#pragma omp parallel for reduction(+:sum)
for (i=0; i{
sum+ = a * b;
}

Please tell me why the two running results are identical?
Thank you.

0 Kudos
3 Replies
Highlighted
11 Views


a) You got lucky
b) You compiled with OpenMP off
c) You compiled with OpenMP on, Nested levels off, and loop is in nested level.
d) You compiled with OpenMP on, but only 1 thread is used
e) N <= 1
f) all of a or all of b or both are 0
g) N is sufficiently small such that each thread finishes before the other starts (assuming multiple threads run the loop)


Jim Dempsey
0 Kudos
Highlighted
Beginner
11 Views


a) You got lucky
b) You compiled with OpenMP off
c) You compiled with OpenMP on, Nested levels off, and loop is in nested level.
d) You compiled with OpenMP on, but only 1 thread is used
e) N <= 1
f) all of a or all of b or both are 0
g) N is sufficiently small such that each thread finishes before the other starts (assuming multiple threads run the loop)


Jim Dempsey

0 Kudos
Highlighted
Beginner
11 Views

Thank you very much indeed for your reply.
0 Kudos