Good Reductions
Correct reduction:
c$omp parallel private(suml,i)
c$omp& shared(sum,a,n)
suml = 0.0
c$omp do
do 10 i=1,n
10 suml = suml + a(i)
c$omp critical
sum = sum + suml
c$omp end critical
c$omp end parallel
Using Reduction does the same:
c$omp parallel private(i)
c$omp& shared(a,n)
c$omp& reduction(+:sum)
c$omp do
do 10 i=1,n
10 sum = sum + a(i)
c$omp end parallel
Previous slide
Next slide
Back to first slide
View graphic version