From: Augustin Degomme Date: Mon, 1 Jul 2013 15:54:34 +0000 (+0200) Subject: handle MPI_IN_PLACE for basic reduce X-Git-Tag: v3_9_90~212 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/46a70e098d1d50876b9cf0576cac2357725cf54f handle MPI_IN_PLACE for basic reduce --- diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 875ce4ebce..84c53dc403 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -1176,24 +1176,29 @@ void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count, MPI_Request *requests; void **tmpbufs; + char* sendtmpbuf = (char*) sendbuf; + if( sendbuf == MPI_IN_PLACE ) { + sendtmpbuf = (char *)recvbuf; + } + rank = smpi_comm_rank(comm); size = smpi_comm_size(comm); //non commutative case, use a working algo from openmpi if(!smpi_op_is_commute(op)){ - smpi_coll_tuned_reduce_ompi_basic_linear(sendbuf, recvbuf, count, + smpi_coll_tuned_reduce_ompi_basic_linear(sendtmpbuf, recvbuf, count, datatype, op, root, comm); return; } if(rank != root) { // Send buffer to root - smpi_mpi_send(sendbuf, count, datatype, root, system_tag, comm); + smpi_mpi_send(sendtmpbuf, count, datatype, root, system_tag, comm); } else { // FIXME: check for errors smpi_datatype_extent(datatype, &lb, &dataext); // Local copy from root - if (sendbuf && recvbuf) - smpi_datatype_copy(sendbuf, count, datatype, recvbuf, count, datatype); + if (sendtmpbuf && recvbuf) + smpi_datatype_copy(sendtmpbuf, count, datatype, recvbuf, count, datatype); // Receive buffers from senders //TODO: make a MPI_barrier here ? requests = xbt_new(MPI_Request, size - 1);