delete p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
}
-Cpu *CpuCas01Model::createCpu(const char *name, xbt_dynar_t speedPeak,
+Cpu *CpuCas01Model::createCpu(simgrid::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale,
tmgr_trace_t speedTrace, int core,
e_surf_resource_state_t state_initial,
xbt_assert(xbt_dynar_getfirst_as(speedPeak, double) > 0.0,
"Speed 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 *cpu = new CpuCas01(this, name, speedPeak, pstate, speedScale, speedTrace, core, state_initial, state_trace);
+ Cpu *cpu = new CpuCas01(this, host, speedPeak, pstate, speedScale, speedTrace, core, state_initial, state_trace);
return cpu;
}
/************
* Resource *
************/
-CpuCas01::CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t speedPeak,
+CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace)
-: Cpu(model, name,
+: Cpu(model, host,
lmm_constraint_new(model->getMaxminSystem(), this, core * speedScale * xbt_dynar_get_as(speedPeak, pstate, double)),
core, xbt_dynar_get_as(speedPeak, pstate, double), speedScale,
stateInitial) {
double (CpuCas01Model::*shareResources)(double now);
void (CpuCas01Model::*updateActionsState)(double now, double delta);
- Cpu *createCpu(const char *name, xbt_dynar_t speedPeak, int pstate,
+ Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeak, int pstate,
double speedScale,
tmgr_trace_t speedTrace, int core,
e_surf_resource_state_t state_initial,
class CpuCas01 : public Cpu {
public:
- CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t speedPeak,
+ CpuCas01(CpuCas01Model *model, simgrid::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace) ;
~CpuCas01();
}
-Cpu::Cpu(Model *model, const char *name,
+Cpu::Cpu(Model *model, simgrid::Host *host,
int core, double speedPeak, double speedScale,
e_surf_resource_state_t stateInitial)
- : Resource(model, name, stateInitial)
+ : Resource(model, host->getName().c_str(), stateInitial)
, m_core(core)
, m_speedPeak(speedPeak)
, m_speedScale(speedScale)
+ , m_host(host)
{
}
-Cpu::Cpu(Model *model, const char *name,
+Cpu::Cpu(Model *model, simgrid::Host *host,
lmm_constraint_t constraint, int core, double speedPeak,
double speedScale, e_surf_resource_state_t stateInitial)
- : Resource(model, name, constraint, stateInitial)
+ : Resource(model, host->getName().c_str(), constraint, stateInitial)
, m_core(core)
, m_speedPeak(speedPeak)
, m_speedScale(speedScale)
+ , m_host(host)
{
- /* At now, we assume that a VM does not have a multicore CPU. */
+ /* Currently, we assume that a VM does not have a multicore CPU. */
if (core > 1)
xbt_assert(model == surf_cpu_model_pm);
int i;
for (i = 0; i < core; i++) {
/* just for a unique id, never used as a string. */
- p_constraintCoreId[i] = bprintf("%s:%i", name, i);
+ p_constraintCoreId[i] = bprintf("%s:%i", host->getName().c_str(), i);
p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], m_speedScale * m_speedPeak);
}
}
}
-Cpu::Cpu(Model *model, const char *name,
+Cpu::Cpu(Model *model, simgrid::Host *host,
lmm_constraint_t constraint, int core, double speedPeak, double speedScale)
-: Cpu(model, name, constraint, core, speedPeak, speedScale, SURF_RESOURCE_ON)
+: Cpu(model, host, constraint, core, speedPeak, speedScale, SURF_RESOURCE_ON)
{}
-Cpu::Cpu(Model *model, const char *name,
+Cpu::Cpu(Model *model, simgrid::Host *host,
int core, double speedPeak, double speedScale)
-: Cpu(model, name, core, speedPeak, speedScale, SURF_RESOURCE_ON)
+: Cpu(model, host, core, speedPeak, speedScale, SURF_RESOURCE_ON)
{}
Cpu::~Cpu()
return m_core;
}
-void Cpu::plug(simgrid::Host* host)
-{
- if (this->m_host != nullptr)
- xbt_die("Already plugged into host %s", host->getName().c_str());
- host->extension_set(this);
- this->m_host = host;
-}
-
/**********
* Action *
**********/
* @param state_initial [TODO]
* @param state_trace [TODO]
*/
- virtual Cpu *createCpu(const char *name, xbt_dynar_t speedPeak,
+ virtual Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale,
tmgr_trace_t speedTrace, int core,
e_surf_resource_state_t state_initial,
* @brief Cpu constructor
*
* @param model The CpuModel associated to this Cpu
- * @param name The name of the Cpu
+ * @param host The host in which this Cpu should be plugged
* @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component
* @param core The number of core of this Cpu
* @param speedPeak The speed peak of this Cpu in flops (max speed)
* @param speedScale The speed scale of this Cpu in [0;1] (available amount)
* @param stateInitial whether it is created running or crashed
*/
- Cpu(simgrid::surf::Model *model, const char *name,
+ Cpu(simgrid::surf::Model *model, simgrid::Host *host,
lmm_constraint_t constraint, int core, double speedPeak, double speedScale,
e_surf_resource_state_t stateInitial);
* @brief Cpu constructor
*
* @param model The CpuModel associated to this Cpu
- * @param name The name of the Cpu
+ * @param host The host in which this Cpu should be plugged
* @param core The number of core of this Cpu
* @param speedPeak The speed peak of this Cpu in flops (max speed)
* @param speedScale The speed scale of this Cpu in [0;1] (available amount)
* @param stateInitial whether it is created running or crashed
*/
- Cpu(simgrid::surf::Model *model, const char *name,
+ Cpu(simgrid::surf::Model *model, simgrid::Host *host,
int core, double speedPeak, double speedScale,
e_surf_resource_state_t stateInitial);
- Cpu(simgrid::surf::Model *model, const char *name,
+ Cpu(simgrid::surf::Model *model, simgrid::Host *host,
lmm_constraint_t constraint, int core, double speedPeak, double speedScale);
- Cpu(simgrid::surf::Model *model, const char *name,
+ Cpu(simgrid::surf::Model *model, simgrid::Host *host,
int core, double speedPeak, double speedScale);
~Cpu();
virtual void setPstate(int pstate_index)=0;
virtual int getPstate()=0;
- void plug(simgrid::Host* host);
-
void addTraces(void);
simgrid::Host* getHost() { return m_host; }
int m_core = 1; /* Amount of cores */
double m_speedPeak; /*< CPU speed peak, ie max value */
double m_speedScale; /*< Percentage of CPU available according to the trace, in [O,1] */
- simgrid::Host* m_host = nullptr;
+ simgrid::Host* m_host;
/* Note (hypervisor): */
lmm_constraint_t *p_constraintCore=NULL;
xbt_heap_free(p_tiActionHeap);
}
-Cpu *CpuTiModel::createCpu(const char *name,
+Cpu *CpuTiModel::createCpu(simgrid::Host *host,
xbt_dynar_t speedPeak,
int pstate,
double speedScale,
xbt_assert(core==1,"Multi-core not handled with this model yet");
xbt_assert(xbt_dynar_getfirst_as(speedPeak, double) > 0.0,
"Speed has to be >0.0. Did you forget to specify the mandatory speed attribute?");
- CpuTi *cpu = new CpuTi(this, name, speedPeak, pstate, speedScale, speedTrace,
+ CpuTi *cpu = new CpuTi(this, host, speedPeak, pstate, speedScale, speedTrace,
core, stateInitial, stateTrace);
return cpu;
}
/************
* Resource *
************/
-CpuTi::CpuTi(CpuTiModel *model, const char *name, xbt_dynar_t speedPeak,
+CpuTi::CpuTi(CpuTiModel *model, simgrid::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace)
- : Cpu(model, name, core, 0, speedScale, stateInitial)
+ : Cpu(model, host, core, 0, speedScale, stateInitial)
{
p_speedEvent = NULL;
m_speedScale = speedScale;
class CpuTi : public Cpu {
public:
CpuTi() {};
- CpuTi(CpuTiModel *model, const char *name, xbt_dynar_t speedPeak,
+ CpuTi(CpuTiModel *model, simgrid::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace) ;
~CpuTi();
public:
CpuTiModel();
~CpuTiModel();
- Cpu *createCpu(const char *name, xbt_dynar_t speedPeak,
+ Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale,
tmgr_trace_t speedTrace, int core,
e_surf_resource_state_t state_initial,
return res;
}
-Cpu *CpuL07Model::createCpu(const char *name, xbt_dynar_t powerPeak,
+Cpu *CpuL07Model::createCpu(simgrid::Host *host, xbt_dynar_t powerPeak,
int pstate, double power_scale,
tmgr_trace_t power_trace, int core,
e_surf_resource_state_t state_initial,
tmgr_trace_t state_trace)
{
double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
- CpuL07 *cpu = new CpuL07(this, name, power_initial, power_scale, power_trace,
+ CpuL07 *cpu = new CpuL07(this, host, power_initial, power_scale, power_trace,
core, state_initial, state_trace);
return cpu;
}
/************
* Resource *
************/
-CpuL07::CpuL07(CpuL07Model *model, const char* name,
+CpuL07::CpuL07(CpuL07Model *model, simgrid::Host *host,
double speedInitial, double speedScale, tmgr_trace_t speedTrace,
int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
- : Cpu(model, name, lmm_constraint_new(ptask_maxmin_system, this, speedInitial * speedScale),
+ : Cpu(model, host, lmm_constraint_new(ptask_maxmin_system, this, speedInitial * speedScale),
core, speedInitial, speedScale, state_initial)
{
xbt_assert(m_speedScale > 0, "Power has to be >0");
CpuL07Model(HostL07Model *hmodel) : CpuModel() {p_hostModel = hmodel;};
~CpuL07Model() {surf_cpu_model_pm = NULL;};
- Cpu *createCpu(const char *name, xbt_dynar_t speedPeak,
+ Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale,
tmgr_trace_t speedTrace, int core,
e_surf_resource_state_t state_initial,
tmgr_trace_event_t p_stateEvent;
tmgr_trace_event_t p_speedEvent;
public:
- CpuL07(CpuL07Model *model, const char* name,
+ CpuL07(CpuL07Model *model, simgrid::Host *host,
double power_scale, double power_initial, tmgr_trace_t power_trace,
int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
~CpuL07();
sg_host_t h = simgrid::Host::by_name_or_create(host->id);
simgrid::surf::Cpu *cpu = surf_cpu_model_pm->createCpu(
- host->id,
+ h,
host->speed_peak,
host->pstate,
host->speed_scale,
host->core_amount,
host->initial_state,
host->state_trace);
- cpu->plug(h);
surf_host_model->createHost(host->id, net, cpu, host->properties)->attach(h);
if (TRACE_is_enabled() && TRACE_needs_platform())
sg_instr_new_host(host);
// Roughly, create a vcpu resource by using the values of the sub_cpu one.
CpuCas01 *sub_cpu = static_cast<CpuCas01*>(sg_host_surfcpu(host_PM));
- p_cpu = surf_cpu_model_vm->createCpu(name, // name
+ p_cpu = surf_cpu_model_vm->createCpu(host, // the machine hosting the VM
sub_cpu->getSpeedPeakList(), // host->power_peak,
sub_cpu->getPState(),
1, // host->power_scale,
1, // host->core_amount,
SURF_RESOURCE_ON, // host->initial_state,
NULL); // host->state_trace,
- p_cpu->plug(host);
/* We create cpu_action corresponding to a VM process on the host operating system. */
/* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */