From a2e5b7d16ced4cf8ceafa5d7b9c4d368311885ca Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Mon, 19 Aug 2019 11:33:25 +0200 Subject: [PATCH] Allgatherv : don't output MPI_ERR_BUFFER if recvbuf is null if we don't receive any data. FIXME : other collectives can have the same constraint relaxed --- src/smpi/bindings/smpi_pmpi_coll.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/smpi/bindings/smpi_pmpi_coll.cpp b/src/smpi/bindings/smpi_pmpi_coll.cpp index 5fafd542f3..b487d2be02 100644 --- a/src/smpi/bindings/smpi_pmpi_coll.cpp +++ b/src/smpi/bindings/smpi_pmpi_coll.cpp @@ -259,7 +259,7 @@ int PMPI_Iallgatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, { if (comm == MPI_COMM_NULL) return MPI_ERR_COMM; - if ((sendbuf == nullptr && sendcount > 0) || (recvbuf == nullptr)) + if (sendbuf == nullptr && sendcount > 0) return MPI_ERR_BUFFER; if (((sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) || (recvtype == MPI_DATATYPE_NULL)) return MPI_ERR_TYPE; @@ -270,9 +270,11 @@ int PMPI_Iallgatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, if (request == nullptr) return MPI_ERR_ARG; - for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free + for (int i = 0; i < comm->size(); i++) { if (recvcounts[i] < 0) return MPI_ERR_COUNT; + else if (recvcounts[i] > 0 && recvbuf == nullptr) + return MPI_ERR_BUFFER; } smpi_bench_end(); @@ -879,7 +881,7 @@ int PMPI_Ialltoallw(const void* sendbuf, const int* sendcounts, const int* sendd smpi_bench_end(); int rank = simgrid::s4u::this_actor::get_pid(); int size = comm->size(); - for (int i = 0; i < size; i++) { // copy data to avoid bad free + for (int i = 0; i < size; i++) { if (recvcounts[i] < 0 || (sendbuf != MPI_IN_PLACE && sendcounts[i] < 0)) return MPI_ERR_COUNT; } -- 2.20.1