From 44c034ffa442f8ec4060f073b8debe683e7a32fa Mon Sep 17 00:00:00 2001 From: pini Date: Mon, 6 Sep 2010 09:12:10 +0000 Subject: [PATCH] Bugfix: invalid behaviour in datatype_copy. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8167 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/smpi/smpi_mpi_dt.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/smpi/smpi_mpi_dt.c b/src/smpi/smpi_mpi_dt.c index dd6b52b86b..de903ef5d0 100644 --- a/src/smpi/smpi_mpi_dt.c +++ b/src/smpi/smpi_mpi_dt.c @@ -112,20 +112,15 @@ int smpi_datatype_copy(void* sendbuf, int sendcount, MPI_Datatype sendtype, void /* First check if we really have something to do */ if(recvcount == 0) { retval = sendcount == 0 ? MPI_SUCCESS : MPI_ERR_TRUNCATE; - } else if(sendtype == recvtype) { - /* If same datatypes used, just copy. */ - count = sendcount < recvcount ? sendcount : recvcount; - memcpy(recvbuf, sendbuf, smpi_datatype_size(sendtype) * count); - retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS; - } else { - /* FIXME: cases - * - If receive packed. - * - If send packed - * to be treated once we have the MPI_Pack things ... - **/ - retval = MPI_SUCCESS; - } - return retval; + } else { + /* FIXME: treat packed cases */ + sendcount *= smpi_datatype_size(sendtype); + recvcount *= smpi_datatype_size(recvtype); + count = sendcount < recvcount ? sendcount : recvcount; + memcpy(recvbuf, sendbuf, count); + retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS; + } + return retval; } typedef struct s_smpi_mpi_op { -- 2.20.1