From 2c1cf331f7be1c55098faf7ba7a542149576614c Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 31 Jan 2016 21:51:11 +0100 Subject: [PATCH] sanitize the handling of trace:connect for host_avail --- src/include/surf/surf.h | 1 - src/surf/cpu_cas01.cpp | 12 +----------- src/surf/cpu_ti.cpp | 19 +------------------ src/surf/cpu_ti.hpp | 2 -- src/surf/host_ptask_L07.cpp | 12 +----------- src/surf/surfxml_parseplatf.cpp | 16 ++++++++++++++++ 6 files changed, 19 insertions(+), 43 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 6fdb314438..52a2e56a62 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -975,7 +975,6 @@ XBT_PUBLIC(void) parse_platform_file(const char *file); /* For the trace and trace:connect tag (store their content till the end of the parsing) */ XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list; -XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail; XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_speed; XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail; XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_bw; diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 052301832a..79d0c91fe2 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -115,17 +115,7 @@ void CpuCas01Model::addTraces() return; called = 1; - /* connect all traces relative to hosts */ - xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) { - tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); - Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu; - - xbt_assert(cpu, "Host %s undefined", elm); - xbt_assert(trace, "Trace %s undefined", trace_name); - - cpu->set_state_trace(trace); - } - + /* connect host speed traces */ xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu; diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 3bcecbfd2d..63701e261a 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -492,22 +492,6 @@ void CpuTiModel::addTraces() called = 1; /* connect all traces relative to hosts */ - xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) { - tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); - CpuTi *cpu = static_cast(sg_host_by_name(elm)->pimpl_cpu); - - xbt_assert(cpu, "Host %s undefined", elm); - xbt_assert(trace, "Trace %s undefined", trace_name); - - if (cpu->p_stateEvent) { - XBT_DEBUG("Trace already configured for this CPU(%s), ignoring it", - elm); - continue; - } - XBT_DEBUG("Add state trace: %s to CPU(%s)", trace_name, elm); - cpu->p_stateEvent = future_evt_set->add_trace(trace, 0.0, cpu); - } - xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); CpuTi *cpu = static_cast(sg_host_by_name(elm)->pimpl_cpu); @@ -527,8 +511,7 @@ void CpuTiModel::addTraces() xbt_dynar_get_cpy(trace->s_list.event_list, xbt_dynar_length(trace->s_list.event_list) - 1, &val); if (val.delta == 0) { - cpu->p_speedEvent = - future_evt_set->add_trace(tmgr_empty_trace_new(), cpu->p_availTrace->m_lastTime, cpu); + cpu->set_speed_trace(tmgr_empty_trace_new()); } } } diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 9df68f476f..9c46c462a6 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -128,8 +128,6 @@ public: void modified(bool modified); CpuTiTgmr *p_availTrace; /*< Structure with data needed to integrate trace file */ - tmgr_trace_iterator_t p_stateEvent = NULL; /*< trace file with states events (ON or OFF) */ - tmgr_trace_iterator_t p_speedEvent = NULL; /*< trace file with availability events */ ActionTiList *p_actionSet; /*< set with all actions running on cpu */ double m_sumPriority; /*< the sum of actions' priority that are running on cpu */ double m_lastUpdate = 0; /*< last update of actions' remaining amount done */ diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index a66b50869b..9197c4d277 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -340,20 +340,10 @@ void HostL07Model::addTraces() xbt_dict_cursor_t cursor = NULL; char *trace_name, *elm; - if (!trace_connect_list_host_avail) + if (!trace_connect_list_host_speed) return; /* Connect traces relative to cpu */ - xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) { - tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); - Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu; - - xbt_assert(cpu, "Host %s undefined", elm); - xbt_assert(trace, "Trace %s undefined", trace_name); - - cpu->set_state_trace(trace); - } - xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu; diff --git a/src/surf/surfxml_parseplatf.cpp b/src/surf/surfxml_parseplatf.cpp index 989e211926..ab301e372d 100644 --- a/src/surf/surfxml_parseplatf.cpp +++ b/src/surf/surfxml_parseplatf.cpp @@ -10,6 +10,7 @@ #include "xbt/dict.h" #include "simgrid/platf.h" #include "surf/surfxml_parse.h" +#include "src/surf/cpu_interface.hpp" #include "src/surf/surf_private.h" #ifdef HAVE_LUA @@ -135,6 +136,21 @@ void parse_platform_file(const char *file) /* Do the actual parsing */ parse_status = surf_parse(); + /* connect all traces relative to hosts */ + xbt_dict_cursor_t cursor = NULL; + char *trace_name, *elm; + + xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) { + tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); + xbt_assert(trace, "Trace %s undefined", trace_name); + + simgrid::s4u::Host *host = sg_host_by_name(elm); + xbt_assert(host, "Host %s undefined", elm); + simgrid::surf::Cpu *cpu = host->pimpl_cpu; + + cpu->set_state_trace(trace); + } + /* Free my data */ xbt_dict_free(&trace_connect_list_host_avail); xbt_dict_free(&trace_connect_list_host_speed); -- 2.20.1