Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix segfault seen with mpich3-test/perf/nestvec2.
[simgrid.git] / src / smpi / mpi / smpi_datatype.cpp
index b738b7b..2457c8f 100644 (file)
@@ -193,6 +193,11 @@ bool Datatype::is_valid(){
   return (flags_ & DT_FLAG_COMMITED);
 }
 
+bool Datatype::is_basic()
+{
+  return (flags_ & DT_FLAG_BASIC);
+}
+
 size_t Datatype::size(){
   return size_;
 }
@@ -246,7 +251,8 @@ void Datatype::set_name(char* name){
 int Datatype::pack(void* inbuf, int incount, void* outbuf, int outcount, int* position,MPI_Comm comm){
   if (outcount - *position < incount*static_cast<int>(size_))
     return MPI_ERR_BUFFER;
-  Datatype::copy(inbuf, incount, this, static_cast<char*>(outbuf) + *position, outcount, MPI_CHAR);
+  Datatype::copy(inbuf == MPI_BOTTOM ? nullptr : inbuf, incount, this, static_cast<char*>(outbuf) + *position, outcount,
+                 MPI_CHAR);
   *position += incount * size_;
   return MPI_SUCCESS;
 }
@@ -278,9 +284,9 @@ int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
       if (not smpi_process()->replaying())
         memcpy(recvbuf, sendbuf, count);
     } else if (not(sendtype->flags() & DT_FLAG_DERIVED)) {
-      recvtype->unserialize( sendbuf, recvbuf, recvcount/recvtype->size(), MPI_REPLACE);
+      recvtype->unserialize(sendbuf, recvbuf, count / recvtype->size(), MPI_REPLACE);
     } else if (not(recvtype->flags() & DT_FLAG_DERIVED)) {
-      sendtype->serialize(sendbuf, recvbuf, sendcount/sendtype->size());
+      sendtype->serialize(sendbuf, recvbuf, count / sendtype->size());
     }else{
 
       void * buf_tmp = xbt_malloc(count);