Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill smpi::Group::rank(s4u::Actor*).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 18 Apr 2021 19:14:49 +0000 (21:14 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 18 Apr 2021 21:47:14 +0000 (23:47 +0200)
src/smpi/include/smpi_group.hpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_group.cpp

index d653812..d16e40d 100644 (file)
@@ -16,10 +16,9 @@ namespace simgrid{
 namespace smpi{
 
 class Group : public F2C{
-  /* This is actually a map from int to s4u::Actor*. We could use std::map here, but looking up a value there costs
+  /* This is actually a map from int to aid_t. We could use std::map here, but looking up a value there costs
    * O(log(n)). For a vector, this costs O(1). We hence go with the vector.
    */
-  std::map<s4u::Actor*, int> actor_to_rank_map_;
   std::vector<aid_t> rank_to_pid_map_;
   std::vector<int> pid_to_rank_map_;
 
@@ -37,7 +36,6 @@ public:
   int rank(aid_t pid) const;
   aid_t actor_pid(int rank) const;
   std::string name() const override {return std::string("MPI_Group");}
-  int rank(s4u::Actor* process) const;
   void ref();
   static void unref(MPI_Group group);
   int size() const { return static_cast<int>(rank_to_pid_map_.size()); }
index 81852a5..7afc994 100644 (file)
@@ -153,7 +153,7 @@ int Comm::rank() const
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->rank();
-  return group_->rank(s4u::Actor::self());
+  return group_->rank(s4u::this_actor::get_pid());
 }
 
 int Comm::id() const
index cda925b..13d0d00 100644 (file)
@@ -16,10 +16,8 @@ namespace smpi{
 Group::Group(const Group* origin)
 {
   if (origin != MPI_GROUP_NULL && origin != MPI_GROUP_EMPTY) {
-    // FIXME: cheinrich: There is no such thing as an index any more; the two maps should be removed
-    rank_to_pid_map_   = origin->rank_to_pid_map_;
-    pid_to_rank_map_   = origin->pid_to_rank_map_;
-    actor_to_rank_map_ = origin->actor_to_rank_map_;
+    rank_to_pid_map_ = origin->rank_to_pid_map_;
+    pid_to_rank_map_ = origin->pid_to_rank_map_;
   }
 }
 
@@ -28,10 +26,8 @@ void Group::set_mapping(aid_t pid, int rank)
   if (0 <= rank && rank < size()) {
     if (static_cast<size_t>(pid) >= pid_to_rank_map_.size())
       pid_to_rank_map_.resize(pid + 1, MPI_UNDEFINED);
-    rank_to_pid_map_[rank]   = pid;
-    pid_to_rank_map_[pid]    = rank;
-    s4u::Actor* actor        = s4u::Actor::by_pid(pid).get();
-    actor_to_rank_map_.insert({actor, rank});
+    rank_to_pid_map_[rank] = pid;
+    pid_to_rank_map_[pid]  = rank;
   }
 }
 
@@ -53,18 +49,6 @@ aid_t Group::actor_pid(int rank) const
   return (0 <= rank && rank < size()) ? rank_to_pid_map_[rank] : -1;
 }
 
-int Group::rank(s4u::Actor* actor) const
-{
-  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());
-  int res = (iterator == actor_to_rank_map_.end()) ? MPI_UNDEFINED : (*iterator).second;
-  int rank2 = rank(actor->get_pid());
-  xbt_assert(res == rank2, "res = %d, rank2 = %d", res, rank2);
-  return res;
-}
-
 void Group::ref()
 {
   refcount_++;