X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dbb4b9d8b72ec01fe1748a7eb6b32222ffe3ece5..8344f32ee2339f2b53a6e79ac0e9aa3a93384f58:/src/smpi/internals/smpi_deployment.cpp diff --git a/src/smpi/internals/smpi_deployment.cpp b/src/smpi/internals/smpi_deployment.cpp index 436a39ab3d..9c9d7c8bdf 100644 --- a/src/smpi/internals/smpi_deployment.cpp +++ b/src/smpi/internals/smpi_deployment.cpp @@ -15,15 +15,12 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi); namespace simgrid::smpi::app { -static int universe_size = 0; - class Instance { public: explicit Instance(int max_no_processes) : size_(max_no_processes) { auto* group = new simgrid::smpi::Group(size_); comm_world_ = new simgrid::smpi::Comm(group, nullptr, false, -1); - universe_size += max_no_processes; bar_ = s4u::Barrier::create(size_); } s4u::BarrierPtr bar_; @@ -57,10 +54,10 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_ void SMPI_app_instance_start(const char* name, const std::function& code, std::vector const& hosts) { - xbt_assert(hosts.size() > 0, "Cannot start a SMPI instance on 0 hosts"); - xbt_assert(smpi_instances.find(name) == smpi_instances.end(), - "Cannot start two MPI applications of the same name '%s'", name); - smpi_instances.try_emplace(name, hosts.size()); + xbt_assert(not hosts.empty(), "Cannot start a SMPI instance on 0 hosts"); + + auto [_, inserted] = smpi_instances.try_emplace(name, hosts.size()); + xbt_assert(inserted, "Cannot start two MPI applications of the same name '%s'", name); int rank = 0; for (auto* host : hosts) { @@ -75,6 +72,17 @@ void SMPI_app_instance_start(const char* name, const std::function& code rank++; } } +void SMPI_app_instance_join(const std::string& instance_id) +{ + std::vector actors = + simgrid::s4u::Engine::get_instance()->get_filtered_actors([instance_id](simgrid::s4u::ActorPtr act) { + auto* actor_instance = act->get_property("instance_id"); + return actor_instance != nullptr && strcmp(actor_instance, instance_id.c_str()) == 0; + }); + + for (auto& act : actors) + act->join(); +} void smpi_deployment_register_process(const std::string& instance_id, int rank, const simgrid::s4u::Actor* actor) { @@ -113,11 +121,6 @@ void smpi_deployment_cleanup_instances(){ smpi_instances.clear(); } -int smpi_get_universe_size() -{ - return simgrid::smpi::app::universe_size; -} - /** @brief Auxiliary method to get list of hosts to deploy app */ static std::vector smpi_get_hosts(const simgrid::s4u::Engine* e, const std::string& hostfile) {