From: Arnaud Giersch Date: Wed, 6 Mar 2013 10:02:20 +0000 (+0100) Subject: Really copy only when recvbuf != sendbuf. X-Git-Tag: v3_9_90~472 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/885b28633a8f79309c6b6066bbdf0d281e34d19d Really copy only when recvbuf != sendbuf. And avoid to call memcpy with overlapping regions. --- diff --git a/src/smpi/smpi_mpi_dt.c b/src/smpi/smpi_mpi_dt.c index 06123eb9a6..29471e963e 100644 --- a/src/smpi/smpi_mpi_dt.c +++ b/src/smpi/smpi_mpi_dt.c @@ -153,12 +153,10 @@ MPI_Aint smpi_datatype_get_extent(MPI_Datatype datatype){ int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype) { - int retval, count; + int count; /* First check if we really have something to do */ - if (recvcount == 0) { - retval = sendcount == 0 ? MPI_SUCCESS : MPI_ERR_TRUNCATE; - } else { + if (recvcount > 0 && recvbuf != sendbuf) { /* FIXME: treat packed cases */ sendcount *= smpi_datatype_size(sendtype); recvcount *= smpi_datatype_size(recvtype); @@ -189,10 +187,9 @@ int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, free(buf_tmp); } - retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS; } - return retval; + return sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS; } /*