From 885b28633a8f79309c6b6066bbdf0d281e34d19d Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 6 Mar 2013 11:02:20 +0100 Subject: [PATCH] Really copy only when recvbuf != sendbuf. And avoid to call memcpy with overlapping regions. --- src/smpi/smpi_mpi_dt.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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; } /* -- 2.20.1