Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix: invalid behaviour in datatype_copy.
authorpini <pini@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 6 Sep 2010 09:12:10 +0000 (09:12 +0000)
committerpini <pini@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 6 Sep 2010 09:12:10 +0000 (09:12 +0000)
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

index dd6b52b..de903ef 100644 (file)
@@ -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 {