From 48e24b849b73cfd56e92cdfac43b16eb06067b3a Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Fri, 6 Jan 2017 14:38:23 +0100 Subject: [PATCH] [SMPI] Use SmpiHost::orecv(). I moved the computation of the orecv configs to the SmpiHost class. It's currently a crude implementation and does not (yet) allow for a per-host configuration, but this is planned and outlined in the code. For that, all we need is an option to parse and set orecv values on a per-node basis. (See the orecv_ property.) --- src/smpi/SmpiHost.cpp | 12 +++++------- src/smpi/SmpiHost.hpp | 1 + src/smpi/smpi_deployment.cpp | 15 +++++++++++++++ src/smpi/smpi_global.cpp | 5 +++++ src/smpi/smpi_request.cpp | 3 ++- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/smpi/SmpiHost.cpp b/src/smpi/SmpiHost.cpp index 962ea77cb6..cc1ec29b3f 100644 --- a/src/smpi/SmpiHost.cpp +++ b/src/smpi/SmpiHost.cpp @@ -1,7 +1,6 @@ #include "smpi/smpi_utils.hpp" #include "src/smpi/SmpiHost.hpp" -#include "src/surf/virtual_machine.hpp" - +#include #include #include @@ -15,11 +14,11 @@ simgrid::xbt::Extension SmpiHost::EXTENSION_ID; double SmpiHost::orecv(size_t size) { if (orecv_parsed_values.empty()) { - if (orecv_.empty()) { - std::string test = xbt_cfg_get_string("smpi/or"); + if (orecv_.empty()) { /* This is currently always true since orecv_ is not really used yet. */ + /* Get global value */ orecv_parsed_values = parse_factor(xbt_cfg_get_string("smpi/or")); } - else + else /* Can currently not be reached, see above */ orecv_parsed_values = parse_factor(orecv_.c_str()); } @@ -67,8 +66,7 @@ static void onCreation(simgrid::s4u::Host& host) { static void onHostDestruction(simgrid::s4u::Host& host) { // Ignore virtual machines - simgrid::surf::HostImpl* surf_host = host.extension(); - if (dynamic_cast(surf_host)) + if (dynamic_cast(&host)) return; } diff --git a/src/smpi/SmpiHost.hpp b/src/smpi/SmpiHost.hpp index 1d6daa5cad..fe810d3747 100644 --- a/src/smpi/SmpiHost.hpp +++ b/src/smpi/SmpiHost.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include diff --git a/src/smpi/smpi_deployment.cpp b/src/smpi/smpi_deployment.cpp index f6c169c70c..e5d4c38d4a 100644 --- a/src/smpi/smpi_deployment.cpp +++ b/src/smpi/smpi_deployment.cpp @@ -6,6 +6,7 @@ #include "private.h" #include "simgrid/msg.h" /* barrier */ +#include "src/smpi/SmpiHost.hpp" #include "xbt/dict.h" #include "xbt/log.h" #include "xbt/sysdep.h" @@ -37,6 +38,19 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_ s_smpi_mpi_instance_t* instance = (s_smpi_mpi_instance_t*)xbt_malloc(sizeof(s_smpi_mpi_instance_t)); + static int already_called = 0; + if (!already_called) { + already_called = 1; + xbt_dynar_t hosts = MSG_hosts_as_dynar(); + unsigned int cursor; + void* h; + xbt_dynar_foreach(hosts, cursor, h) { + simgrid::s4u::Host* host = static_cast(h); + host->extension_set(new simgrid::smpi::SmpiHost(host)); + } + xbt_dynar_free(&hosts); + } + instance->name = name; instance->size = num_processes; instance->present_processes = 0; @@ -50,6 +64,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_ smpi_instances = xbt_dict_new_homogeneous(xbt_free_f); } + xbt_dict_set(smpi_instances, name, (void*)instance, nullptr); } diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 0da7f66a81..c24494a72a 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -18,6 +18,7 @@ #include "src/mc/mc_replay.h" #include "src/msg/msg_private.h" #include "src/simix/smx_private.h" +#include "src/smpi/SmpiHost.hpp" #include "surf/surf.h" #include "xbt/replay.hpp" #include @@ -510,6 +511,10 @@ int smpi_main(const char* executable, int argc, char *argv[]) smpi_init_options(); + simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) { + host.extension_set(new simgrid::smpi::SmpiHost(&host)); + }); + // parse the platform file: get the host list SIMIX_create_environment(argv[1]); SIMIX_comm_set_copy_data_callback(smpi_comm_copy_buffer_callback); diff --git a/src/smpi/smpi_request.cpp b/src/smpi/smpi_request.cpp index 2ff10a2790..f7ca04bc9f 100644 --- a/src/smpi/smpi_request.cpp +++ b/src/smpi/smpi_request.cpp @@ -11,6 +11,7 @@ #include "src/simix/smx_private.h" #include "simgrid/sg_config.h" #include "smpi/smpi_utils.hpp" +#include "src/smpi/SmpiHost.hpp" #include #include "src/kernel/activity/SynchroComm.hpp" @@ -795,7 +796,7 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status) } if(req->detached_sender_ != nullptr){ //integrate pseudo-timing for buffering of small messages, do not bother to execute the simcall if 0 - double sleeptime = smpi_or(req->real_size_); + double sleeptime = simgrid::s4u::Actor::self()->host()->extension()->orecv(req->real_size()); if(sleeptime > 0.0){ simcall_process_sleep(sleeptime); XBT_DEBUG("receiving size of %zu : sleep %f ", req->real_size_, sleeptime); -- 2.20.1