X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1f1c7080d6a6cf2d444dc724d08dc568969aa145..1bd3b1e9e02dd5662a771c1b382cfa1d1d9a2e08:/src/surf/cpu_ti.cpp diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index d3735e3625..1d6ea1e1d9 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -5,8 +5,9 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "cpu_ti.hpp" -#include "trace_mgr_private.h" #include "xbt/heap.h" +#include "src/surf/trace_mgr.hpp" +#include "src/surf/platform.hpp" #ifndef SURF_MODEL_CPUTI_H_ #define SURF_MODEL_CPUTI_H_ @@ -390,7 +391,9 @@ int CpuTiTrace::binarySearch(double *array, double a, int low, int high) static void cpu_ti_define_callbacks() { - sg_platf_postparse_add_cb(simgrid::surf::cpu_add_traces); + simgrid::surf::on_postparse.connect([]() { + surf_cpu_model_pm->addTraces(); + }); } /********* @@ -434,20 +437,20 @@ CpuTiModel::~CpuTiModel() xbt_heap_free(p_tiActionHeap); } -Cpu *CpuTiModel::createCpu(simgrid::Host *host, +Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, - e_surf_resource_state_t stateInitial, + int initiallyOn, tmgr_trace_t stateTrace) { xbt_assert(core==1,"Multi-core not handled with this model yet"); xbt_assert(xbt_dynar_getfirst_as(speedPeak, double) > 0.0, "Speed has to be >0.0. Did you forget to specify the mandatory speed attribute?"); CpuTi *cpu = new CpuTi(this, host, speedPeak, pstate, speedScale, speedTrace, - core, stateInitial, stateTrace); + core, initiallyOn, stateTrace); return cpu; } @@ -501,7 +504,7 @@ void CpuTiModel::addTraces() /* 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)->p_cpu); + 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); @@ -512,12 +515,12 @@ void CpuTiModel::addTraces() continue; } XBT_DEBUG("Add state trace: %s to CPU(%s)", trace_name, elm); - cpu->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, cpu); + cpu->p_stateEvent = future_evt_set->add_trace(trace, 0.0, 0, cpu); } xbt_dict_foreach(trace_connect_list_power, 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)->p_cpu); + 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); @@ -534,11 +537,8 @@ 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) { - tmgr_trace_t empty_trace; - empty_trace = tmgr_empty_trace_new(); cpu->p_speedEvent = - tmgr_history_add_trace(history, empty_trace, - cpu->p_availTrace->m_lastTime, 0, cpu); + future_evt_set->add_trace(tmgr_empty_trace_new(), cpu->p_availTrace->m_lastTime, 0, cpu); } } } @@ -547,10 +547,10 @@ void CpuTiModel::addTraces() /************ * Resource * ************/ -CpuTi::CpuTi(CpuTiModel *model, simgrid::Host *host, xbt_dynar_t speedPeak, +CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, - e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace) - : Cpu(model, host, NULL, pstate, core, 0, speedScale, stateInitial) + int initiallyOn, tmgr_trace_t stateTrace) + : Cpu(model, host, NULL, pstate, core, 0, speedScale, initiallyOn) { xbt_assert(core==1,"Multi-core not handled by this model yet"); m_core = core; @@ -564,7 +564,7 @@ CpuTi::CpuTi(CpuTiModel *model, simgrid::Host *host, xbt_dynar_t speedPeak, XBT_DEBUG("CPU create: peak=%f", m_speedPeak); if (stateTrace) - p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, this); + p_stateEvent = future_evt_set->add_trace(stateTrace, 0.0, 0, this); if (speedTrace && xbt_dynar_length(speedTrace->s_list.event_list) > 1) { s_tmgr_event_t val; @@ -572,8 +572,8 @@ CpuTi::CpuTi(CpuTiModel *model, simgrid::Host *host, xbt_dynar_t speedPeak, xbt_dynar_get_cpy(speedTrace->s_list.event_list, xbt_dynar_length(speedTrace->s_list.event_list) - 1, &val); if (val.delta == 0) { - tmgr_trace_t empty_trace = tmgr_empty_trace_new(); - p_speedEvent = tmgr_history_add_trace(history, empty_trace, p_availTrace->m_lastTime, 0, this); + p_speedEvent = + future_evt_set->add_trace(tmgr_empty_trace_new(), p_availTrace->m_lastTime, 0, this); } } } @@ -585,7 +585,7 @@ CpuTi::~CpuTi() delete p_actionSet; } -void CpuTi::updateState(tmgr_trace_event_t event_type, +void CpuTi::updateState(tmgr_trace_iterator_t event_type, double value, double date) { CpuTiAction *action; @@ -619,11 +619,11 @@ void CpuTi::updateState(tmgr_trace_event_t event_type, } else if (event_type == p_stateEvent) { if (value > 0) { - if(getState() == SURF_RESOURCE_OFF) + if(isOff()) xbt_dynar_push_as(host_that_restart, char*, (char *)getName()); - setState(SURF_RESOURCE_ON); + turnOn(); } else { - setState(SURF_RESOURCE_OFF); + turnOff(); /* put all action running on cpu to failed */ for(ActionTiList::iterator it(p_actionSet->begin()), itend(p_actionSet->end()) @@ -794,7 +794,7 @@ void CpuTi::updateRemainingAmount(double now) CpuAction *CpuTi::execute(double size) { XBT_IN("(%s,%g)", getName(), size); - CpuTiAction *action = new CpuTiAction(static_cast(getModel()), size, getState() != SURF_RESOURCE_ON, this); + CpuTiAction *action = new CpuTiAction(static_cast(getModel()), size, isOff(), this); p_actionSet->push_back(*action); @@ -809,7 +809,7 @@ CpuAction *CpuTi::sleep(double duration) duration = MAX(duration, sg_surf_precision); XBT_IN("(%s,%g)", getName(), duration); - CpuTiAction *action = new CpuTiAction(static_cast(getModel()), 1.0, getState() != SURF_RESOURCE_ON, this); + CpuTiAction *action = new CpuTiAction(static_cast(getModel()), 1.0, isOff(), this); action->m_maxDuration = duration; action->m_suspended = 2;