From: Martin Quinson Date: Wed, 1 Feb 2017 19:02:02 +0000 (+0100) Subject: New callback: simgrid::s4u::onPlatformCreated (right before the simulation start) X-Git-Tag: v3_15~492 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d4ae59be01b5712d91572d5a8503ca56326694c4 New callback: simgrid::s4u::onPlatformCreated (right before the simulation start) --- diff --git a/ChangeLog b/ChangeLog index 62bfffb585..4adcbf017e 100644 --- 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). + S4U + - New callbacks: + - simgrid::s4u::onPlatformCreated: right before the simulation starts + -- target_date=March 20 2017 -- Da SimGrid team SimGrid (3.14.159) stable; urgency=low diff --git a/include/simgrid/s4u/engine.hpp b/include/simgrid/s4u/engine.hpp index 9bdbba9021..25fe6e4bbd 100644 --- a/include/simgrid/s4u/engine.hpp +++ b/include/simgrid/s4u/engine.hpp @@ -104,6 +104,11 @@ public: 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 onPlatformCreated; }} // namespace simgrid::s4u #endif /* SIMGRID_S4U_ENGINE_HPP */ diff --git a/src/msg/msg_global.cpp b/src/msg/msg_global.cpp index f4dd8abf85..79f02a4f8f 100644 --- a/src/msg/msg_global.cpp +++ b/src/msg/msg_global.cpp @@ -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. */ +#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 "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)"); @@ -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); - 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); }); diff --git a/src/s4u/s4u_engine.cpp b/src/s4u/s4u_engine.cpp index 2980b68557..b872ca4078 100644 --- a/src/s4u/s4u_engine.cpp +++ b/src/s4u/s4u_engine.cpp @@ -23,6 +23,7 @@ XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface"); namespace simgrid { namespace s4u { +xbt::signal onPlatformCreated; Engine *Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */ diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 78512e6795..a6e990c4c6 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -13,7 +13,8 @@ #include -#include +#include "simgrid/s4u/engine.hpp" +#include "simgrid/s4u/host.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(); - 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(new simgrid::simix::Host()); }); @@ -428,7 +429,6 @@ void SIMIX_run() } double time = 0; - smx_actor_t process; 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; + 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); diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index 5401f123ab..e443fe6412 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -8,6 +8,7 @@ #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" @@ -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); - simgrid::surf::on_postparse.connect(instr_routing_parse_end_platform); + simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform); } /* diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 1ad08e44c0..4de446c397 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -158,7 +158,7 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel() { }); 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); diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 2e4d420290..e885af8615 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -143,7 +143,7 @@ namespace simgrid { 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; diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index e0bd47a860..2f2f304c8d 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -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" + #include "src/kernel/EngineImpl.hpp" #include "src/simix/smx_private.h" @@ -34,7 +33,6 @@ namespace simgrid { namespace surf { simgrid::xbt::signal on_cluster; -simgrid::xbt::signal 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(); - 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; @@ -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() { - simgrid::surf::on_postparse(); + simgrid::s4u::onPlatformCreated(); } /* Pick the right models for CPU, net and host, and call their model_init_preparse */ diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 6cfdd6907a..4f892d0c25 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -5,6 +5,7 @@ * 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 /*ceil*/ @@ -51,7 +52,7 @@ static void check_disk_attachment() 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); diff --git a/src/surf/xml/platf.hpp b/src/surf/xml/platf.hpp index be9890daf6..8c9f25a6a6 100644 --- a/src/surf/xml/platf.hpp +++ b/src/surf/xml/platf.hpp @@ -35,12 +35,4 @@ XBT_PUBLIC_DATA(int_f_void_t) surf_parse; /* Entry-point to the parser. Se SG_END_DECL() -namespace simgrid { -namespace surf { - -extern XBT_PRIVATE xbt::signal on_postparse; - -} -} - #endif