whenever try call mpi_reduce mpi_in_place send buffer crashes. trawl of google reveals have been problem on mac os ompi 1.3.3 - i'm on centos ompi 1.6.3 (with gfortran 4.4.6).
the following program crashes:
program reduce use mpi implicit none real, dimension(2, 3) :: buffer, gbuffer integer :: ierr, me_world integer :: buf_shape(2), counts call mpi_init(ierr) call mpi_comm_rank(mpi_comm_world, me_world, ierr) buffer = 1. if (me_world .eq. 0) print*, "buffer: ", buffer buf_shape = shape(buffer) counts = buf_shape(1)*buf_shape(2) call mpi_reduce(mpi_in_place, buffer, counts, mpi_real, mpi_sum, 0, mpi_comm_world, ierr) if (me_world .eq. 0) print*, "buffer: ", buffer call mpi_finalize(ierr) end program reduce the mpi error is:
mpi_err_arg: invalid argument of other kind which not helpful.
am missing how mpi_reduce should called? work other compilers/mpi implementations?
you missing important part of how in-place reduction operation works in mpi (see bolded text):
when communicator intracommunicator, can perform reduce operation in-place (the output buffer used input buffer). use variable
mpi_in_placevalue of root process sendbuf. in case, input data taken @ root receive buffer, replaced output data.
the other processes still have supply local buffers sendbuf, not mpi_in_place:
if (me_world == 0) call mpi_reduce(mpi_in_place, buffer, counts, mpi_real, mpi_sum, 0, mpi_comm_world, ierr) else call mpi_reduce(buffer, buffer, counts, mpi_real, mpi_sum, 0, mpi_comm_world, ierr) end if you can safely pass buffer both sendbuf , recvbuf in non-root processes since mpi_reduce not write recvbuf in processes.
Comments
Post a Comment