XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_ti, surf_cpu,
"Logging specific to the SURF CPU TRACE INTEGRATION module");
-static void cpu_ti_action_update_index_heap(void *action, int i);
+namespace simgrid {
+namespace surf {
+
+static inline
+void cpu_ti_action_update_index_heap(void *action, int i)
+{
+ ((simgrid::surf::CpuTiAction*)action)->updateIndexHeap(i);
+}
/*********
* Trace *
return low;
}
+}
+}
+
/*************
* CallBacks *
*************/
static void cpu_ti_define_callbacks()
{
- sg_platf_postparse_add_cb(cpu_add_traces);
+ sg_platf_postparse_add_cb(simgrid::surf::cpu_add_traces);
}
/*********
xbt_assert(!surf_cpu_model_pm,"CPU model already initialized. This should not happen.");
xbt_assert(!surf_cpu_model_vm,"CPU model already initialized. This should not happen.");
- surf_cpu_model_pm = new CpuTiModel();
- surf_cpu_model_vm = new CpuTiModel();
+ surf_cpu_model_pm = new simgrid::surf::CpuTiModel();
+ surf_cpu_model_vm = new simgrid::surf::CpuTiModel();
cpu_ti_define_callbacks();
- Model *model_pm = static_cast<Model*>(surf_cpu_model_pm);
- Model *model_vm = static_cast<Model*>(surf_cpu_model_vm);
+ simgrid::surf::Model *model_pm = static_cast<simgrid::surf::Model*>(surf_cpu_model_pm);
+ simgrid::surf::Model *model_vm = static_cast<simgrid::surf::Model*>(surf_cpu_model_vm);
xbt_dynar_push(all_existing_models, &model_pm);
xbt_dynar_push(all_existing_models, &model_vm);
}
+namespace simgrid {
+namespace surf {
+
CpuTiModel::CpuTiModel() : CpuModel()
{
p_runningActionSetThatDoesNotNeedBeingChecked = new ActionList();
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,
tmgr_trace_t speedTrace,
int core,
e_surf_resource_state_t stateInitial,
- tmgr_trace_t stateTrace,
- xbt_dict_t cpuProperties)
+ tmgr_trace_t stateTrace)
{
xbt_assert(core==1,"Multi-core not handled with this model yet");
- sg_host_t host = sg_host_by_name(name);
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,
- core, stateInitial, stateTrace, cpuProperties);
- sg_host_surfcpu_register(host, cpu);
+ CpuTi *cpu = new CpuTi(this, host, speedPeak, pstate, speedScale, speedTrace,
+ core, stateInitial, stateTrace);
return cpu;
}
/* 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);
- CpuTi *cpu = static_cast<CpuTi*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuTi *cpu = static_cast<CpuTi*>(sg_host_surfcpu(sg_host_by_name(elm)));
+ CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->p_cpu);
xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
/************
* 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,
- xbt_dict_t properties)
- : Cpu(model, name, properties, core, 0, speedScale, stateInitial)
+ e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace)
+ : Cpu(model, host, NULL, pstate, core, 0, speedScale, stateInitial)
{
p_speedEvent = NULL;
m_speedScale = speedScale;
}
};
-CpuTi::~CpuTi(){
+CpuTi::~CpuTi()
+{
modified(false);
delete p_availTrace;
delete p_actionSet;
* Action *
**********/
-static void cpu_ti_action_update_index_heap(void *action, int i)
-{
-((CpuTiAction*)action)->updateIndexHeap(i);
-}
-
CpuTiAction::CpuTiAction(CpuTiModel *model_, double cost, bool failed,
CpuTi *cpu)
: CpuAction(model_, cost, failed)
{
- m_suspended = 0; /* Should be useless because of the
- calloc but it seems to help valgrind... */
p_cpu = cpu;
m_indexHeap = -1;
p_cpu->modified(true);
return m_remains;
}
-#endif /* SURF_MODEL_CPUTI_H_ */
+}
+}
+#endif /* SURF_MODEL_CPUTI_H_ */