Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use plain pointers in internal structures, and hopefully fix more memory leaks.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 25 Sep 2019 19:35:42 +0000 (21:35 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 25 Sep 2019 20:29:55 +0000 (22:29 +0200)
src/smpi/include/smpi_group.hpp
src/smpi/mpi/smpi_group.cpp

index e033edc..9607843 100644 (file)
@@ -20,8 +20,8 @@ class Group : public F2C{
   /* This is actually a map from int to int. 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::vector<s4u::ActorPtr> rank_to_actor_map_;
-  std::map<s4u::ActorPtr, int> actor_to_rank_map_;
+  std::vector<s4u::Actor*> rank_to_actor_map_;
+  std::map<s4u::Actor*, int> actor_to_rank_map_;
   std::vector<int> index_to_rank_map_;
 
   int refcount_ = 1; /* refcount_: start > 0 so that this group never gets freed */
@@ -33,7 +33,7 @@ public:
   void set_mapping(s4u::ActorPtr actor, int rank);
   int rank(int index);
   s4u::ActorPtr actor(int rank);
-  int rank(const s4u::ActorPtr process);
+  int rank(s4u::ActorPtr process);
   void ref();
   static void unref(MPI_Group group);
   int size() { return size_; }
index 68d86f8..eea8e73 100644 (file)
@@ -28,8 +28,9 @@ Group::Group(Group* origin)
   }
 }
 
-void Group::set_mapping(s4u::ActorPtr actor, int rank)
+void Group::set_mapping(s4u::ActorPtr actor_ptr, int rank)
 {
+  s4u::Actor* actor = actor_ptr.get();
   if (0 <= rank && rank < size_) {
     int index                = actor->get_pid();
     if (index != MPI_UNDEFINED) {
@@ -39,9 +40,7 @@ void Group::set_mapping(s4u::ActorPtr actor, int rank)
     }
 
     rank_to_actor_map_[rank] = actor;
-    if (actor != nullptr) {
-      actor_to_rank_map_.insert({actor, rank});
-    }
+    actor_to_rank_map_.insert({actor, rank});
   }
 }
 
@@ -64,9 +63,9 @@ s4u::ActorPtr Group::actor(int rank)
     return nullptr;
 }
 
-int Group::rank(const s4u::ActorPtr actor)
+int Group::rank(s4u::ActorPtr actor)
 {
-  auto iterator = actor_to_rank_map_.find(actor);
+  auto iterator = actor_to_rank_map_.find(actor.get());
   return (iterator == actor_to_rank_map_.end()) ? MPI_UNDEFINED : (*iterator).second;
 }