From: Augustin Degomme Date: Tue, 6 Apr 2021 18:05:22 +0000 (+0200) Subject: try to improve handling of comm_self a bit. X-Git-Tag: v3.28~455^2~128 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e2ca66b723c8ff551c9264e10aee802ebeb5e159 try to improve handling of comm_self a bit. --- diff --git a/src/smpi/bindings/smpi_pmpi_group.cpp b/src/smpi/bindings/smpi_pmpi_group.cpp index a3d37984e6..eb8a2d71f0 100644 --- a/src/smpi/bindings/smpi_pmpi_group.cpp +++ b/src/smpi/bindings/smpi_pmpi_group.cpp @@ -140,7 +140,9 @@ int PMPI_Group_excl(MPI_Group group, int n, const int *ranks, MPI_Group * newgro return MPI_ERR_ARG; } else if (n == 0) { *newgroup = group; - if (group != MPI_COMM_WORLD->group() && group != MPI_COMM_SELF->group() && group != MPI_GROUP_EMPTY) + if (group != MPI_GROUP_EMPTY && + group != MPI_COMM_WORLD->group() && + ((smpi_process()->comm_self_is_set()) || (group != MPI_COMM_SELF->group()))) group->ref(); return MPI_SUCCESS; } else if (n == group->size()) { @@ -200,8 +202,9 @@ int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group * n } if (n == 0) { *newgroup = group; - if (group != MPI_COMM_WORLD->group() && group != MPI_COMM_SELF->group() && - group != MPI_GROUP_EMPTY) + if (group != MPI_GROUP_EMPTY && + group != MPI_COMM_WORLD->group() && + ((smpi_process()->comm_self_is_set()) || (group != MPI_COMM_SELF->group()))) group->ref(); return MPI_SUCCESS; } else { diff --git a/src/smpi/include/smpi_actor.hpp b/src/smpi/include/smpi_actor.hpp index 3da3086eb1..1b43f2cabc 100644 --- a/src/smpi/include/smpi_actor.hpp +++ b/src/smpi/include/smpi_actor.hpp @@ -75,6 +75,7 @@ public: void simulated_start(); double simulated_elapsed() const; MPI_Comm comm_world() const; + bool comm_self_is_set() {return (comm_self_ != MPI_COMM_NULL);}; MPI_Comm comm_self(); MPI_Comm comm_intra(); void set_comm_intra(MPI_Comm comm); diff --git a/src/smpi/internals/smpi_actor.cpp b/src/smpi/internals/smpi_actor.cpp index 75b0c806af..767faca285 100644 --- a/src/smpi/internals/smpi_actor.cpp +++ b/src/smpi/internals/smpi_actor.cpp @@ -177,6 +177,7 @@ MPI_Comm ActorExt::comm_self() if (comm_self_ == MPI_COMM_NULL) { auto* group = new Group(1); comm_self_ = new Comm(group, nullptr); + comm_self_->set_name("MPI_COMM_SELF"); group->set_mapping(actor_, 0); } return comm_self_; diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index bde50b6e60..e082fc6134 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -170,9 +170,6 @@ void Comm::get_name(char* name, int* len) const if(this == MPI_COMM_WORLD && name_.empty()) { strncpy(name, "MPI_COMM_WORLD", 15); *len = 14; - } else if(this == MPI_COMM_SELF && name_.empty()) { - strncpy(name, "MPI_COMM_SELF", 14); - *len = 13; } else { *len = snprintf(name, MPI_MAX_NAME_STRING+1, "%s", name_.c_str()); }