X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f4ed74ca6d4a744d2956a4f2906c897e1886cefd..ae7bffe6655b934fc4a09ca1a34e10de5d8dd366:/src/surf/cpu_cas01.cpp diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index d7a4faf622..a8412b0975 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2011, 2013-2014. The SimGrid Team. +/* Copyright (c) 2009-2011, 2013-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -30,13 +30,12 @@ void surf_cpu_model_init_Cas01() surf_cpu_model_pm = new CpuCas01Model(); surf_cpu_model_vm = new CpuCas01Model(); - sg_platf_host_add_cb(cpu_parse_init); sg_platf_postparse_add_cb(cpu_add_traces); Model *model_pm = surf_cpu_model_pm; Model *model_vm = surf_cpu_model_vm; - xbt_dynar_push(model_list, &model_pm); - xbt_dynar_push(model_list, &model_vm); + xbt_dynar_push(all_existing_models, &model_pm); + xbt_dynar_push(all_existing_models, &model_vm); } CpuCas01Model::CpuCas01Model() : CpuModel() @@ -106,16 +105,12 @@ Cpu *CpuCas01Model::createCpu(const char *name, xbt_dynar_t power_peak, { Cpu *cpu = NULL; sg_host_t host = sg_host_by_name(name); - xbt_assert(!sg_host_surfcpu(host), - "Host '%s' declared several times in the platform file", - name); 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); - sg_host_surfcpu_set(host, cpu); - + sg_host_surfcpu_register(host, cpu); return cpu; } @@ -165,15 +160,23 @@ CpuCas01::CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t powerPeak xbt_dict_t properties) : Cpu(model, name, properties, lmm_constraint_new(model->getMaxminSystem(), this, core * powerScale * xbt_dynar_get_as(powerPeak, pstate, double)), - core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale) { + core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale, + stateInitial) { p_powerEvent = NULL; - p_powerPeakList = powerPeak; + + // Copy the power peak array: + p_powerPeakList = 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_powerPeakList, &value); + } + m_pstate = pstate; XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate); m_core = core; - setState(stateInitial); if (powerTrace) p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, this);