From: Frederic Suter Date: Mon, 8 Apr 2019 07:03:16 +0000 (+0200) Subject: Merge branch 'master' of https://framagit.org/simgrid/simgrid X-Git-Tag: v3.22.2~163 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b830103bb89748d30c84ff7a0e88ca821d2d78b7?hp=6f5a3a45f1fc86d0ca10bc6c31e22e5686071f45 Merge branch 'master' of https://framagit.org/simgrid/simgrid --- diff --git a/src/smpi/bindings/smpi_pmpi_coll.cpp b/src/smpi/bindings/smpi_pmpi_coll.cpp index 415f12692c..2eb62c2c09 100644 --- a/src/smpi/bindings/smpi_pmpi_coll.cpp +++ b/src/smpi/bindings/smpi_pmpi_coll.cpp @@ -417,7 +417,7 @@ int PMPI_Ireduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, { if (comm == MPI_COMM_NULL) { return MPI_ERR_COMM; - } if ((sendbuf == nullptr && count > 0) || ((comm->rank() == root) && recvbuf == nullptr)) { + } else if ((sendbuf == nullptr && count > 0) || ((comm->rank() == root) && recvbuf == nullptr)) { return MPI_ERR_BUFFER; } else if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid()){ return MPI_ERR_TYPE; @@ -475,7 +475,7 @@ int PMPI_Iallreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype dataty { if (comm == MPI_COMM_NULL) { return MPI_ERR_COMM; - } if ((sendbuf == nullptr && count > 0) || (recvbuf == nullptr)) { + } else if ((sendbuf == nullptr && count > 0) || (recvbuf == nullptr)) { return MPI_ERR_BUFFER; } else if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid()) { return MPI_ERR_TYPE; @@ -534,6 +534,8 @@ int PMPI_Iscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, M retval = MPI_ERR_ARG; } else if (count < 0){ retval = MPI_ERR_COUNT; + } else if (sendbuf == nullptr || recvbuf == nullptr){ + retval = MPI_ERR_BUFFER; } else { int rank = simgrid::s4u::this_actor::get_pid(); void* sendtmpbuf = sendbuf; @@ -580,6 +582,8 @@ int PMPI_Iexscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, retval = MPI_ERR_ARG; } else if (count < 0){ retval = MPI_ERR_COUNT; + } else if (sendbuf == nullptr || recvbuf == nullptr){ + retval = MPI_ERR_BUFFER; } else { int rank = simgrid::s4u::this_actor::get_pid(); void* sendtmpbuf = sendbuf; @@ -756,7 +760,9 @@ int PMPI_Ialltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* re MPI_Datatype sendtmptype = sendtype; if (sendbuf == MPI_IN_PLACE) { sendtmpbuf = static_cast(xbt_malloc(recvcount * comm->size() * recvtype->size())); - memcpy(sendtmpbuf, recvbuf, recvcount * comm->size() * recvtype->size()); + //memcpy(??,nullptr,0) is actually undefined behavor, even if harmless. + if(recvbuf != nullptr) + memcpy(sendtmpbuf, recvbuf, recvcount * comm->size() * recvtype->size()); sendtmpcount = recvcount; sendtmptype = recvtype; } diff --git a/src/smpi/include/smpi_actor.hpp b/src/smpi/include/smpi_actor.hpp index 97d4d2b1f1..098642963f 100644 --- a/src/smpi/include/smpi_actor.hpp +++ b/src/smpi/include/smpi_actor.hpp @@ -31,7 +31,11 @@ class ActorExt { smpi_trace_call_location_t trace_call_loc_; s4u::ActorPtr actor_ = nullptr; smpi_privatization_region_t privatized_region_ = nullptr; - int optind = 1; /*for getopt replacement */ +#ifdef __linux__ + int optind_ = 0; /*for getopt replacement */ +#else + int optind_ = 1; /*for getopt replacement */ +#endif std::string tracing_category_ = ""; #if HAVE_PAPI diff --git a/src/smpi/internals/smpi_actor.cpp b/src/smpi/internals/smpi_actor.cpp index e657ab901b..0a9a96d395 100644 --- a/src/smpi/internals/smpi_actor.cpp +++ b/src/smpi/internals/smpi_actor.cpp @@ -246,11 +246,11 @@ void ActorExt::init() int ActorExt::get_optind() { - return optind; + return optind_; } void ActorExt::set_optind(int new_optind) { - optind = new_optind; + optind_ = new_optind; } } // namespace smpi diff --git a/teshsuite/smpi/mpich3-test/init/testlist b/teshsuite/smpi/mpich3-test/init/testlist index b2e20fbc3f..4e14874e37 100644 --- a/teshsuite/smpi/mpich3-test/init/testlist +++ b/teshsuite/smpi/mpich3-test/init/testlist @@ -6,4 +6,4 @@ version 1 finalized 1 #needs PMPI_Comm_free_keyval #attrself 1 -library_version 1 mpiversion=3.0 +library_version 1 diff --git a/teshsuite/smpi/privatization/privatization.c b/teshsuite/smpi/privatization/privatization.c index 9a9e963627..25668c8116 100644 --- a/teshsuite/smpi/privatization/privatization.c +++ b/teshsuite/smpi/privatization/privatization.c @@ -6,7 +6,8 @@ static int myvalue = 0; static void test_opts(int* argc, char **argv[]){ - int found = 0, ret; + int found = 0; + int ret; static struct option long_options[] = { {"long", no_argument, 0, 0 }, {0, 0, 0, 0 } diff --git a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c index b2fbc2148d..84217e9ea9 100644 --- a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c +++ b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c @@ -12,7 +12,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test"); static void test_opts(int* argc, char **argv[]){ - int found = 0, ret; + int found = 0; + int ret; int option_index = 0; static struct option long_options[] = { {"long", no_argument, 0, 0 }, diff --git a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c index 6ddb623680..c46ea3395b 100644 --- a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c +++ b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c @@ -10,14 +10,12 @@ #include static void test_opts(int* argc, char **argv[]){ - int found = 0, ret; + int found = 0; + int ret; while ((ret = getopt(*argc, *argv, "s")) >= 0) { - switch (ret) { - case 's': + if (ret == 's') found = 1; - break; - } } if (found!=1){ printf("(smpi_)getopt failed ! \n");