Basic HTML version of Foils prepared August 29 98

Foil 46 Good Reductions

From Designing and Building Parallel Programs 2: openMP Shared Memory Programming Language DoD Modernization Tutorial -- 1995-1998. by Ian Foster, Gina Goff, Ehtesham Hayder, Chuck Koelbel(Some foils prepared by Kuck & Associates, Inc.)


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



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Apr 11 1999