Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to improve handling of comm_self a bit.
authorAugustin Degomme <adegomme@users.noreply.github.com>
Tue, 6 Apr 2021 18:05:22 +0000 (20:05 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Tue, 6 Apr 2021 18:07:17 +0000 (20:07 +0200)
src/smpi/bindings/smpi_pmpi_group.cpp
src/smpi/include/smpi_actor.hpp
src/smpi/internals/smpi_actor.cpp
src/smpi/mpi/smpi_comm.cpp

index a3d3798..eb8a2d7 100644 (file)
@@ -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 {
index 3da3086..1b43f2c 100644 (file)
@@ -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);
index 75b0c80..767faca 100644 (file)
@@ -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_;
index bde50b6..e082fc6 100644 (file)
@@ -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());
   }