Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
recv should return MPI_ERR_TRUNCATE
authorAugustin Degomme <adegomme@gmail.com>
Fri, 2 Apr 2021 15:30:51 +0000 (17:30 +0200)
committerAugustin Degomme <adegomme@gmail.com>
Fri, 2 Apr 2021 18:03:31 +0000 (20:03 +0200)
we crash properly when needed, but don't return it properly if errhandler is meant not to crash

src/smpi/bindings/smpi_pmpi_request.cpp
src/smpi/include/smpi_request.hpp
src/smpi/mpi/smpi_request.cpp

index 9e2dc56..91984f9 100644 (file)
@@ -259,8 +259,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
                                                        datatype->is_replayable() ? count : count * datatype->size(),
                                                        tag, simgrid::smpi::Datatype::encode(datatype)));
 
-    simgrid::smpi::Request::recv(buf, count, datatype, src, tag, comm, status);
-    retval = MPI_SUCCESS;
+    retval = simgrid::smpi::Request::recv(buf, count, datatype, src, tag, comm, status);
 
     // the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
     int src_traced=0;
@@ -415,8 +414,7 @@ int PMPI_Sendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, int
       simgrid::smpi::Request::send(sendbuf, sendcount, sendtype, dst, sendtag, comm);
     retval = MPI_SUCCESS;
   } else if (dst == MPI_PROC_NULL){
-    simgrid::smpi::Request::recv(recvbuf, recvcount, recvtype, src, recvtag, comm, status);
-    retval = MPI_SUCCESS;
+    retval = simgrid::smpi::Request::recv(recvbuf, recvcount, recvtype, src, recvtag, comm, status);
   } else if (dst >= comm->group()->size() || dst <0 ||
       (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0))){
     retval = MPI_ERR_RANK;
index 16b8998..226094d 100644 (file)
@@ -91,7 +91,7 @@ public:
   static MPI_Request issend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
   static MPI_Request irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
 
-  static void recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status);
+  static int recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status);
   static void bsend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
   static void send(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
   static void ssend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
index 633fcd7..18df5f8 100644 (file)
@@ -313,12 +313,13 @@ MPI_Request Request::irecv(void *buf, int count, MPI_Datatype datatype, int src,
   return request;
 }
 
-void Request::recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status)
+int Request::recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status)
 {
   MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */
   request = irecv(buf, count, datatype, src, tag, comm);
-  wait(&request,status);
+  int retval = wait(&request,status);
   request = nullptr;
+  return retval;
 }
 
 void Request::bsend(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
@@ -1023,6 +1024,9 @@ int Request::wait(MPI_Request * request, MPI_Status * status)
     ret = ((*request)->generalized_funcs)->query_fn(((*request)->generalized_funcs)->extra_state, mystatus);
   }
 
+  if ((*request)->truncated_)
+    ret = MPI_ERR_TRUNCATE;
+
   finish_wait(request, status); // may invalidate *request
   if (*request != MPI_REQUEST_NULL && (((*request)->flags_ & MPI_REQ_NON_PERSISTENT) != 0))
     *request = MPI_REQUEST_NULL;