xbt_assert(xbt_dynar_getfirst_as(power_peak, double) > 0.0,
"Power has to be >0.0. Did you forget to specify the mandatory power attribute?");
xbt_assert(core > 0, "Invalid number of cores %d. Must be larger than 0", core);
cpu = new CpuCas01(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
xbt_assert(xbt_dynar_getfirst_as(power_peak, double) > 0.0,
"Power has to be >0.0. Did you forget to specify the mandatory power attribute?");
xbt_assert(core > 0, "Invalid number of cores %d. Must be larger than 0", core);
cpu = new CpuCas01(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
- surf_callback_emit(cpuCreatedCallbacks, cpu);
- surf_callback_emit(cpuStateChangedCallbacks, cpu, SURF_RESOURCE_ON, state_initial);
- sg_host_surfcpu_set(host, cpu);
-
+ sg_host_surfcpu_register(host, cpu);
lmm_constraint_new(model->getMaxminSystem(), this, core * powerScale * xbt_dynar_get_as(powerPeak, pstate, double)),
core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale,
stateInitial) {
lmm_constraint_new(model->getMaxminSystem(), this, core * powerScale * xbt_dynar_get_as(powerPeak, pstate, double)),
core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale,
stateInitial) {
- p_powerEvent = NULL;
- p_powerPeakList = powerPeak;
+ p_speedEvent = NULL;
+
+ // Copy the power peak array:
+ p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr);
+ unsigned long n = xbt_dynar_length(powerPeak);
+ for (unsigned long i = 0; i != n; ++i) {
+ double value = xbt_dynar_get_as(powerPeak, i, double);
+ xbt_dynar_push(p_speedPeakList, &value);
+ }
+
- XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
+ XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_speedPeak, m_pstate);
- p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, this);
+ p_speedEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, this);
if (stateTrace)
p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, this);
if (stateTrace)
p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, this);
/* TODO (Hypervisor): do the same thing for constraint_core[i] */
xbt_assert(m_core == 1, "FIXME: add power scaling code also for constraint_core[i]");
/* TODO (Hypervisor): do the same thing for constraint_core[i] */
xbt_assert(m_core == 1, "FIXME: add power scaling code also for constraint_core[i]");
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(),
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(),
} else if (event_type == p_stateEvent) {
/* TODO (Hypervisor): do the same thing for constraint_core[i] */
xbt_assert(m_core == 1, "FIXME: add state change code also for constraint_core[i]");
} else if (event_type == p_stateEvent) {
/* TODO (Hypervisor): do the same thing for constraint_core[i] */
xbt_assert(m_core == 1, "FIXME: add state change code also for constraint_core[i]");
XBT_IN("(%s,%g)", getName(), size);
CpuCas01Action *action = new CpuCas01Action(getModel(), size, getState() != SURF_RESOURCE_ON,
XBT_IN("(%s,%g)", getName(), size);
CpuCas01Action *action = new CpuCas01Action(getModel(), size, getState() != SURF_RESOURCE_ON,
XBT_IN("(%s,%g)", getName(), duration);
CpuCas01Action *action = new CpuCas01Action(getModel(), 1.0, getState() != SURF_RESOURCE_ON,
XBT_IN("(%s,%g)", getName(), duration);
CpuCas01Action *action = new CpuCas01Action(getModel(), 1.0, getState() != SURF_RESOURCE_ON,
xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
return xbt_dynar_get_as(plist, pstate_index, double);
xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
return xbt_dynar_get_as(plist, pstate_index, double);
xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
double new_pstate = xbt_dynar_get_as(plist, pstate_index, double);
m_pstate = pstate_index;
xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
double new_pstate = xbt_dynar_get_as(plist, pstate_index, double);
m_pstate = pstate_index;