X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/24c3e313f3c05f044f19ff318c11f7bedc6da624..5f9b13c6302e914a514168da8ff54818c0ee6787:/src/surf/cpu_ti.cpp diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 01beca94e6..93c115c984 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -399,10 +399,6 @@ void surf_cpu_model_init_ti() surf_cpu_model_vm = new simgrid::surf::CpuTiModel(); xbt_dynar_push(all_existing_models, &surf_cpu_model_vm); - - simgrid::surf::on_postparse.connect([]() { - surf_cpu_model_pm->addTraces(); - }); } namespace simgrid { @@ -444,7 +440,7 @@ Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, return cpu; } -double CpuTiModel::shareResources(double now) +double CpuTiModel::next_occuring_event(double now) { double min_action_duration = -1; @@ -480,29 +476,6 @@ void CpuTiModel::updateActionsState(double now, double /*delta*/) } } -void CpuTiModel::addTraces() -{ - xbt_dict_cursor_t cursor = NULL; - char *trace_name, *elm; - - static int called = 0; - - if (called) - return; - called = 1; - -/* connect all traces relative to hosts */ - 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); - - xbt_assert(cpu, "Host %s undefined", elm); - xbt_assert(trace, "Trace %s undefined", trace_name); - - cpu->set_speed_trace(trace); - } -} - /************ * Resource * ************/ @@ -514,13 +487,13 @@ CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, xbt_assert(core==1,"Multi-core not handled by this model yet"); m_core = core; - m_speedScale = speedScale; + p_speed.scale = speedScale; p_availTrace = new CpuTiTgmr(speedTrace, speedScale); p_actionSet = new ActionTiList(); - xbt_dynar_get_cpy(speedPeak, 0, &m_speedPeak); - XBT_DEBUG("CPU create: peak=%f", m_speedPeak); + xbt_dynar_get_cpy(speedPeak, 0, &p_speed.peak); + XBT_DEBUG("CPU create: peak=%f", p_speed.peak); if (stateTrace) p_stateEvent = future_evt_set->add_trace(stateTrace, 0.0, this); @@ -531,7 +504,7 @@ CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, xbt_dynar_get_cpy(speedTrace->event_list, xbt_dynar_length(speedTrace->event_list) - 1, &val); if (val.delta == 0) { - p_speedEvent = + p_speed.event = future_evt_set->add_trace(tmgr_empty_trace_new(), p_availTrace->m_lastTime, this); } } @@ -548,33 +521,27 @@ void CpuTi::set_speed_trace(tmgr_trace_t trace) if (p_availTrace) delete p_availTrace; - p_availTrace = new CpuTiTgmr(trace, m_speedScale); + p_availTrace = new CpuTiTgmr(trace, p_speed.scale); /* add a fake trace event if periodicity == 0 */ if (trace && xbt_dynar_length(trace->event_list) > 1) { s_tmgr_event_t val; - xbt_dynar_get_cpy(trace->event_list, - xbt_dynar_length(trace->event_list) - 1, &val); - if (val.delta == 0) { - p_speedEvent = future_evt_set->add_trace(tmgr_empty_trace_new(), 0.0, this); - } + xbt_dynar_get_cpy(trace->event_list, xbt_dynar_length(trace->event_list) - 1, &val); + if (val.delta == 0) + p_speed.event = future_evt_set->add_trace(tmgr_empty_trace_new(), 0.0, this); } } -void CpuTi::updateState(tmgr_trace_iterator_t event_type, - double value, double date) +void CpuTi::apply_event(tmgr_trace_iterator_t event, double value) { - CpuTiAction *action; - - if (event_type == p_speedEvent) { + if (event == p_speed.event) { tmgr_trace_t speedTrace; CpuTiTgmr *trace; s_tmgr_event_t val; - XBT_DEBUG("Finish trace date: %f value %f date %f", surf_get_clock(), - value, date); + XBT_DEBUG("Finish trace date: value %f", value); /* update remaining of actions and put in modified cpu swag */ - updateRemainingAmount(date); + updateRemainingAmount(surf_get_clock()); modified(true); @@ -583,27 +550,29 @@ void CpuTi::updateState(tmgr_trace_iterator_t event_type, xbt_dynar_length(speedTrace->event_list) - 1, &val); /* free old trace */ delete p_availTrace; - m_speedScale = val.value; + p_speed.scale = val.value; trace = new CpuTiTgmr(TRACE_FIXED, val.value); XBT_DEBUG("value %f", val.value); p_availTrace = trace; - tmgr_trace_event_unref(&p_speedEvent); + tmgr_trace_event_unref(&p_speed.event); - } else if (event_type == p_stateEvent) { + } else if (event == p_stateEvent) { if (value > 0) { if(isOff()) xbt_dynar_push_as(host_that_restart, char*, (char *)getName()); turnOn(); } else { turnOff(); + double date = surf_get_clock(); /* put all action running on cpu to failed */ for(ActionTiList::iterator it(p_actionSet->begin()), itend(p_actionSet->end()) ; it != itend ; ++it) { - action = &*it; + + CpuTiAction *action = &*it; if (action->getState() == SURF_ACTION_RUNNING || action->getState() == SURF_ACTION_READY || action->getState() == SURF_ACTION_NOT_IN_THE_SYSTEM) { @@ -619,6 +588,7 @@ void CpuTi::updateState(tmgr_trace_iterator_t event_type, } } tmgr_trace_event_unref(&p_stateEvent); + } else { xbt_die("Unknown event!\n"); } @@ -668,7 +638,7 @@ void CpuTi::updateActionsFinishTime(double now) (action->getRemains()) * sum_priority * action->getPriority(); - total_area /= m_speedPeak; + total_area /= p_speed.peak; action->setFinishTime(p_availTrace->solve(now, total_area)); /* verify which event will happen before (max_duration or finish time) */ @@ -710,7 +680,7 @@ bool CpuTi::isUsed() double CpuTi::getAvailableSpeed() { - m_speedScale = p_availTrace->getPowerScale(surf_get_clock()); + p_speed.scale = p_availTrace->getPowerScale(surf_get_clock()); return Cpu::getAvailableSpeed(); } @@ -725,7 +695,7 @@ void CpuTi::updateRemainingAmount(double now) return; /* compute the integration area */ - area_total = p_availTrace->integrate(m_lastUpdate, now) * m_speedPeak; + area_total = p_availTrace->integrate(m_lastUpdate, now) * p_speed.peak; XBT_DEBUG("Flops total: %f, Last update %f", area_total, m_lastUpdate);