Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI] Use SmpiHost::orecv().
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Fri, 6 Jan 2017 13:38:23 +0000 (14:38 +0100)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Wed, 12 Apr 2017 09:53:18 +0000 (11:53 +0200)
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
src/smpi/SmpiHost.hpp
src/smpi/smpi_deployment.cpp
src/smpi/smpi_global.cpp
src/smpi/smpi_request.cpp

index 962ea77..cc1ec29 100644 (file)
@@ -1,7 +1,6 @@
 #include "smpi/smpi_utils.hpp"
 #include "src/smpi/SmpiHost.hpp"
 #include "smpi/smpi_utils.hpp"
 #include "src/smpi/SmpiHost.hpp"
-#include "src/surf/virtual_machine.hpp"
-
+#include <simgrid/s4u/VirtualMachine.hpp>
 #include <string>
 #include <vector>
 
 #include <string>
 #include <vector>
 
@@ -15,11 +14,11 @@ simgrid::xbt::Extension<simgrid::s4u::Host, SmpiHost> SmpiHost::EXTENSION_ID;
 double SmpiHost::orecv(size_t size)
 {
   if (orecv_parsed_values.empty()) {
 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"));
     }
       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());
   }
   
       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
 
 static void onHostDestruction(simgrid::s4u::Host& host) {
   // Ignore virtual machines
-  simgrid::surf::HostImpl* surf_host = host.extension<simgrid::surf::HostImpl>();
-  if (dynamic_cast<simgrid::surf::VirtualMachine*>(surf_host))
+  if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host))
     return;
 }
 
     return;
 }
 
index 1d6daa5..fe810d3 100644 (file)
@@ -6,6 +6,7 @@
 #include <simgrid/s4u/host.hpp>
 #include <string>
 #include <vector>
 #include <simgrid/s4u/host.hpp>
 #include <string>
 #include <vector>
+#include <xbt/config.hpp>
 #include <xbt/Extendable.hpp>
 
 
 #include <xbt/Extendable.hpp>
 
 
index f6c169c..e5d4c38 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "private.h"
 #include "simgrid/msg.h" /* barrier */
 
 #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"
 #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));
 
 
   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<simgrid::s4u::Host*>(h);
+      host->extension_set(new simgrid::smpi::SmpiHost(host));
+    }
+    xbt_dynar_free(&hosts);
+  }
+
   instance->name = name;
   instance->size = num_processes;
   instance->present_processes = 0;
   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);
   }
 
     smpi_instances = xbt_dict_new_homogeneous(xbt_free_f);
   }
 
+
   xbt_dict_set(smpi_instances, name, (void*)instance, nullptr);
 }
 
   xbt_dict_set(smpi_instances, name, (void*)instance, nullptr);
 }
 
index 0da7f66..c24494a 100644 (file)
@@ -18,6 +18,7 @@
 #include "src/mc/mc_replay.h"
 #include "src/msg/msg_private.h"
 #include "src/simix/smx_private.h"
 #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 <xbt/config.hpp>
 #include "surf/surf.h"
 #include "xbt/replay.hpp"
 #include <xbt/config.hpp>
@@ -510,6 +511,10 @@ int smpi_main(const char* executable, int argc, char *argv[])
 
   smpi_init_options();
 
 
   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);
   // parse the platform file: get the host list
   SIMIX_create_environment(argv[1]);
   SIMIX_comm_set_copy_data_callback(smpi_comm_copy_buffer_callback);
index 2ff10a2..f7ca04b 100644 (file)
@@ -11,6 +11,7 @@
 #include "src/simix/smx_private.h"
 #include "simgrid/sg_config.h"
 #include "smpi/smpi_utils.hpp"
 #include "src/simix/smx_private.h"
 #include "simgrid/sg_config.h"
 #include "smpi/smpi_utils.hpp"
+#include "src/smpi/SmpiHost.hpp"
 #include <simgrid/s4u/host.hpp>
 #include "src/kernel/activity/SynchroComm.hpp"
 
 #include <simgrid/s4u/host.hpp>
 #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
   }
   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<simgrid::smpi::SmpiHost>()->orecv(req->real_size());
     if(sleeptime > 0.0){
       simcall_process_sleep(sleeptime);
       XBT_DEBUG("receiving size of %zu : sleep %f ", req->real_size_, sleeptime);
     if(sleeptime > 0.0){
       simcall_process_sleep(sleeptime);
       XBT_DEBUG("receiving size of %zu : sleep %f ", req->real_size_, sleeptime);