X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/62b54dd272b6f669c0a9b231991d572c3bec52b5..872d65264714799b25eb231609c3f05bae3d03dc:/src/surf/instr_routing.cpp diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index 05a47064c5..ad7511791a 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -6,7 +6,10 @@ #include "src/instr/instr_private.h" -#include "src/surf/surf_private.h" +#include "src/surf/AsImpl.hpp" +#include "simgrid/s4u/engine.hpp" +#include "surf/surf.h" +#include "src/surf/xml/platf_private.hpp" #include "xbt/graph.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_routing, instr, "Tracing platform hierarchy"); @@ -122,21 +125,20 @@ static void linkContainers (container_t src, container_t dst, xbt_dict_t filter) XBT_DEBUG (" linkContainers %s <-> %s", src->name, dst->name); } -static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t filter) +static void recursiveGraphExtraction (simgrid::s4u::As *as, container_t container, xbt_dict_t filter) { if (!TRACE_platform_topology()){ XBT_DEBUG("Graph extraction disabled by user."); return; } - XBT_DEBUG ("Graph extraction for routing_component = %s", surf_AS_get_name(rc)); - if (!xbt_dict_is_empty(surf_AS_get_routing_sons(rc))){ + XBT_DEBUG ("Graph extraction for routing_component = %s", as->name()); + if (!xbt_dict_is_empty(as->children())){ xbt_dict_cursor_t cursor = NULL; AS_t rc_son; char *child_name; //bottom-up recursion - xbt_dict_foreach(surf_AS_get_routing_sons(rc), cursor, child_name, rc_son) { - container_t child_container = (container_t) xbt_dict_get ( - container->children, surf_AS_get_name(rc_son)); + xbt_dict_foreach(as->children(), cursor, child_name, rc_son) { + container_t child_container = (container_t) xbt_dict_get (container->children, rc_son->name()); recursiveGraphExtraction (rc_son, child_container, filter); } } @@ -150,7 +152,7 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t xbt_dict_cursor_t cursor = NULL; char *edge_name; - surf_AS_get_graph(rc, graph, nodes, edges); + static_cast(as)->getGraph(graph, nodes, edges); xbt_dict_foreach(edges,cursor,edge_name,edge) { linkContainers( PJ_container_get((const char*) edge->src->data), @@ -255,24 +257,24 @@ static void instr_routing_parse_start_link (sg_platf_link_cbarg_t link) xbt_dynar_free (&links_to_create); } -static void instr_routing_parse_start_host (sg_platf_host_cbarg_t host) +void sg_instr_new_host(sg_platf_host_cbarg_t host) { container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); container_t container = PJ_container_new (host->id, INSTR_HOST, father); - if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (! TRACE_disable_power())) { - type_t power = PJ_type_get_or_null ("power", container->type); - if (power == NULL){ - power = PJ_type_variable_new ("power", NULL, container->type); + if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (! TRACE_disable_speed())) { + type_t speed = PJ_type_get_or_null ("power", container->type); + if (speed == NULL){ + speed = PJ_type_variable_new ("power", NULL, container->type); } - double current_power_state; - xbt_dynar_get_cpy(host->power_peak, host->pstate, ¤t_power_state); - new_pajeSetVariable (0, container, power, current_power_state); + double current_speed_state; + xbt_dynar_get_cpy(host->speed_per_pstate, host->pstate, ¤t_speed_state); + new_pajeSetVariable (0, container, speed, current_speed_state); } if (TRACE_uncategorized()){ - type_t power_used = PJ_type_get_or_null ("power_used", container->type); - if (power_used == NULL){ + type_t speed_used = PJ_type_get_or_null ("power_used", container->type); + if (speed_used == NULL){ PJ_type_variable_new ("power_used", "0.5 0.5 0.5", container->type); } } @@ -330,7 +332,7 @@ static void instr_routing_parse_end_platform () currentContainer = NULL; xbt_dict_t filter = xbt_dict_new_homogeneous(xbt_free_f); XBT_DEBUG ("Starting graph extraction."); - recursiveGraphExtraction (surf_platf_get_root(routing_platf), PJ_container_get_root(), filter); + recursiveGraphExtraction (simgrid::s4u::Engine::instance()->rootAs(), PJ_container_get_root(), filter); XBT_DEBUG ("Graph extraction finished."); xbt_dict_free(&filter); platform_created = 1; @@ -343,10 +345,8 @@ void instr_routing_define_callbacks () //always need the call backs to ASes (we need only the root AS), //to create the rootContainer and the rootType properly if (!TRACE_needs_platform()) return; - sg_platf_link_add_cb(instr_routing_parse_start_link); - sg_platf_host_add_cb(instr_routing_parse_start_host); - - sg_platf_postparse_add_cb(instr_routing_parse_end_platform); + simgrid::surf::on_link.connect(instr_routing_parse_start_link); + simgrid::surf::on_postparse.connect(instr_routing_parse_end_platform); } /* @@ -445,21 +445,21 @@ int instr_platform_traced () static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, - AS_t rc, container_t container) + AS_t as, container_t container) { - if (!xbt_dict_is_empty(surf_AS_get_routing_sons(rc))){ + if (!xbt_dict_is_empty(as->children())){ xbt_dict_cursor_t cursor = NULL; - AS_t rc_son; + AS_t as_child; char *child_name; //bottom-up recursion - xbt_dict_foreach(surf_AS_get_routing_sons(rc), cursor, child_name, rc_son) { + xbt_dict_foreach(as->children(), cursor, child_name, as_child) { container_t child_container = (container_t) xbt_dict_get ( - container->children, surf_AS_get_name(rc_son)); - recursiveXBTGraphExtraction (graph, nodes, edges, rc_son, child_container); + container->children, as_child->name()); + recursiveXBTGraphExtraction (graph, nodes, edges, as_child, child_container); } } - surf_AS_get_graph(rc, graph, nodes, edges); + static_cast(as)->getGraph(graph, nodes, edges); } xbt_graph_t instr_routing_platform_graph (void) @@ -467,7 +467,7 @@ xbt_graph_t instr_routing_platform_graph (void) xbt_graph_t ret = xbt_graph_new_graph (0, NULL); xbt_dict_t nodes = xbt_dict_new_homogeneous(NULL); xbt_dict_t edges = xbt_dict_new_homogeneous(NULL); - recursiveXBTGraphExtraction (ret, nodes, edges, surf_platf_get_root(routing_platf), PJ_container_get_root()); + recursiveXBTGraphExtraction (ret, nodes, edges, simgrid::s4u::Engine::instance()->rootAs(), PJ_container_get_root()); xbt_dict_free (&nodes); xbt_dict_free (&edges); return ret;