-/* Copyright (c) 2009-2011, 2013-2015. The SimGrid Team.
+/* Copyright (c) 2009-2011, 2013-2016. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
*********/
void surf_cpu_model_init_Cas01()
{
- char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
-
xbt_assert(!surf_cpu_model_pm);
xbt_assert(!surf_cpu_model_vm);
+ char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
if (!strcmp(optim, "TI")) {
surf_cpu_model_init_ti();
return;
}
surf_cpu_model_pm = new simgrid::surf::CpuCas01Model();
+ xbt_dynar_push(all_existing_models, &surf_cpu_model_pm);
+
surf_cpu_model_vm = new simgrid::surf::CpuCas01Model();
+ xbt_dynar_push(all_existing_models, &surf_cpu_model_vm);
sg_platf_postparse_add_cb(simgrid::surf::cpu_add_traces);
-
- simgrid::surf::Model *model_pm = surf_cpu_model_pm;
- simgrid::surf::Model *model_vm = surf_cpu_model_vm;
- xbt_dynar_push(all_existing_models, &model_pm);
- xbt_dynar_push(all_existing_models, &model_vm);
}
namespace simgrid {
p_cpuRunningActionSetThatDoesNotNeedBeingChecked = new ActionList();
- if (getUpdateMechanism() == UM_LAZY) {
- shareResources = &CpuCas01Model::shareResourcesLazy;
- updateActionsState = &CpuCas01Model::updateActionsStateLazy;
-
- } else if (getUpdateMechanism() == UM_FULL) {
- shareResources = &CpuCas01Model::shareResourcesFull;
- updateActionsState = &CpuCas01Model::updateActionsStateFull;
- } else
- xbt_die("Invalid cpu update mechanism!");
-
- if (!p_maxminSystem) {
- p_maxminSystem = lmm_system_new(m_selectiveUpdate);
- }
+ p_maxminSystem = lmm_system_new(m_selectiveUpdate);
if (getUpdateMechanism() == UM_LAZY) {
p_actionHeap = xbt_heap_new(8, NULL);
/* 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);
- CpuCas01 *host = static_cast<CpuCas01*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
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);
- CpuCas01 *host = static_cast<CpuCas01*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
}
+/** @brief take into account changes of speed (either load or max) */
+void CpuCas01::onSpeedChange() {
+ lmm_variable_t var = NULL;
+ lmm_element_t elem = NULL;
+
+ lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(),
+ m_core * m_speedScale * m_speedPeak);
+ while ((var = lmm_get_var_from_cnst
+ (getModel()->getMaxminSystem(), getConstraint(), &elem))) {
+ CpuCas01Action *action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
+
+ lmm_update_variable_bound(getModel()->getMaxminSystem(),
+ action->getVariable(),
+ m_speedScale * m_speedPeak);
+ }
+
+ Cpu::onSpeedChange();
+}
+
void CpuCas01::updateState(tmgr_trace_event_t event_type, double value, double date)
{
lmm_variable_t var = NULL;
xbt_assert(m_core == 1, "FIXME: add speed scaling code also for constraint_core[i]");
m_speedScale = value;
- lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(),
- m_core * m_speedScale *
- m_speedPeak);
- TRACE_surf_host_set_speed(date, getName(),
- m_core * m_speedScale *
- m_speedPeak);
- while ((var = lmm_get_var_from_cnst
- (getModel()->getMaxminSystem(), getConstraint(), &elem))) {
- CpuCas01Action *action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
+ onSpeedChange();
- lmm_update_variable_bound(getModel()->getMaxminSystem(),
- action->getVariable(),
- m_speedScale * m_speedPeak);
- }
if (tmgr_trace_event_free(event_type))
p_speedEvent = NULL;
} else if (event_type == p_stateEvent) {
return action;
}
-double CpuCas01::getCurrentPowerPeak()
-{
- return m_speedPeak;
-}
-
/**********
* Action *
**********/