/* 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_by_name(elm)->pimpl_cpu);
+ Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu;
- xbt_assert(host, "Host %s undefined", elm);
+ xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- host->p_stateEvent = future_evt_set->add_trace(trace, 0.0, host);
+ cpu->set_state_trace(trace);
}
xbt_dict_foreach(trace_connect_list_host_speed, 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_by_name(elm)->pimpl_cpu);
+ Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu;
- xbt_assert(host, "Host %s undefined", elm);
+ xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- host->p_speedEvent = future_evt_set->add_trace(trace, 0.0, host);
+ cpu->set_speed_trace(trace);
}
}
************/
class CpuCas01 : public Cpu {
- friend CpuCas01Model;
public:
CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
protected:
void onSpeedChange() override;
-
-private:
-
- tmgr_trace_iterator_t p_stateEvent = nullptr;
- tmgr_trace_iterator_t p_speedEvent = nullptr;
};
/**********
return m_core;
}
+void Cpu::set_state_trace(tmgr_trace_t trace)
+{
+ xbt_assert(p_stateEvent==NULL,"Cannot set a second state trace to Host %s", m_host->name().c_str());
+
+ p_stateEvent = future_evt_set->add_trace(trace, 0.0, this);
+}
+void Cpu::set_speed_trace(tmgr_trace_t trace)
+{
+ xbt_assert(p_speedEvent==NULL,"Cannot set a second speed trace to Host %s", m_host->name().c_str());
+
+ p_speedEvent = future_evt_set->add_trace(trace, 0.0, this);
+}
+
+
/**********
* Action *
**********/
virtual void setPState(int pstate_index);
virtual int getPState();
- void addTraces(void);
simgrid::s4u::Host* getHost() { return m_host; }
public:
lmm_constraint_t *p_constraintCore=NULL;
void **p_constraintCoreId=NULL;
+public:
+ void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF) */
+ void set_speed_trace(tmgr_trace_t trace); /*< setup the trace file with availability events (peak speed changes due to external load) */
+protected:
+ tmgr_trace_iterator_t p_stateEvent = nullptr;
+ tmgr_trace_iterator_t p_speedEvent = nullptr;
};
/**********
/* Connect traces relative to cpu */
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);
- CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
+ Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu;
- xbt_assert(host, "Host %s undefined", elm);
+ xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- host->p_stateEvent = future_evt_set->add_trace(trace, 0.0, host);
+ cpu->set_state_trace(trace);
}
xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
+ Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu;
- xbt_assert(host, "Host %s undefined", elm);
+ xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- host->p_speedEvent = future_evt_set->add_trace(trace, 0.0, host);
+ cpu->set_speed_trace(trace);
}
/* Connect traces relative to network */
************/
class CpuL07 : public Cpu {
- friend void HostL07Model::addTraces();
- tmgr_trace_iterator_t p_stateEvent = nullptr;
- tmgr_trace_iterator_t p_speedEvent = nullptr;
public:
CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate,
double power_scale, tmgr_trace_t power_trace,