From 5a897f62cb4a09de7541022ed02344f9a8bf6e53 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Fri, 2 Apr 2021 17:30:51 +0200 Subject: [PATCH] recv should return MPI_ERR_TRUNCATE 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 | 6 ++---- src/smpi/include/smpi_request.hpp | 2 +- src/smpi/mpi/smpi_request.cpp | 8 ++++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/smpi/bindings/smpi_pmpi_request.cpp b/src/smpi/bindings/smpi_pmpi_request.cpp index 9e2dc56095..91984f91e3 100644 --- a/src/smpi/bindings/smpi_pmpi_request.cpp +++ b/src/smpi/bindings/smpi_pmpi_request.cpp @@ -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; diff --git a/src/smpi/include/smpi_request.hpp b/src/smpi/include/smpi_request.hpp index 16b89986c6..226094de7b 100644 --- a/src/smpi/include/smpi_request.hpp +++ b/src/smpi/include/smpi_request.hpp @@ -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); diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 633fcd7e7b..18df5f8f9a 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -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; -- 2.20.1