X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/befbbbe1fbb31663a8f91e24ce12df271cf4ae79..1dbdb7cb3a16885ab4749222c48f7bf83a7e0ef3:/src/surf/xml/surfxml_parseplatf.cpp diff --git a/src/surf/xml/surfxml_parseplatf.cpp b/src/surf/xml/surfxml_parseplatf.cpp index 5f02c5230a..0e4d96d3dd 100644 --- a/src/surf/xml/surfxml_parseplatf.cpp +++ b/src/surf/xml/surfxml_parseplatf.cpp @@ -7,7 +7,6 @@ #include "src/instr/instr_private.h" // TRACE_start(). FIXME: remove by subscribing tracing to the surf signals #include "src/surf/cpu_interface.hpp" #include "src/surf/network_interface.hpp" -#include "xbt/dict.h" #include "xbt/log.h" #include "xbt/misc.h" #include "xbt/str.h" @@ -27,21 +26,20 @@ extern "C" { XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse); -SG_BEGIN_DECL() - /* Trace related stuff */ - -xbt_dict_t traces_set_list = nullptr; +XBT_PRIVATE std::unordered_map traces_set_list; XBT_PRIVATE std::unordered_map trace_connect_list_host_avail; XBT_PRIVATE std::unordered_map trace_connect_list_host_speed; XBT_PRIVATE std::unordered_map trace_connect_list_link_avail; XBT_PRIVATE std::unordered_map trace_connect_list_link_bw; XBT_PRIVATE std::unordered_map trace_connect_list_link_lat; -void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect) +SG_BEGIN_DECL() +void sg_platf_trace_connect(TraceConnectCreationArgs* trace_connect) { - xbt_assert(xbt_dict_get_or_null(traces_set_list, trace_connect->trace), - "Cannot connect trace %s to %s: trace unknown", trace_connect->trace, trace_connect->element); + xbt_assert(traces_set_list.find(trace_connect->trace) != traces_set_list.end(), + "Cannot connect trace %s to %s: trace unknown", trace_connect->trace.c_str(), + trace_connect->element.c_str()); switch (trace_connect->kind) { case SURF_TRACE_CONNECT_KIND_HOST_AVAIL: @@ -60,8 +58,8 @@ void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect) trace_connect_list_link_lat.insert({trace_connect->trace, trace_connect->element}); break; default: - surf_parse_error("Cannot connect trace %s to %s: kind of trace unknown", trace_connect->trace, - trace_connect->element); + surf_parse_error(std::string("Cannot connect trace ") + trace_connect->trace + " to " + trace_connect->element + + ": unknown kind of trace"); break; } } @@ -116,15 +114,13 @@ void parse_platform_file(const char *file) after_config_done = 0; surf_parse_open(file); - traces_set_list = xbt_dict_new_homogeneous(nullptr); - /* Do the actual parsing */ parse_status = surf_parse(); /* connect all traces relative to hosts */ - for (auto elm : trace_connect_list_host_avail) { - tmgr_trace_t trace = (tmgr_trace_t)xbt_dict_get_or_null(traces_set_list, elm.first.c_str()); - xbt_assert(trace, "Trace %s undefined", elm.first.c_str()); + for (auto const& elm : trace_connect_list_host_avail) { + xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); + tmgr_trace_t trace = traces_set_list.at(elm.first); simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str()); xbt_assert(host, "Host %s undefined", elm.second.c_str()); @@ -133,9 +129,9 @@ void parse_platform_file(const char *file) cpu->setStateTrace(trace); } - for (auto elm : trace_connect_list_host_speed) { - tmgr_trace_t trace = (tmgr_trace_t)xbt_dict_get_or_null(traces_set_list, elm.first.c_str()); - xbt_assert(trace, "Trace %s undefined", elm.first.c_str()); + for (auto const& elm : trace_connect_list_host_speed) { + xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); + tmgr_trace_t trace = traces_set_list.at(elm.first); simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str()); xbt_assert(host, "Host %s undefined", elm.second.c_str()); @@ -144,38 +140,35 @@ void parse_platform_file(const char *file) cpu->setSpeedTrace(trace); } - for (auto elm : trace_connect_list_link_avail) { - tmgr_trace_t trace = (tmgr_trace_t)xbt_dict_get_or_null(traces_set_list, elm.first.c_str()); - xbt_assert(trace, "Trace %s undefined", elm.first.c_str()); + for (auto const& elm : trace_connect_list_link_avail) { + xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); + tmgr_trace_t trace = traces_set_list.at(elm.first); sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str()); xbt_assert(link, "Link %s undefined", elm.second.c_str()); link->setStateTrace(trace); } - for (auto elm : trace_connect_list_link_bw) { - tmgr_trace_t trace = (tmgr_trace_t)xbt_dict_get_or_null(traces_set_list, elm.first.c_str()); - xbt_assert(trace, "Trace %s undefined", elm.first.c_str()); + for (auto const& elm : trace_connect_list_link_bw) { + xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); + tmgr_trace_t trace = traces_set_list.at(elm.first); sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str()); xbt_assert(link, "Link %s undefined", elm.second.c_str()); link->setBandwidthTrace(trace); } - for (auto elm : trace_connect_list_link_lat) { - tmgr_trace_t trace = (tmgr_trace_t)xbt_dict_get_or_null(traces_set_list, elm.first.c_str()); - xbt_assert(trace, "Trace %s undefined", elm.first.c_str()); + for (auto const& elm : trace_connect_list_link_lat) { + xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); + tmgr_trace_t trace = traces_set_list.at(elm.first); sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str()); xbt_assert(link, "Link %s undefined", elm.second.c_str()); link->setLatencyTrace(trace); } - /* Free my data */ - xbt_dict_free(&traces_set_list); - surf_parse_close(); if (parse_status) - surf_parse_error("Parse error in %s", file); + surf_parse_error(std::string("Parse error in ") + file); } }