From 5af96acb7bd3444ad821e8ffba513d4fd0e4a01f Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 26 Sep 2019 09:51:52 +0200 Subject: [PATCH] There's no more need for ActorPtr there. --- src/smpi/bindings/smpi_pmpi_group.cpp | 2 +- src/smpi/include/private.hpp | 3 +-- src/smpi/include/smpi_group.hpp | 6 ++--- src/smpi/internals/smpi_actor.cpp | 2 +- src/smpi/internals/smpi_deployment.cpp | 2 +- src/smpi/mpi/smpi_comm.cpp | 12 +++++----- src/smpi/mpi/smpi_group.cpp | 33 +++++++++++++------------- 7 files changed, 29 insertions(+), 31 deletions(-) diff --git a/src/smpi/bindings/smpi_pmpi_group.cpp b/src/smpi/bindings/smpi_pmpi_group.cpp index 83b08ed2d7..e038ca7ab1 100644 --- a/src/smpi/bindings/smpi_pmpi_group.cpp +++ b/src/smpi/bindings/smpi_pmpi_group.cpp @@ -59,7 +59,7 @@ int PMPI_Group_translate_ranks(MPI_Group group1, int n, const int *ranks1, MPI_G if(ranks1[i]==MPI_PROC_NULL){ ranks2[i]=MPI_PROC_NULL; }else{ - simgrid::s4u::ActorPtr actor = group1->actor(ranks1[i]); + simgrid::s4u::Actor* actor = group1->actor(ranks1[i]); ranks2[i] = group2->rank(actor); } } diff --git a/src/smpi/include/private.hpp b/src/smpi/include/private.hpp index b3bec46d11..01e57274a7 100644 --- a/src/smpi/include/private.hpp +++ b/src/smpi/include/private.hpp @@ -76,8 +76,7 @@ XBT_PRIVATE simgrid::smpi::ActorExt* smpi_process(); XBT_PRIVATE simgrid::smpi::ActorExt* smpi_process_remote(simgrid::s4u::ActorPtr actor); XBT_PRIVATE int smpi_get_universe_size(); -XBT_PRIVATE void smpi_deployment_register_process(const std::string& instance_id, int rank, - simgrid::s4u::ActorPtr actor); +XBT_PRIVATE void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::Actor* actor); XBT_PRIVATE void smpi_deployment_unregister_process(const std::string& instance_id); XBT_PRIVATE MPI_Comm* smpi_deployment_comm_world(const std::string& instance_id); diff --git a/src/smpi/include/smpi_group.hpp b/src/smpi/include/smpi_group.hpp index 96078433a8..c0fa3fe1f1 100644 --- a/src/smpi/include/smpi_group.hpp +++ b/src/smpi/include/smpi_group.hpp @@ -30,10 +30,10 @@ public: explicit Group(int size) : size_(size), rank_to_actor_map_(size, nullptr), index_to_rank_map_(size, MPI_UNDEFINED) {} explicit Group(Group* origin); - void set_mapping(s4u::ActorPtr actor, int rank); + void set_mapping(s4u::Actor* actor, int rank); int rank(int index); - s4u::ActorPtr actor(int rank); - int rank(s4u::ActorPtr process); + s4u::Actor* actor(int rank); + int rank(s4u::Actor* process); void ref(); static void unref(MPI_Group group); int size() { return size_; } diff --git a/src/smpi/internals/smpi_actor.cpp b/src/smpi/internals/smpi_actor.cpp index 8e6f16cd64..eae424428b 100644 --- a/src/smpi/internals/smpi_actor.cpp +++ b/src/smpi/internals/smpi_actor.cpp @@ -213,7 +213,7 @@ void ActorExt::init() xbt_assert(smpi_get_universe_size() != 0, "SimGrid was not initialized properly before entering MPI_Init. " "Aborting, please check compilation process and use smpirun."); - simgrid::s4u::ActorPtr self = simgrid::s4u::Actor::self(); + simgrid::s4u::Actor* self = simgrid::s4u::Actor::self(); // cheinrich: I'm not sure what the impact of the SMPI_switch_data_segment on this call is. I moved // this up here so that I can set the privatized region before the switch. ActorExt* ext = smpi_process(); diff --git a/src/smpi/internals/smpi_deployment.cpp b/src/smpi/internals/smpi_deployment.cpp index 6aa940aa70..5cf91ebc73 100644 --- a/src/smpi/internals/smpi_deployment.cpp +++ b/src/smpi/internals/smpi_deployment.cpp @@ -65,7 +65,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_ smpi_instances.insert(std::pair(name, instance)); } -void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::ActorPtr actor) +void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::Actor* actor) { Instance& instance = smpi_instances.at(instance_id); instance.comm_world_->group()->set_mapping(actor, rank); diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index 8571f381b4..ed24882e91 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -275,7 +275,7 @@ MPI_Comm Comm::split(int color, int key) group_root = group_out; /* Save root's group */ } for (unsigned j = 0; j < rankmap.size(); j++) { - s4u::ActorPtr actor = group->actor(rankmap[j].second); + s4u::Actor* actor = group->actor(rankmap[j].second); group_out->set_mapping(actor, j); } MPI_Request* requests = xbt_new(MPI_Request, rankmap.size()); @@ -345,7 +345,7 @@ MPI_Comm Comm::find_intra_comm(int * leader){ int min_index = INT_MAX; // the minimum index will be the leader for (auto& actor : process_list) { int index = actor.get_pid(); - if (this->group()->rank(actor.iface()) != MPI_UNDEFINED) { // Is this process in the current group? + if (this->group()->rank(actor.ciface()) != MPI_UNDEFINED) { // Is this process in the current group? intra_comm_size++; if (index < min_index) min_index = index; @@ -355,8 +355,8 @@ MPI_Comm Comm::find_intra_comm(int * leader){ MPI_Group group_intra = new Group(intra_comm_size); int i = 0; for (auto& actor : process_list) { - if (this->group()->rank(actor.iface()) != MPI_UNDEFINED) { - group_intra->set_mapping(actor.iface(), i); + if (this->group()->rank(actor.ciface()) != MPI_UNDEFINED) { + group_intra->set_mapping(actor.ciface(), i); i++; } } @@ -426,7 +426,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(s4u::Actor::by_pid(leader_list[i]), i); + leaders_group->set_mapping(s4u::Actor::by_pid(leader_list[i]).get(), i); leader_comm = new Comm(leaders_group, nullptr,1); this->set_leaders_comm(leader_comm); this->set_intra_comm(comm_intra); @@ -434,7 +434,7 @@ void Comm::init_smp(){ // create intracommunicator }else{ for (i=0; i< leader_group_size;i++) - leaders_group->set_mapping(s4u::Actor::by_pid(leader_list[i]), i); + leaders_group->set_mapping(s4u::Actor::by_pid(leader_list[i]).get(), i); if(this->get_leaders_comm()==MPI_COMM_NULL){ leader_comm = new Comm(leaders_group, nullptr,1); diff --git a/src/smpi/mpi/smpi_group.cpp b/src/smpi/mpi/smpi_group.cpp index eea8e737a9..cbd973a064 100644 --- a/src/smpi/mpi/smpi_group.cpp +++ b/src/smpi/mpi/smpi_group.cpp @@ -28,9 +28,8 @@ Group::Group(Group* origin) } } -void Group::set_mapping(s4u::ActorPtr actor_ptr, int rank) +void Group::set_mapping(s4u::Actor* actor, int rank) { - s4u::Actor* actor = actor_ptr.get(); if (0 <= rank && rank < size_) { int index = actor->get_pid(); if (index != MPI_UNDEFINED) { @@ -55,7 +54,7 @@ int Group::rank(int index) return rank; } -s4u::ActorPtr Group::actor(int rank) +s4u::Actor* Group::actor(int rank) { if (0 <= rank && rank < size_) return rank_to_actor_map_[rank]; @@ -63,9 +62,9 @@ s4u::ActorPtr Group::actor(int rank) return nullptr; } -int Group::rank(s4u::ActorPtr actor) +int Group::rank(s4u::Actor* actor) { - auto iterator = actor_to_rank_map_.find(actor.get()); + auto iterator = actor_to_rank_map_.find(actor); return (iterator == actor_to_rank_map_.end()) ? MPI_UNDEFINED : (*iterator).second; } @@ -91,7 +90,7 @@ int Group::compare(MPI_Group group2) result = MPI_UNEQUAL; } else { for (int i = 0; i < size_; i++) { - s4u::ActorPtr actor = this->actor(i); + s4u::Actor* actor = this->actor(i); int rank = group2->rank(actor); if (rank == MPI_UNDEFINED) { result = MPI_UNEQUAL; @@ -117,7 +116,7 @@ int Group::incl(int n, const int* ranks, MPI_Group* newgroup) } else { *newgroup = new Group(n); for (i = 0; i < n; i++) { - s4u::ActorPtr actor = this->actor(ranks[i]); // ranks[] was passed as a param! + s4u::Actor* actor = this->actor(ranks[i]); // ranks[] was passed as a param! (*newgroup)->set_mapping(actor, i); } } @@ -129,7 +128,7 @@ int Group::group_union(MPI_Group group2, MPI_Group* newgroup) int size1 = size_; int size2 = group2->size(); for (int i = 0; i < size2; i++) { - s4u::ActorPtr actor = group2->actor(i); + s4u::Actor* actor = group2->actor(i); int proc1 = this->rank(actor); if (proc1 == MPI_UNDEFINED) { size1++; @@ -141,11 +140,11 @@ int Group::group_union(MPI_Group group2, MPI_Group* newgroup) *newgroup = new Group(size1); size2 = this->size(); for (int i = 0; i < size2; i++) { - s4u::ActorPtr actor1 = this->actor(i); + s4u::Actor* actor1 = this->actor(i); (*newgroup)->set_mapping(actor1, i); } for (int i = size2; i < size1; i++) { - s4u::ActorPtr actor = group2->actor(i - size2); + s4u::Actor* actor = group2->actor(i - size2); (*newgroup)->set_mapping(actor, i); } } @@ -156,7 +155,7 @@ int Group::intersection(MPI_Group group2, MPI_Group* newgroup) { int size2 = group2->size(); for (int i = 0; i < size2; i++) { - s4u::ActorPtr actor = group2->actor(i); + s4u::Actor* actor = group2->actor(i); int proc1 = this->rank(actor); if (proc1 == MPI_UNDEFINED) { size2--; @@ -168,7 +167,7 @@ int Group::intersection(MPI_Group group2, MPI_Group* newgroup) *newgroup = new Group(size2); int j=0; for (int i = 0; i < group2->size(); i++) { - s4u::ActorPtr actor = group2->actor(i); + s4u::Actor* actor = group2->actor(i); int proc1 = this->rank(actor); if (proc1 != MPI_UNDEFINED) { (*newgroup)->set_mapping(actor, j); @@ -184,7 +183,7 @@ int Group::difference(MPI_Group group2, MPI_Group* newgroup) int newsize = size_; int size2 = size_; for (int i = 0; i < size2; i++) { - s4u::ActorPtr actor = this->actor(i); + s4u::Actor* actor = this->actor(i); int proc2 = group2->rank(actor); if (proc2 != MPI_UNDEFINED) { newsize--; @@ -195,7 +194,7 @@ int Group::difference(MPI_Group group2, MPI_Group* newgroup) } else { *newgroup = new Group(newsize); for (int i = 0; i < size2; i++) { - s4u::ActorPtr actor = this->actor(i); + s4u::Actor* actor = this->actor(i); int proc2 = group2->rank(actor); if (proc2 == MPI_UNDEFINED) { (*newgroup)->set_mapping(actor, i); @@ -217,7 +216,7 @@ int Group::excl(int n, const int *ranks, MPI_Group * newgroup){ int j = 0; for (int i = 0; i < oldsize; i++) { if(to_exclude[i]==0){ - s4u::ActorPtr actor = this->actor(i); + s4u::Actor* actor = this->actor(i); (*newgroup)->set_mapping(actor, j); j++; } @@ -256,7 +255,7 @@ int Group::range_incl(int n, int ranges[][3], MPI_Group * newgroup){ for (int rank = ranges[i][0]; /* First */ rank >= 0 && rank < size_; /* Last */ ) { - s4u::ActorPtr actor = this->actor(rank); + s4u::Actor* actor = this->actor(rank); (*newgroup)->set_mapping(actor, j); j++; if(rank == ranges[i][1]){/*already last ?*/ @@ -308,7 +307,7 @@ int Group::range_excl(int n, int ranges[][3], MPI_Group * newgroup){ } } if(add==1){ - s4u::ActorPtr actor = this->actor(oldrank); + s4u::Actor* actor = this->actor(oldrank); (*newgroup)->set_mapping(actor, newrank); newrank++; } -- 2.20.1