-Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint,
- xbt_dynar_t speedPeakList, int pstate,
- int core, double speedPeak,
- double speedScale, int initiallyOn)
- : Resource(model, host->name().c_str(), constraint, initiallyOn)
- , m_core(core)
- , m_host(host)
-{
- p_speed.peak = speedPeak;
- p_speed.scale = speedScale;
- host->pimpl_cpu = this;
- xbt_assert(p_speed.scale > 0, "Available speed has to be >0");
-
- // Copy the power peak array:
- p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr);
- unsigned long n = xbt_dynar_length(speedPeakList);
- for (unsigned long i = 0; i != n; ++i) {
- double value = xbt_dynar_get_as(speedPeakList, i, double);
- xbt_dynar_push(p_speedPeakList, &value);
- }
-
- m_pstate = pstate;
-
- /* Currently, we assume that a VM does not have a multicore CPU. */
- if (core > 1)
- xbt_assert(model == surf_cpu_model_pm);
-
- if (model->getUpdateMechanism() != UM_UNDEFINED) {
- p_constraintCore = xbt_new(lmm_constraint_t, core);
- p_constraintCoreId = xbt_new(void*, core);
-
- int i;
- for (i = 0; i < core; i++) {
- /* just for a unique id, never used as a string. */
- p_constraintCoreId[i] = bprintf("%s:%i", host->name().c_str(), i);
- p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], p_speed.scale * p_speed.peak);
- }
- }
-}
-
-Cpu::~Cpu()
+Cpu::Cpu(Model* model, s4u::Host* host, lmm::Constraint* constraint, const std::vector<double>& speed_per_pstate,
+ int core)
+ : Resource(model, host->get_cname(), constraint)
+ , core_count_(core)
+ , host_(host)
+ , speed_per_pstate_(speed_per_pstate)