From 1d17c885aa26ea6c36c1fc0c6ab39ddd5d509755 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 24 Apr 2018 18:43:17 +0200 Subject: [PATCH] simplication and uniformization --- src/bindings/lua/lua_platf.cpp | 2 -- src/include/surf/surf.hpp | 1 - src/instr/instr_config.cpp | 17 ++++++++-------- src/instr/instr_private.hpp | 1 + src/surf/instr_routing.cpp | 31 ++++++++++++++--------------- src/surf/sg_platf.cpp | 3 ++- src/surf/storage_n11.cpp | 8 +------- src/surf/surf_private.hpp | 3 +-- src/surf/xml/surfxml_parseplatf.cpp | 3 --- 9 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index 26c9276499..a52a7070d8 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -63,8 +63,6 @@ int console_open(lua_State *L) { sg_platf_init(); sg_platf_begin(); - storage_register_callbacks(); - return 0; } diff --git a/src/include/surf/surf.hpp b/src/include/surf/surf.hpp index 03768f9408..db629ccbf2 100644 --- a/src/include/surf/surf.hpp +++ b/src/include/surf/surf.hpp @@ -332,7 +332,6 @@ XBT_PUBLIC void parse_platform_file(const char* file); /********** Tracing **********/ /* instr_routing.c */ -void instr_routing_define_callbacks(); xbt_graph_t instr_routing_platform_graph(); void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename); diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index f5e687a04c..1f76e6ad89 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -81,6 +81,7 @@ int TRACE_start() // - enabled (with --cfg=tracing:yes) // - already configured (TRACE_global_init already called) if (TRACE_is_enabled()) { + instr_routing_define_callbacks(); XBT_DEBUG("Tracing starts"); /* init the tracing module to generate the right output */ @@ -201,42 +202,42 @@ bool TRACE_uncategorized () bool TRACE_actor_is_enabled() { - return trace_actor_enabled && TRACE_is_enabled(); + return trace_actor_enabled && trace_enabled; } bool TRACE_vm_is_enabled() { - return trace_vm_enabled && TRACE_is_enabled(); + return trace_vm_enabled && trace_enabled; } bool TRACE_disable_link() { - return trace_disable_link && TRACE_is_enabled(); + return trace_disable_link && trace_enabled; } bool TRACE_disable_speed() { - return trace_disable_power && TRACE_is_enabled(); + return trace_disable_power && trace_enabled; } bool TRACE_buffer () { - return trace_buffer && TRACE_is_enabled(); + return trace_buffer && trace_enabled; } bool TRACE_disable_destroy () { - return trace_disable_destroy && TRACE_is_enabled(); + return trace_disable_destroy && trace_enabled; } bool TRACE_basic () { - return trace_basic && TRACE_is_enabled(); + return trace_basic && trace_enabled; } bool TRACE_display_sizes () { - return trace_display_sizes && trace_smpi_enabled && TRACE_is_enabled(); + return trace_display_sizes && trace_smpi_enabled && trace_enabled; } std::string TRACE_get_comment() diff --git a/src/instr/instr_private.hpp b/src/instr/instr_private.hpp index 2e71e313a7..579758ce0f 100644 --- a/src/instr/instr_private.hpp +++ b/src/instr/instr_private.hpp @@ -249,6 +249,7 @@ XBT_PRIVATE void TRACE_surf_link_set_utilization(const char* resource, const cha extern XBT_PRIVATE std::set trivaNodeTypes; extern XBT_PRIVATE std::set trivaEdgeTypes; XBT_PRIVATE long long int instr_new_paje_id(); +XBT_PRIVATE void instr_routing_define_callbacks(); void instr_new_variable_type(std::string new_typename, std::string color); void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color); void instr_new_user_state_type(std::string father_type, std::string new_typename); diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index 835aee20f9..b70294a5db 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -150,7 +150,7 @@ static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t /* * Callbacks */ -static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone) +static void instr_netzone_on_creation(simgrid::s4u::NetZone& netzone) { std::string id = netzone.get_name(); @@ -180,14 +180,14 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone) } } -static void sg_instr_AS_end(simgrid::s4u::NetZone& /*netzone*/) +static void instr_netzone_on_seal(simgrid::s4u::NetZone& /*netzone*/) { if (TRACE_needs_platform()){ currentContainer.pop_back(); } } -static void instr_routing_parse_start_link(simgrid::s4u::Link& link) +static void instr_link_on_creation(simgrid::s4u::Link& link) { if (currentContainer.empty()) // No ongoing parsing. Are you creating the loopback? return; @@ -208,7 +208,7 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link) } } -static void sg_instr_new_host(simgrid::s4u::Host& host) +static void instr_host_on_creation(simgrid::s4u::Host& host) { container_t container = new simgrid::instr::HostContainer(host, currentContainer.back()); container_t root = simgrid::instr::Container::getRoot(); @@ -255,13 +255,13 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) } } -static void sg_instr_new_router(simgrid::kernel::routing::NetPoint * netpoint) +static void instr_netpoint_on_creation(simgrid::kernel::routing::NetPoint* netpoint) { if (netpoint->is_router() && TRACE_is_enabled() && TRACE_needs_platform()) new simgrid::instr::RouterContainer(netpoint->get_cname(), currentContainer.back()); } -static void instr_routing_parse_end_platform () +static void instr_on_platform_created() { currentContainer.clear(); std::set* filter = new std::set; @@ -273,19 +273,18 @@ static void instr_routing_parse_end_platform () TRACE_paje_dump_buffer(true); } -void instr_routing_define_callbacks () +void instr_routing_define_callbacks() { - // always need the callbacks to ASes (we need only the root AS), to create the rootContainer and the rootType properly - if (not TRACE_is_enabled()) - return; + // always need the callbacks to zones (we need only the root zone), to create the rootContainer and the rootType + // properly if (TRACE_needs_platform()) { - simgrid::s4u::Link::onCreation.connect(instr_routing_parse_start_link); - simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform); - simgrid::s4u::Host::onCreation.connect(sg_instr_new_host); + simgrid::s4u::Host::onCreation.connect(instr_host_on_creation); + simgrid::s4u::Link::onCreation.connect(instr_link_on_creation); + simgrid::s4u::onPlatformCreated.connect(instr_on_platform_created); } - simgrid::s4u::NetZone::onCreation.connect(sg_instr_AS_begin); - simgrid::s4u::NetZone::onSeal.connect(sg_instr_AS_end); - simgrid::kernel::routing::NetPoint::onCreation.connect(sg_instr_new_router); + simgrid::s4u::NetZone::onCreation.connect(instr_netzone_on_creation); + simgrid::s4u::NetZone::onSeal.connect(instr_netzone_on_seal); + simgrid::kernel::routing::NetPoint::onCreation.connect(instr_netpoint_on_creation); } /* * user categories support diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index fae502ce36..9f71bc53b4 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -48,7 +48,8 @@ static simgrid::kernel::routing::NetZoneImpl* routing_get_current() /** Module management function: creates all internal data structures */ void sg_platf_init() -{ /* Do nothing: just for symmetry of user code */ +{ + simgrid::s4u::onPlatformCreated.connect(check_disk_attachment); } /** Module management function: frees all internal data structures */ diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index f9e5c7a0ed..53b75032e7 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -17,7 +17,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_storage); *************/ extern std::map storage_types; -static void check_disk_attachment() +void check_disk_attachment() { for (auto const& s : simgrid::s4u::Engine::getInstance()->getAllStorages()) { simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s->getImpl()->getHost().c_str()); @@ -29,12 +29,6 @@ static void check_disk_attachment() } } -void storage_register_callbacks() -{ - simgrid::s4u::onPlatformCreated.connect(check_disk_attachment); - instr_routing_define_callbacks(); -} - /********* * Model * *********/ diff --git a/src/surf/surf_private.hpp b/src/surf/surf_private.hpp index 375960cc8e..fc2e885fc2 100644 --- a/src/surf/surf_private.hpp +++ b/src/surf/surf_private.hpp @@ -20,8 +20,7 @@ XBT_PRIVATE std::ifstream* surf_ifsopen(std::string name); */ XBT_PRIVATE int __surf_is_absolute_file_path(const char* file_path); -XBT_PUBLIC void storage_register_callbacks(); - +XBT_PRIVATE void check_disk_attachment(); XBT_PRIVATE void parse_after_config(); #endif diff --git a/src/surf/xml/surfxml_parseplatf.cpp b/src/surf/xml/surfxml_parseplatf.cpp index 3edce862c9..14767edce3 100644 --- a/src/surf/xml/surfxml_parseplatf.cpp +++ b/src/surf/xml/surfxml_parseplatf.cpp @@ -65,9 +65,6 @@ void parse_after_config() { if (not after_config_done) { TRACE_start(); - /* Register classical callbacks */ - storage_register_callbacks(); - after_config_done = 1; } } -- 2.20.1