Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI] Remove index notion from smpi::Group
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 11 Jan 2018 23:11:26 +0000 (00:11 +0100)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Wed, 24 Jan 2018 14:58:16 +0000 (15:58 +0100)
This is a huge commit and removes the index() function from
smpi::Group and replaces it with an actor() function.

The index was basically just Actor::getPid()-1 and doesn't need
to be saved. It was also often used for the privatization segment
(to know where it was stored) but that is no longer required.

13 files changed:
src/smpi/bindings/smpi_pmpi_coll.cpp
src/smpi/bindings/smpi_pmpi_group.cpp
src/smpi/bindings/smpi_pmpi_request.cpp
src/smpi/bindings/smpi_pmpi_win.cpp
src/smpi/include/smpi_group.hpp
src/smpi/internals/smpi_deployment.cpp
src/smpi/internals/smpi_process.cpp
src/smpi/internals/smpi_replay.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_group.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/mpi/smpi_topo.cpp
src/smpi/mpi/smpi_win.cpp

index 28ab3ae..e97643f 100644 (file)
@@ -28,7 +28,7 @@ int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm c
   } else {
     int rank        = smpi_process()->index();
     TRACE_smpi_comm_in(rank, __FUNCTION__,
-                       new simgrid::instr::CollTIData("bcast", comm->group()->index(root), -1.0,
+                       new simgrid::instr::CollTIData("bcast", comm->group()->actor(root)->getPid()-1, -1.0,
                                                       datatype->is_replayable() ? count : count * datatype->size(), -1,
                                                       encode_datatype(datatype), ""));
     if (comm->size() > 1)
@@ -94,7 +94,7 @@ int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbu
 
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::CollTIData(
-                           "gather", comm->group()->index(root), -1.0,
+                           "gather", comm->group()->actor(root)->getPid()-1, -1.0,
                            sendtmptype->is_replayable() ? sendtmpcount : sendtmpcount * sendtmptype->size(),
                            (comm->rank() != root || recvtype->is_replayable()) ? recvcount : recvcount * recvtype->size(),
                            encode_datatype(sendtmptype), encode_datatype(recvtype)));
@@ -145,7 +145,7 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recv
 
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::VarCollTIData(
-                           "gatherV", comm->group()->index(root),
+                           "gatherV", comm->group()->actor(root)->getPid()-1,
                            sendtmptype->is_replayable() ? sendtmpcount : sendtmpcount * sendtmptype->size(), nullptr,
                            dt_size_recv, trace_recvcounts, encode_datatype(sendtmptype), encode_datatype(recvtype)));
 
@@ -261,7 +261,7 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::CollTIData(
-                           "scatter", comm->group()->index(root), -1.0,
+                           "scatter", comm->group()->actor(root)->getPid()-1, -1.0,
                            (comm->rank() != root || sendtype->is_replayable()) ? sendcount : sendcount * sendtype->size(),
                            recvtype->is_replayable() ? recvcount : recvcount * recvtype->size(), encode_datatype(sendtype),
                            encode_datatype(recvtype)));
@@ -304,7 +304,7 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
     }
 
     TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
-                                               "scatterV", comm->group()->index(root), dt_size_send, trace_sendcounts,
+                                               "scatterV", comm->group()->actor(root)->getPid()-1, dt_size_send, trace_sendcounts,
                                                recvtype->is_replayable() ? recvcount : recvcount * recvtype->size(), nullptr,
                                                encode_datatype(sendtype), encode_datatype(recvtype)));
 
@@ -331,7 +331,7 @@ int PMPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
     int rank               = smpi_process()->index();
 
     TRACE_smpi_comm_in(rank, __FUNCTION__,
-                       new simgrid::instr::CollTIData("reduce", comm->group()->index(root), 0,
+                       new simgrid::instr::CollTIData("reduce", comm->group()->actor(root)->getPid()-1, 0,
                                                       datatype->is_replayable() ? count : count * datatype->size(), -1,
                                                       encode_datatype(datatype), ""));
 
index 4f1c188..0c52427 100644 (file)
@@ -61,8 +61,8 @@ int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1, MPI_Group g
       if(ranks1[i]==MPI_PROC_NULL){
         ranks2[i]=MPI_PROC_NULL;
       }else{
-        int index = group1->index(ranks1[i]);
-        ranks2[i] = group2->rank(index);
+        simgrid::s4u::ActorPtr actor = group1->actor(ranks1[i]);
+        ranks2[i] = group2->rank(actor);
       }
     }
     return MPI_SUCCESS;
index fea9af0..359c0b2 100644 (file)
@@ -160,7 +160,7 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MP
     int rank       = smpi_process()->index();
 
     TRACE_smpi_comm_in(rank, __FUNCTION__,
-                       new simgrid::instr::Pt2PtTIData("Irecv", comm->group()->index(src),
+                       new simgrid::instr::Pt2PtTIData("Irecv", comm->group()->actor(src)->getPid()-1, // TODO cheinrich was before: index(src); -- make the "-1" go away
                                                        datatype->is_replayable() ? count : count * datatype->size(),
                                                        encode_datatype(datatype)));
 
@@ -199,7 +199,7 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MP
     retval = MPI_ERR_TAG;
   } else {
     int rank      = smpi_process()->index();
-    int trace_dst = comm->group()->index(dst);
+    int trace_dst = comm->group()->actor(dst)->getPid()-1; // TODO cheinrich
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("Isend", trace_dst,
                                                        datatype->is_replayable() ? count : count * datatype->size(),
@@ -241,7 +241,7 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, M
     retval = MPI_ERR_TAG;
   } else {
     int rank      = smpi_process()->index();
-    int trace_dst = comm->group()->index(dst);
+    int trace_dst = comm->group()->actor(dst)->getPid()-1; // TODO cheinrich
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("ISsend", trace_dst,
                                                        datatype->is_replayable() ? count : count * datatype->size(),
@@ -281,7 +281,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
     retval = MPI_ERR_TAG;
   } else {
     int rank               = smpi_process()->index();
-    int src_traced         = comm->group()->index(src);
+    int src_traced         = comm->group()->actor(src)->getPid()-1; // TODO cheinrich
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("recv", src_traced,
                                                        datatype->is_replayable() ? count : count * datatype->size(),
@@ -292,7 +292,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
 
     // the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
     if (status != MPI_STATUS_IGNORE) {
-      src_traced = comm->group()->index(status->MPI_SOURCE);
+      src_traced = comm->group()->actor(status->MPI_SOURCE)->getPid()-1;
       if (not TRACE_smpi_view_internals()) {
         TRACE_smpi_recv(src_traced, rank, tag);
       }
@@ -324,7 +324,7 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI
     retval = MPI_ERR_TAG;
   } else {
     int rank               = smpi_process()->index();
-    int dst_traced         = comm->group()->index(dst);
+    int dst_traced         = comm->group()->actor(dst)->getPid()-1; // TODO cheinrich
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("send", dst_traced,
                                                        datatype->is_replayable() ? count : count * datatype->size(),
@@ -362,7 +362,7 @@ int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MP
     retval = MPI_ERR_TAG;
   } else {
     int rank               = smpi_process()->index();
-    int dst_traced         = comm->group()->index(dst);
+    int dst_traced         = comm->group()->actor(dst)->getPid()-1;
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("Ssend", dst_traced,
                                                        datatype->is_replayable() ? count : count * datatype->size(),
@@ -404,8 +404,8 @@ int PMPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst,
     retval = MPI_ERR_TAG;
   } else {
     int rank               = smpi_process()->index();
-    int dst_traced         = comm->group()->index(dst);
-    int src_traced         = comm->group()->index(src);
+    int dst_traced         = comm->group()->actor(dst)->getPid()-1;
+    int src_traced         = comm->group()->actor(src)->getPid()-1;
 
     // FIXME: Hack the way to trace this one
     std::vector<int>* dst_hack = new std::vector<int>;
index eb5aa7b..e58610f 100644 (file)
@@ -273,7 +273,7 @@ int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
     int rank = smpi_process()->index();
     MPI_Group group;
     win->get_group(&group);
-    int dst_traced = group->index(target_rank);
+    int dst_traced = group->actor(target_rank)->getPid()-1;
     TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Put", dst_traced,
                                                        origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
                                                        encode_datatype(origin_datatype)));
@@ -314,7 +314,7 @@ int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype
     int rank = smpi_process()->index();
     MPI_Group group;
     win->get_group(&group);
-    int dst_traced = group->index(target_rank);
+    int dst_traced = group->actor(target_rank)->getPid()-1;
     TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Rput", dst_traced,
                                                        origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
                                                        encode_datatype(origin_datatype)));
index 1bb4d17..f22bf4e 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "smpi_f2c.hpp"
 #include <smpi/smpi.h>
+#include <map>
 #include <vector>
 
 namespace simgrid{
@@ -21,17 +22,21 @@ class Group : public F2C{
      * 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<simgrid::s4u::ActorPtr> rank_to_actor_map_;
+    std::map<simgrid::s4u::ActorPtr, int> actor_to_rank_map_;
     std::vector<int> rank_to_index_map_;
     std::vector<int> index_to_rank_map_;
+
     int refcount_;
   public:
     explicit Group();
     explicit Group(int size);
     explicit Group(Group* origin);
 
-    void set_mapping(int index, int rank);
-    int index(int rank);
+    void set_mapping(simgrid::s4u::ActorPtr actor, int rank);
     int rank(int index);
+    simgrid::s4u::ActorPtr actor(int rank);
+    int rank(const simgrid::s4u::ActorPtr process);
     void ref();
     static void unref(MPI_Group group);
     int size();
index 7d61374..76052cf 100644 (file)
@@ -74,7 +74,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_
   smpi_instances.insert(std::pair<std::string, Instance>(name, instance));
 }
 
-void smpi_deployment_register_process(const char* instance_id, int rank, int index)
+void smpi_deployment_register_process(const char* instance_id, int rank, simgrid::s4u::ActorPtr actor)
 {
   if (smpi_instances.empty()) // no instance registered, we probably used smpirun.
     return;
@@ -82,7 +82,7 @@ void smpi_deployment_register_process(const char* instance_id, int rank, int ind
   Instance& instance = smpi_instances.at(instance_id);
 
   instance.present_processes++;
-  instance.comm_world->group()->set_mapping(index, rank);
+  instance.comm_world->group()->set_mapping(actor, rank);
 }
 
 MPI_Comm* smpi_deployment_comm_world(const char* instance_id)
index 280e5e9..184b4e6 100644 (file)
@@ -231,7 +231,7 @@ MPI_Comm Process::comm_self()
   if(comm_self_==MPI_COMM_NULL){
     MPI_Group group = new  Group(1);
     comm_self_ = new  Comm(group, nullptr);
-    group->set_mapping(index_, 0);
+    group->set_mapping(process_, 0);
   }
   return comm_self_;
 }
index a257225..0461c1c 100644 (file)
@@ -443,7 +443,7 @@ static void action_bcast(const char *const *action)
 
   int rank = smpi_process()->index();
   TRACE_smpi_comm_in(rank, __FUNCTION__,
-                     new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->index(root), -1.0, size, -1,
+                     new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->actor(root)->getPid()-1, -1.0, size, -1,
                                                     encode_datatype(MPI_CURRENT_TYPE), ""));
 
   void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
@@ -471,7 +471,7 @@ static void action_reduce(const char *const *action)
 
   int rank = smpi_process()->index();
   TRACE_smpi_comm_in(rank, __FUNCTION__,
-                     new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->index(root), comp_size,
+                     new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->actor(root)->getPid()-1, comp_size,
                                                     comm_size, -1, encode_datatype(MPI_CURRENT_TYPE), ""));
 
   void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
index a5870b8..8f5fdf0 100644 (file)
@@ -22,6 +22,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi, "Logging specific to SMPI (comm
 simgrid::smpi::Comm mpi_MPI_COMM_UNINITIALIZED;
 MPI_Comm MPI_COMM_UNINITIALIZED=&mpi_MPI_COMM_UNINITIALIZED;
 
+using simgrid::s4u::ActorPtr;
+
 /* Support for cartesian topology was added, but there are 2 other types of topology, graph et dist graph. In order to
  * support them, we have to add a field SMPI_Topo_type, and replace the MPI_Topology field by an union. */
 
@@ -216,8 +218,8 @@ MPI_Comm Comm::split(int color, int key)
           group_root = group_out; /* Save root's group */
         }
         for (unsigned j = 0; j < rankmap.size(); j++) {
-          int index = group->index(rankmap[j].second);
-          group_out->set_mapping(index, j);
+          ActorPtr actor = group->actor(rankmap[j].second);
+          group_out->set_mapping(actor, j);
         }
         MPI_Request* requests = xbt_new(MPI_Request, rankmap.size());
         int reqs              = 0;
@@ -307,9 +309,9 @@ void Comm::init_smp(){
   int min_index           = INT_MAX; // the minimum index will be the leader
   for (auto const& actor : process_list) {
     int index = actor.pid - 1;
-    if (this->group()->rank(index) != MPI_UNDEFINED) {
+    // TODO cheinrich: actor is of type ActorImpl here and I'm unsure how to convert that without the lookup byPid() ...
+    if (this->group()->rank(simgrid::s4u::Actor::byPid(actor.pid)) != MPI_UNDEFINED) { // Is this process in the current group?
       intra_comm_size++;
-      // the process is in the comm
       if (index < min_index)
         min_index = index;
     }
@@ -318,9 +320,9 @@ void Comm::init_smp(){
   MPI_Group group_intra = new  Group(intra_comm_size);
   int i = 0;
   for (auto const& actor : process_list) {
-    int index = actor.pid - 1;
-    if(this->group()->rank(index)!=MPI_UNDEFINED){
-      group_intra->set_mapping(index, i);
+    // TODO cheinrich : We should not need the const_cast here and above.
+    if(this->group()->rank(simgrid::s4u::Actor::byPid(actor.pid))!=MPI_UNDEFINED){
+      group_intra->set_mapping(simgrid::s4u::Actor::byPid(actor.pid), i);
       i++;
     }
   }
@@ -365,7 +367,7 @@ void Comm::init_smp(){
   if(MPI_COMM_WORLD!=MPI_COMM_UNINITIALIZED && this!=MPI_COMM_WORLD){
     //create leader_communicator
     for (i=0; i< leader_group_size;i++)
-      leaders_group->set_mapping(leader_list[i], i);
+      leaders_group->set_mapping(simgrid::s4u::Actor::byPid(leader_list[i]+1), i);
     leader_comm = new  Comm(leaders_group, nullptr);
     this->set_leaders_comm(leader_comm);
     this->set_intra_comm(comm_intra);
@@ -373,7 +375,7 @@ void Comm::init_smp(){
     // create intracommunicator
   }else{
     for (i=0; i< leader_group_size;i++)
-      leaders_group->set_mapping(leader_list[i], i);
+      leaders_group->set_mapping(simgrid::s4u::Actor::byPid(leader_list[i]+1), i);
 
     if(this->get_leaders_comm()==MPI_COMM_NULL){
       leader_comm = new  Comm(leaders_group, nullptr);
@@ -412,9 +414,9 @@ void Comm::init_smp(){
   }
   // Are the ranks blocked ? = allocated contiguously on the SMP nodes
   int is_blocked=1;
-  int prev=this->group()->rank(comm_intra->group()->index(0));
+  int prev=this->group()->rank(comm_intra->group()->actor(0));
   for (i = 1; i < my_local_size; i++) {
-    int that = this->group()->rank(comm_intra->group()->index(i));
+    int that = this->group()->rank(comm_intra->group()->actor(i));
     if (that != prev + 1) {
       is_blocked = 0;
       break;
index 89fbf59..b22a46c 100644 (file)
@@ -3,6 +3,7 @@
 /* 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. */
 
+#include "simgrid/s4u/Actor.hpp"
 #include "smpi_group.hpp"
 #include "smpi_comm.hpp"
 #include <string>
@@ -16,13 +17,15 @@ MPI_Group MPI_GROUP_EMPTY=&mpi_MPI_GROUP_EMPTY;
 namespace simgrid{
 namespace smpi{
 
+using simgrid::s4u::ActorPtr;
+
 Group::Group()
 {
   size_              = 0;       /* size */
   refcount_          = 1;       /* refcount_: start > 0 so that this group never gets freed */
 }
 
-Group::Group(int n) : size_(n), rank_to_index_map_(size_, MPI_UNDEFINED)
+Group::Group(int n) : size_(n), rank_to_actor_map_(size_, nullptr), rank_to_index_map_(size_, MPI_UNDEFINED), index_to_rank_map_(size_, MPI_UNDEFINED)
 {
   refcount_ = 1;
 }
@@ -34,29 +37,27 @@ Group::Group(MPI_Group origin)
     refcount_          = 1;
     rank_to_index_map_ = origin->rank_to_index_map_;
     index_to_rank_map_ = origin->index_to_rank_map_;
+    rank_to_actor_map_ = origin->rank_to_actor_map_;
+    actor_to_rank_map_ = origin->actor_to_rank_map_;
   }
 }
 
-void Group::set_mapping(int index, int rank)
+void Group::set_mapping(simgrid::s4u::ActorPtr actor, int rank)
 {
   if (0 <= rank && rank < size_) {
+    int index = actor->getPid()-1;
     rank_to_index_map_[rank] = index;
     if (index != MPI_UNDEFINED) {
       if ((unsigned)index >= index_to_rank_map_.size())
         index_to_rank_map_.resize(index + 1, MPI_UNDEFINED);
       index_to_rank_map_[index] = rank;
     }
-  }
-}
 
-int Group::index(int rank)
-{
-  int index;
-  if (0 <= rank && rank < size_)
-    index = rank_to_index_map_[rank];
-  else
-    index = MPI_UNDEFINED;
-  return index;
+    rank_to_actor_map_[rank] = actor;
+    if (actor != nullptr) {
+      actor_to_rank_map_.insert({actor, rank});
+    }
+  }
 }
 
 int Group::rank(int index)
@@ -66,9 +67,22 @@ int Group::rank(int index)
     rank = index_to_rank_map_[index];
   else
     rank = MPI_UNDEFINED;
+
   return rank;
 }
 
+simgrid::s4u::ActorPtr Group::actor(int rank) {
+  if (0 <= rank && rank < size_)
+    return rank_to_actor_map_[rank];
+  else
+    return nullptr;
+}
+
+int Group::rank(const simgrid::s4u::ActorPtr actor) {
+  auto iterator = actor_to_rank_map_.find(actor);
+  return (iterator == actor_to_rank_map_.end()) ? MPI_UNDEFINED : (*iterator).second;
+}
+
 void Group::ref()
 {
   refcount_++;
@@ -96,8 +110,8 @@ int Group::compare(MPI_Group group2)
     result = MPI_UNEQUAL;
   } else {
     for (int i = 0; i < size_; i++) {
-      int index = this->index(i);
-      int rank = group2->rank(index);
+      ActorPtr actor = this->actor(i);
+      int rank = group2->rank(actor);
       if (rank == MPI_UNDEFINED) {
         result = MPI_UNEQUAL;
         break;
@@ -113,7 +127,6 @@ int Group::compare(MPI_Group group2)
 int Group::incl(int n, int* ranks, MPI_Group* newgroup)
 {
   int i=0;
-  int index=0;
   if (n == 0) {
     *newgroup = MPI_GROUP_EMPTY;
   } else if (n == size_) {
@@ -123,8 +136,8 @@ int Group::incl(int n, int* ranks, MPI_Group* newgroup)
   } else {
     *newgroup = new Group(n);
     for (i = 0; i < n; i++) {
-      index = this->index(ranks[i]);
-      (*newgroup)->set_mapping(index, i);
+      ActorPtr actor = this->actor(ranks[i]);
+      (*newgroup)->set_mapping(actor, i);
     }
   }
   return MPI_SUCCESS;
@@ -135,8 +148,8 @@ int Group::group_union(MPI_Group group2, MPI_Group* newgroup)
   int size1 = size_;
   int size2 = group2->size();
   for (int i = 0; i < size2; i++) {
-    int proc2 = group2->index(i);
-    int proc1 = this->rank(proc2);
+    ActorPtr actor = group2->actor(i);
+    int proc1 = this->rank(actor);
     if (proc1 == MPI_UNDEFINED) {
       size1++;
     }
@@ -147,12 +160,12 @@ int Group::group_union(MPI_Group group2, MPI_Group* newgroup)
     *newgroup = new  Group(size1);
     size2 = this->size();
     for (int i = 0; i < size2; i++) {
-      int proc1 = this->index(i);
-      (*newgroup)->set_mapping(proc1, i);
+      ActorPtr actor1 = this->actor(i);
+      (*newgroup)->set_mapping(actor1, i);
     }
     for (int i = size2; i < size1; i++) {
-      int proc2 = group2->index(i - size2);
-      (*newgroup)->set_mapping(proc2, i);
+      ActorPtr actor = group2->actor(i - size2);
+      (*newgroup)->set_mapping(actor, i);
     }
   }
   return MPI_SUCCESS;
@@ -162,8 +175,8 @@ int Group::intersection(MPI_Group group2, MPI_Group* newgroup)
 {
   int size2 = group2->size();
   for (int i = 0; i < size2; i++) {
-    int proc2 = group2->index(i);
-    int proc1 = this->rank(proc2);
+    ActorPtr actor = group2->actor(i);
+    int proc1 = this->rank(actor);
     if (proc1 == MPI_UNDEFINED) {
       size2--;
     }
@@ -174,10 +187,10 @@ int Group::intersection(MPI_Group group2, MPI_Group* newgroup)
     *newgroup = new  Group(size2);
     int j=0;
     for (int i = 0; i < group2->size(); i++) {
-      int proc2 = group2->index(i);
-      int proc1 = this->rank(proc2);
+      ActorPtr actor = group2->actor(i);
+      int proc1 = this->rank(actor);
       if (proc1 != MPI_UNDEFINED) {
-        (*newgroup)->set_mapping(proc2, j);
+        (*newgroup)->set_mapping(actor, j);
         j++;
       }
     }
@@ -190,8 +203,8 @@ int Group::difference(MPI_Group group2, MPI_Group* newgroup)
   int newsize = size_;
   int size2 = size_;
   for (int i = 0; i < size2; i++) {
-    int proc1 = this->index(i);
-    int proc2 = group2->rank(proc1);
+    ActorPtr actor = this->actor(i);
+    int proc2 = group2->rank(actor);
     if (proc2 != MPI_UNDEFINED) {
       newsize--;
     }
@@ -201,10 +214,10 @@ int Group::difference(MPI_Group group2, MPI_Group* newgroup)
   } else {
     *newgroup = new  Group(newsize);
     for (int i = 0; i < size2; i++) {
-      int proc1 = this->index(i);
-      int proc2 = group2->rank(proc1);
+      ActorPtr actor = this->actor(i);
+      int proc2 = group2->rank(actor);
       if (proc2 == MPI_UNDEFINED) {
-        (*newgroup)->set_mapping(proc1, i);
+        (*newgroup)->set_mapping(actor, i);
       }
     }
   }
@@ -223,8 +236,8 @@ int Group::excl(int n, int *ranks, MPI_Group * newgroup){
   int j = 0;
   for (int i = 0; i < oldsize; i++) {
     if(to_exclude[i]==0){
-      int index = this->index(i);
-      (*newgroup)->set_mapping(index, j);
+      ActorPtr actor = this->actor(i);
+      (*newgroup)->set_mapping(actor, j);
       j++;
     }
   }
@@ -262,8 +275,8 @@ int Group::range_incl(int n, int ranges[][3], MPI_Group * newgroup){
     for (int rank = ranges[i][0];                    /* First */
          rank >= 0 && rank < size_; /* Last */
          ) {
-      int index = this->index(rank);
-      (*newgroup)->set_mapping(index, j);
+      ActorPtr actor = this->actor(rank);
+      (*newgroup)->set_mapping(actor, j);
       j++;
       if(rank == ranges[i][1]){/*already last ?*/
         break;
@@ -314,8 +327,8 @@ int Group::range_excl(int n, int ranges[][3], MPI_Group * newgroup){
         }
       }
       if(add==1){
-        int index = this->index(oldrank);
-        (*newgroup)->set_mapping(index, newrank);
+        ActorPtr actor = this->actor(oldrank);
+        (*newgroup)->set_mapping(actor, newrank);
         newrank++;
       }
       oldrank++;
index 57e5a6b..e0f5aed 100644 (file)
@@ -179,19 +179,19 @@ MPI_Request Request::send_init(void *buf, int count, MPI_Datatype datatype, int
 {
 
   return new Request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process()->index(),
-                          comm->group()->index(dst), tag, comm, PERSISTENT | SEND | PREPARED);
+                          comm->group()->actor(dst)->getPid()-1, tag, comm, PERSISTENT | SEND | PREPARED);
 }
 
 MPI_Request Request::ssend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
 {
   return new Request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process()->index(),
-                        comm->group()->index(dst), tag, comm, PERSISTENT | SSEND | SEND | PREPARED);
+                        comm->group()->actor(dst)->getPid()-1, tag, comm, PERSISTENT | SSEND | SEND | PREPARED);
 }
 
 MPI_Request Request::isend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
 {
   return new Request(buf==MPI_BOTTOM ? nullptr : buf , count, datatype, smpi_process()->index(),
-                          comm->group()->index(dst), tag,comm, PERSISTENT | ISEND | SEND | PREPARED);
+                          comm->group()->actor(dst)->getPid()-1, tag,comm, PERSISTENT | ISEND | SEND | PREPARED);
 }
 
 
@@ -213,7 +213,7 @@ MPI_Request Request::rma_send_init(void *buf, int count, MPI_Datatype datatype,
 MPI_Request Request::recv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm)
 {
   return new Request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype,
-                          src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->index(src),
+                          src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(src)->getPid()-1,
                           smpi_process()->index(), tag, comm, PERSISTENT | RECV | PREPARED);
 }
 
@@ -235,7 +235,7 @@ MPI_Request Request::rma_recv_init(void *buf, int count, MPI_Datatype datatype,
 MPI_Request Request::irecv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm)
 {
   return new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype,
-                     src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->index(src), smpi_process()->index(), tag,
+                     src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(src)->getPid()-1, smpi_process()->index(), tag,
                      comm, PERSISTENT | RECV | PREPARED);
 }
 
@@ -243,7 +243,7 @@ MPI_Request Request::isend(void *buf, int count, MPI_Datatype datatype, int dst,
 {
   MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */
   request             = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process()->index(),
-                        comm->group()->index(dst), tag, comm, NON_PERSISTENT | ISEND | SEND);
+                        comm->group()->actor(dst)->getPid()-1, tag, comm, NON_PERSISTENT | ISEND | SEND);
   request->start();
   return request;
 }
@@ -252,7 +252,7 @@ MPI_Request Request::issend(void *buf, int count, MPI_Datatype datatype, int dst
 {
   MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */
   request             = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process()->index(),
-                        comm->group()->index(dst), tag, comm, NON_PERSISTENT | ISEND | SSEND | SEND);
+                        comm->group()->actor(dst)->getPid()-1, tag, comm, NON_PERSISTENT | ISEND | SSEND | SEND);
   request->start();
   return request;
 }
@@ -262,7 +262,7 @@ MPI_Request Request::irecv(void *buf, int count, MPI_Datatype datatype, int src,
 {
   MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */
   request             = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype,
-                        src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->index(src), smpi_process()->index(),
+                        src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(src)->getPid()-1, smpi_process()->index(),
                         tag, comm, NON_PERSISTENT | RECV);
   request->start();
   return request;
@@ -280,7 +280,7 @@ void Request::send(void *buf, int count, MPI_Datatype datatype, int dst, int tag
 {
   MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */
   request             = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process()->index(),
-                        comm->group()->index(dst), tag, comm, NON_PERSISTENT | SEND);
+                        comm->group()->actor(dst)->getPid()-1, tag, comm, NON_PERSISTENT | SEND);
 
   request->start();
   wait(&request, MPI_STATUS_IGNORE);
@@ -291,7 +291,7 @@ void Request::ssend(void *buf, int count, MPI_Datatype datatype, int dst, int ta
 {
   MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */
   request             = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process()->index(),
-                        comm->group()->index(dst), tag, comm, NON_PERSISTENT | SSEND | SEND);
+                        comm->group()->actor(dst)->getPid()-1, tag, comm, NON_PERSISTENT | SSEND | SEND);
 
   request->start();
   wait(&request,MPI_STATUS_IGNORE);
@@ -304,8 +304,8 @@ void Request::sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,int d
 {
   MPI_Request requests[2];
   MPI_Status stats[2];
-  int myid=smpi_process()->index();
-  if ((comm->group()->index(dst) == myid) && (comm->group()->index(src) == myid)){
+  unsigned int myid=smpi_process()->index();
+  if ((comm->group()->actor(dst)->getPid()-1 == myid) && (comm->group()->actor(src)->getPid()-1 == myid)){
       Datatype::copy(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype);
       return;
   }
@@ -628,7 +628,7 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status*
   double speed        = simgrid::s4u::Actor::self()->getHost()->getSpeed();
   double maxrate = xbt_cfg_get_double("smpi/iprobe-cpu-usage");
   MPI_Request request = new Request(nullptr, 0, MPI_CHAR, source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE :
-                 comm->group()->index(source), comm->rank(), tag, comm, PERSISTENT | RECV);
+                 comm->group()->actor(source)->getPid()-1, comm->rank(), tag, comm, PERSISTENT | RECV);
   if (smpi_iprobe_sleep > 0) {
     smx_activity_t iprobe_sleep = simcall_execution_start(
         "iprobe", /* flops to executek*/ nsleeps * smpi_iprobe_sleep * speed * maxrate, /* priority */ 1.0,
index 04b5179..be218ba 100644 (file)
@@ -70,7 +70,7 @@ Topo_Cart::Topo_Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], in
     oldGroup = comm_old->group();
     newGroup = new  Group(newSize);
     for (int i = 0 ; i < newSize ; i++) {
-      newGroup->set_mapping(oldGroup->index(i), i);
+      newGroup->set_mapping(oldGroup->actor(i), i);
     }
 
     nnodes_ = newSize;
index 33b7f66..0827674 100644 (file)
@@ -211,11 +211,11 @@ int Win::put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
   if(target_rank != comm_->rank()){
     //prepare send_request
     MPI_Request sreq = Request::rma_send_init(origin_addr, origin_count, origin_datatype, smpi_process()->index(),
-        comm_->group()->index(target_rank), SMPI_RMA_TAG+1, comm_, MPI_OP_NULL);
+        comm_->group()->actor(target_rank)->getPid()-1, SMPI_RMA_TAG+1, comm_, MPI_OP_NULL);
 
     //prepare receiver request
     MPI_Request rreq = Request::rma_recv_init(recv_addr, target_count, target_datatype, smpi_process()->index(),
-        comm_->group()->index(target_rank), SMPI_RMA_TAG+1, recv_win->comm_, MPI_OP_NULL);
+        comm_->group()->actor(target_rank)->getPid()-1, SMPI_RMA_TAG+1, recv_win->comm_, MPI_OP_NULL);
 
     //start send
     sreq->start();
@@ -268,12 +268,12 @@ int Win::get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
   if(target_rank != comm_->rank()){
     //prepare send_request
     MPI_Request sreq = Request::rma_send_init(send_addr, target_count, target_datatype,
-        comm_->group()->index(target_rank), smpi_process()->index(), SMPI_RMA_TAG+2, send_win->comm_,
+        comm_->group()->actor(target_rank)->getPid()-1, smpi_process()->index(), SMPI_RMA_TAG+2, send_win->comm_,
         MPI_OP_NULL);
 
     //prepare receiver request
     MPI_Request rreq = Request::rma_recv_init(origin_addr, origin_count, origin_datatype,
-        comm_->group()->index(target_rank), smpi_process()->index(), SMPI_RMA_TAG+2, comm_,
+        comm_->group()->actor(target_rank)->getPid()-1, smpi_process()->index(), SMPI_RMA_TAG+2, comm_,
         MPI_OP_NULL);
 
     //start the send, with another process than us as sender.
@@ -331,11 +331,11 @@ int Win::accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da
     //prepare send_request
 
     MPI_Request sreq = Request::rma_send_init(origin_addr, origin_count, origin_datatype,
-        smpi_process()->index(), comm_->group()->index(target_rank), SMPI_RMA_TAG-3-count_, comm_, op);
+        smpi_process()->index(), comm_->group()->actor(target_rank)->getPid()-1, SMPI_RMA_TAG-3-count_, comm_, op);
 
     //prepare receiver request
     MPI_Request rreq = Request::rma_recv_init(recv_addr, target_count, target_datatype,
-        smpi_process()->index(), comm_->group()->index(target_rank), SMPI_RMA_TAG-3-count_, recv_win->comm_, op);
+        smpi_process()->index(), comm_->group()->actor(target_rank)->getPid()-1, SMPI_RMA_TAG-3-count_, recv_win->comm_, op);
 
     count_++;
 
@@ -449,7 +449,7 @@ int Win::start(MPI_Group group, int assert){
 
   XBT_DEBUG("Entering MPI_Win_Start");
     while (j != size) {
-      int src = group->index(j);
+      int src = group->actor(j)->getPid()-1;
       if (src != smpi_process()->index() && src != MPI_UNDEFINED) {
         reqs[i] = Request::irecv_init(nullptr, 0, MPI_CHAR, src, SMPI_RMA_TAG + 4, MPI_COMM_WORLD);
         i++;
@@ -479,7 +479,7 @@ int Win::post(MPI_Group group, int assert){
 
   XBT_DEBUG("Entering MPI_Win_Post");
   while(j!=size){
-    int dst=group->index(j);
+    int dst=group->actor(j)->getPid()-1;
     if(dst!=smpi_process()->index() && dst!=MPI_UNDEFINED){
       reqs[i]=Request::send_init(nullptr, 0, MPI_CHAR, dst, SMPI_RMA_TAG+4, MPI_COMM_WORLD);
       i++;
@@ -512,7 +512,7 @@ int Win::complete(){
   MPI_Request* reqs = xbt_new0(MPI_Request, size);
 
   while(j!=size){
-    int dst=group_->index(j);
+    int dst=group_->actor(j)->getPid()-1;
     if(dst!=smpi_process()->index() && dst!=MPI_UNDEFINED){
       reqs[i]=Request::send_init(nullptr, 0, MPI_CHAR, dst, SMPI_RMA_TAG+5, MPI_COMM_WORLD);
       i++;
@@ -546,7 +546,7 @@ int Win::wait(){
   MPI_Request* reqs = xbt_new0(MPI_Request, size);
 
   while(j!=size){
-    int src=group_->index(j);
+    int src=group_->actor(j)->getPid()-1;
     if(src!=smpi_process()->index() && src!=MPI_UNDEFINED){
       reqs[i]=Request::irecv_init(nullptr, 0, MPI_CHAR, src,SMPI_RMA_TAG+5, MPI_COMM_WORLD);
       i++;