Basic HTML version of Foils prepared August 29 98

Foil 31 Example: Performing a Sum

From Designing and Building Parallel Programs 3: MPI Message Passing System DoD Modernization Tutorial -- 1995-1998. by Ian Foster, Gina Goff, Ehtesham Hayder, Chuck Koelbel


rank = MPI_COMM_RANK( comm )
if (rank .eq. 0) then
read *, n
end if
call MPI_BCAST(n, 1, MPI_INTEGER, 0, comm )
lo = rank*n+1
hi = lo+n-1
sum = 0.0d0
do i = lo, hi
sum = sum + 1.0d0 / i
end do
call MPI_REDUCEALL( sum, sumout, 1, MPI_DOUBLE,
& MPI_ADD_DOUBLE, comm)



© 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