Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Const for pointer and reference parameters (slight return).
[simgrid.git] / src / smpi / mpi / smpi_group.cpp
index 00d32b2a5822ce9922a7596fa22fe69e52b53e36..37b2a22d6eb0e79b8393c79f2e6f48a94f6586da 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,7 +14,7 @@ MPI_Group MPI_GROUP_EMPTY=&mpi_MPI_GROUP_EMPTY;
 namespace simgrid{
 namespace smpi{
 
-Group::Group(Group* origin)
+Group::Group(const Group* origin)
 {
   if (origin != MPI_GROUP_NULL && origin != MPI_GROUP_EMPTY) {
     size_              = origin->size();
@@ -62,6 +62,9 @@ s4u::Actor* Group::actor(int rank)
 int Group::rank(s4u::Actor* actor)
 {
   auto iterator = actor_to_rank_map_.find(actor);
+  //I'm not in the communicator ... but maybe my parent is ?
+  if (iterator == actor_to_rank_map_.end())
+    iterator = actor_to_rank_map_.find(s4u::Actor::by_pid(actor->get_ppid()).get());
   return (iterator == actor_to_rank_map_.end()) ? MPI_UNDEFINED : (*iterator).second;
 }
 
@@ -219,7 +222,6 @@ int Group::excl(int n, const int *ranks, MPI_Group * newgroup){
   }
   delete[] to_exclude;
   return MPI_SUCCESS;
-
 }
 
 static bool is_rank_in_range(int rank, int first, int last)
@@ -320,7 +322,7 @@ MPI_Group Group::f2c(int id) {
     char key[KEY_SIZE];
     return static_cast<MPI_Group>(F2C::f2c_lookup()->at(get_key(key, id)));
   } else {
-    return static_cast<MPI_Group>(MPI_GROUP_NULL);
+    return MPI_GROUP_NULL;
   }
 }