From 3ccd03dc66b4383355886a51a7b2241ba10f6f40 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 20 Jul 2023 11:46:04 +0200 Subject: [PATCH] Introduce SMPI_app_instance_join() --- ChangeLog | 3 +++ .../masterworker_mailbox_smpi.cpp | 3 +++ examples/smpi/smpi_s4u_masterworker/s4u_smpi.tesh | 3 ++- include/smpi/smpi.h | 1 + src/smpi/internals/smpi_deployment.cpp | 11 +++++++++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3e54838c24..ffd935631b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ S4U: Also add a variant with s4u::Link, when you don't want to specify the directions on symmetric routes. +SMPI: + - New SMPI_app_instance_join(): wait for the completion of a started MPI instance + Python: - Make the host_load plugin available from Python. See examples/python/plugin-host-load diff --git a/examples/smpi/smpi_s4u_masterworker/masterworker_mailbox_smpi.cpp b/examples/smpi/smpi_s4u_masterworker/masterworker_mailbox_smpi.cpp index 0539a00a0b..d81d9fa2bd 100644 --- a/examples/smpi/smpi_s4u_masterworker/masterworker_mailbox_smpi.cpp +++ b/examples/smpi/smpi_s4u_masterworker/masterworker_mailbox_smpi.cpp @@ -127,7 +127,10 @@ int main(int argc, char* argv[]) SMPI_app_instance_start("alltoall_mpi", alltoall_mpi, {e.host_by_name_or_null("Ginette"), e.host_by_name_or_null("Bourassa"), e.host_by_name_or_null("Jupiter"), e.host_by_name_or_null("Fafard")}); + SMPI_app_instance_join("alltoall_mpi"); + XBT_INFO("This other alltoall_mpi instance terminated."); }); + e.run(); XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock()); diff --git a/examples/smpi/smpi_s4u_masterworker/s4u_smpi.tesh b/examples/smpi/smpi_s4u_masterworker/s4u_smpi.tesh index 00d5dc8d7a..ba6efdd22f 100644 --- a/examples/smpi/smpi_s4u_masterworker/s4u_smpi.tesh +++ b/examples/smpi/smpi_s4u_masterworker/s4u_smpi.tesh @@ -50,4 +50,5 @@ $ ./masterworker_mailbox_smpi ${srcdir:=.}/../../platforms/small_platform_with_r > [Ginette:alltoall_mpi#0:(11) 10.036773] [smpi_masterworkers/INFO] after alltoall 0 > [Bourassa:alltoall_mpi#1:(12) 10.046578] [smpi_masterworkers/INFO] after alltoall 1 > [Fafard:alltoall_mpi#3:(14) 10.046865] [smpi_masterworkers/INFO] after alltoall 3 -> [Jupiter:alltoall_mpi#2:(13) 10.046865] [smpi_masterworkers/INFO] after alltoall 2 \ No newline at end of file +> [Jupiter:alltoall_mpi#2:(13) 10.046865] [smpi_masterworkers/INFO] after alltoall 2 +> [Ginette:launcher:(10) 10.046865] [smpi_masterworkers/INFO] This other alltoall_mpi instance terminated. \ No newline at end of file diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index ad3140ca53..453a6ef0e8 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -1235,6 +1235,7 @@ SG_END_DECL #ifdef __cplusplus XBT_PUBLIC void SMPI_app_instance_start(const char* name, std::function const& code, std::vector const& hosts); +XBT_PUBLIC void SMPI_app_instance_join(const std::string& instance_id); /* This version without parameter is nice to use with SMPI_app_instance_start() */ XBT_PUBLIC void MPI_Init(); diff --git a/src/smpi/internals/smpi_deployment.cpp b/src/smpi/internals/smpi_deployment.cpp index e73865cc55..c39bbd5519 100644 --- a/src/smpi/internals/smpi_deployment.cpp +++ b/src/smpi/internals/smpi_deployment.cpp @@ -75,6 +75,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) { -- 2.20.1