Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New callback: simgrid::s4u::onPlatformCreated (right before the simulation start)
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 1 Feb 2017 19:02:02 +0000 (20:02 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 1 Feb 2017 19:17:02 +0000 (20:17 +0100)
ChangeLog
include/simgrid/s4u/engine.hpp
src/msg/msg_global.cpp
src/s4u/s4u_engine.cpp
src/simix/smx_global.cpp
src/surf/instr_routing.cpp
src/surf/network_ns3.cpp
src/surf/network_smpi.cpp
src/surf/sg_platf.cpp
src/surf/storage_n11.cpp
src/surf/xml/platf.hpp

index 62bfffb..4adcbf0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,10 @@ SimGrid (3.15) UNRELEASED; urgency=low
    it denotes, so use JniException that is a RuntimeException (not to
    be catched explicitely).
 
    it denotes, so use JniException that is a RuntimeException (not to
    be catched explicitely).
 
+ S4U
+ - New callbacks:
+   - simgrid::s4u::onPlatformCreated: right before the simulation starts
+
  -- target_date=March 20 2017 -- Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
 
 SimGrid (3.14.159) stable; urgency=low
  -- target_date=March 20 2017 -- Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
 
 SimGrid (3.14.159) stable; urgency=low
index 9bdbba9..25fe6e4 100644 (file)
@@ -104,6 +104,11 @@ public:
 private:
   static s4u::Engine *instance_;
 };
 private:
   static s4u::Engine *instance_;
 };
+
+/* Callback called when the platform is created (ie, the xml file parsed),
+ * right before the actual simulation starts.
+ */
+extern XBT_PRIVATE xbt::signal<void(void)> onPlatformCreated;
 }} // namespace simgrid::s4u
 
 #endif /* SIMGRID_S4U_ENGINE_HPP */
 }} // namespace simgrid::s4u
 
 #endif /* SIMGRID_S4U_ENGINE_HPP */
index f4dd8ab..79f02a4 100644 (file)
@@ -3,12 +3,12 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "simgrid/s4u/engine.hpp"
 #include "simgrid/s4u/host.hpp"
 
 #include "instr/instr_interface.h"
 #include "mc/mc.h"
 #include "src/msg/msg_private.h"
 #include "simgrid/s4u/host.hpp"
 
 #include "instr/instr_interface.h"
 #include "mc/mc.h"
 #include "src/msg/msg_private.h"
-#include "src/surf/xml/platf_private.hpp" // FIXME: KILLME by removing MSG_post_create_environment()
 
 XBT_LOG_NEW_CATEGORY(msg, "All MSG categories");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, "Logging specific to MSG (kernel)");
 
 XBT_LOG_NEW_CATEGORY(msg, "All MSG categories");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, "Logging specific to MSG (kernel)");
@@ -54,7 +54,7 @@ void MSG_init_nocheck(int *argc, char **argv) {
     SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
     SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
 
     SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
     SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
 
-    simgrid::surf::on_postparse.connect(MSG_post_create_environment);
+    simgrid::s4u::onPlatformCreated.connect(MSG_post_create_environment);
     simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
       MSG_host_create_(&host);
     });
     simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
       MSG_host_create_(&host);
     });
index 2980b68..b872ca4 100644 (file)
@@ -23,6 +23,7 @@ XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface");
 
 namespace simgrid {
 namespace s4u {
 
 namespace simgrid {
 namespace s4u {
+xbt::signal<void(void)> onPlatformCreated;
 
 Engine *Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
 
 
 Engine *Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
 
index 78512e6..a6e990c 100644 (file)
@@ -13,7 +13,8 @@
 
 #include <xbt/functional.hpp>
 
 
 #include <xbt/functional.hpp>
 
-#include <simgrid/s4u/host.hpp>
+#include "simgrid/s4u/engine.hpp"
+#include "simgrid/s4u/host.hpp"
 
 #include "src/surf/surf_interface.hpp"
 #include "src/surf/storage_interface.hpp"
 
 #include "src/surf/surf_interface.hpp"
 #include "src/surf/storage_interface.hpp"
@@ -228,7 +229,7 @@ void SIMIX_global_init(int *argc, char **argv)
 #endif
     /* register a function to be called by SURF after the environment creation */
     sg_platf_init();
 #endif
     /* register a function to be called by SURF after the environment creation */
     sg_platf_init();
-    simgrid::surf::on_postparse.connect(SIMIX_post_create_environment);
+    simgrid::s4u::onPlatformCreated.connect(SIMIX_post_create_environment);
     simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
       host.extension_set<simgrid::simix::Host>(new simgrid::simix::Host());
     });
     simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
       host.extension_set<simgrid::simix::Host>(new simgrid::simix::Host());
     });
@@ -428,7 +429,6 @@ void SIMIX_run()
   }
 
   double time = 0;
   }
 
   double time = 0;
-  smx_actor_t process;
 
   do {
     XBT_DEBUG("New Schedule Round; size(queue)=%lu", xbt_dynar_length(simix_global->process_to_run));
 
   do {
     XBT_DEBUG("New Schedule Round; size(queue)=%lu", xbt_dynar_length(simix_global->process_to_run));
@@ -500,6 +500,7 @@ void SIMIX_run()
        */
 
       unsigned int iter;
        */
 
       unsigned int iter;
+      smx_actor_t process;
       xbt_dynar_foreach(simix_global->process_that_ran, iter, process) {
         if (process->simcall.call != SIMCALL_NONE) {
           SIMIX_simcall_handle(&process->simcall, 0);
       xbt_dynar_foreach(simix_global->process_that_ran, iter, process) {
         if (process->simcall.call != SIMCALL_NONE) {
           SIMIX_simcall_handle(&process->simcall, 0);
index 5401f12..e443fe6 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "simgrid/s4u/engine.hpp"
 #include "simgrid/s4u/host.hpp"
 
 #include "simgrid/s4u/engine.hpp"
 #include "simgrid/s4u/host.hpp"
+
 #include "src/kernel/routing/NetZoneImpl.hpp"
 #include "src/surf/network_interface.hpp"
 #include "src/surf/xml/platf_private.hpp"
 #include "src/kernel/routing/NetZoneImpl.hpp"
 #include "src/surf/network_interface.hpp"
 #include "src/surf/xml/platf_private.hpp"
@@ -324,7 +325,7 @@ void instr_routing_define_callbacks ()
   //to create the rootContainer and the rootType properly
   if (!TRACE_needs_platform()) return;
   simgrid::surf::Link::onCreation.connect(instr_routing_parse_start_link);
   //to create the rootContainer and the rootType properly
   if (!TRACE_needs_platform()) return;
   simgrid::surf::Link::onCreation.connect(instr_routing_parse_start_link);
-  simgrid::surf::on_postparse.connect(instr_routing_parse_end_platform);
+  simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform);
 }
 
 /*
 }
 
 /*
index 1ad08e4..4de446c 100644 (file)
@@ -158,7 +158,7 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
 
   });
   simgrid::surf::on_cluster.connect(&clusterCreation_cb);
 
   });
   simgrid::surf::on_cluster.connect(&clusterCreation_cb);
-  simgrid::surf::on_postparse.connect(&postparse_cb);
+  simgrid::s4u::onPlatformCreated.connect(&postparse_cb);
   simgrid::s4u::NetZone::onRouteCreation.connect(&routeCreation_cb);
 
   LogComponentEnable("UdpEchoClientApplication", ns3::LOG_LEVEL_INFO);
   simgrid::s4u::NetZone::onRouteCreation.connect(&routeCreation_cb);
 
   LogComponentEnable("UdpEchoClientApplication", ns3::LOG_LEVEL_INFO);
index 2e4d420..e885af8 100644 (file)
@@ -143,7 +143,7 @@ namespace simgrid {
         smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor"));
 
       double current=1.0;
         smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor"));
 
       double current=1.0;
-      for (auto fact: smpi_lat_factor) {
+      for (const auto& fact : smpi_lat_factor) {
         if (size <= fact.factor) {
           XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
           return current;
         if (size <= fact.factor) {
           XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
           return current;
index e0bd47a..2f2f304 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
- * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u/engine.hpp"
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u/engine.hpp"
+
 #include "src/kernel/EngineImpl.hpp"
 #include "src/simix/smx_private.h"
 
 #include "src/kernel/EngineImpl.hpp"
 #include "src/simix/smx_private.h"
 
@@ -34,7 +33,6 @@ namespace simgrid {
 namespace surf {
 
 simgrid::xbt::signal<void(sg_platf_cluster_cbarg_t)> on_cluster;
 namespace surf {
 
 simgrid::xbt::signal<void(sg_platf_cluster_cbarg_t)> on_cluster;
-simgrid::xbt::signal<void(void)> on_postparse;
 
 }
 }
 
 }
 }
@@ -55,7 +53,7 @@ void sg_platf_init() {
 /** Module management function: frees all internal data structures */
 void sg_platf_exit() {
   simgrid::surf::on_cluster.disconnect_all_slots();
 /** Module management function: frees all internal data structures */
 void sg_platf_exit() {
   simgrid::surf::on_cluster.disconnect_all_slots();
-  simgrid::surf::on_postparse.disconnect_all_slots();
+  simgrid::s4u::onPlatformCreated.disconnect_all_slots();
 
   /* make sure that we will reinit the models while loading the platf once reinited */
   surf_parse_models_setup_already_called = 0;
 
   /* make sure that we will reinit the models while loading the platf once reinited */
   surf_parse_models_setup_already_called = 0;
@@ -569,7 +567,7 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
 void sg_platf_begin() { /* Do nothing: just for symmetry of user code */ }
 
 void sg_platf_end() {
 void sg_platf_begin() { /* Do nothing: just for symmetry of user code */ }
 
 void sg_platf_end() {
-  simgrid::surf::on_postparse();
+  simgrid::s4u::onPlatformCreated();
 }
 
 /* Pick the right models for CPU, net and host, and call their model_init_preparse */
 }
 
 /* Pick the right models for CPU, net and host, and call their model_init_preparse */
index 6cfdd69..4f892d0 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "storage_n11.hpp"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "storage_n11.hpp"
+#include "simgrid/s4u/engine.hpp"
 #include "src/kernel/routing/NetPoint.hpp"
 #include "surf_private.h"
 #include <math.h> /*ceil*/
 #include "src/kernel/routing/NetPoint.hpp"
 #include "surf_private.h"
 #include <math.h> /*ceil*/
@@ -51,7 +52,7 @@ static void check_disk_attachment()
 
 void storage_register_callbacks()
 {
 
 void storage_register_callbacks()
 {
-  simgrid::surf::on_postparse.connect(check_disk_attachment);
+  simgrid::s4u::onPlatformCreated.connect(check_disk_attachment);
   instr_routing_define_callbacks();
 
   ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, xbt_free_f);
   instr_routing_define_callbacks();
 
   ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, xbt_free_f);
index be9890d..8c9f25a 100644 (file)
@@ -35,12 +35,4 @@ XBT_PUBLIC_DATA(int_f_void_t) surf_parse;       /* Entry-point to the parser. Se
 
 SG_END_DECL()
 
 
 SG_END_DECL()
 
-namespace simgrid {
-namespace surf {
-
-extern XBT_PRIVATE xbt::signal<void(void)> on_postparse;
-
-}
-}
-
 #endif
 #endif