Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Quick fix for warnings in compilation induced by fat trees.
[simgrid.git] / src / surf / cpu_cas01.cpp
index 3882724..3c6662d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2011, 2013. The SimGrid Team.
+/* Copyright (c) 2009-2011, 2013-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -17,18 +17,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu,
  * CallBacks *
  *************/
 
-static void parse_cpu_init(sg_platf_host_cbarg_t host){
-  ((CpuCas01ModelPtr)surf_cpu_model_pm)->parseInit(host);
-}
-
-static void cpu_add_traces_cpu(){
-  surf_cpu_model_pm->addTraces();
-}
-
 static void cpu_define_callbacks()
 {
   sg_platf_host_add_cb(parse_cpu_init);
-  sg_platf_postparse_add_cb(cpu_add_traces_cpu);
+  sg_platf_postparse_add_cb(add_traces_cpu);
 }
 
 /*********
@@ -171,7 +163,7 @@ void CpuCas01Model::addTraces()
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
-    host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
+    host->setStateEvent(tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host)));
   }
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
@@ -181,8 +173,7 @@ void CpuCas01Model::addTraces()
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
-    host->p_powerEvent =
-        tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
+    host->setPowerEvent(tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host)));
   }
 }
 
@@ -216,6 +207,25 @@ CpuCas01::~CpuCas01(){
     xbt_dynar_free(&p_powerPeakList);
 }
 
+void CpuCas01::setStateEvent(tmgr_trace_event_t stateEvent)
+{
+  p_stateEvent = stateEvent;
+}
+
+void CpuCas01::setPowerEvent(tmgr_trace_event_t powerEvent)
+{
+  p_powerEvent = powerEvent;
+}
+
+xbt_dynar_t CpuCas01::getPowerPeakList(){
+  return p_powerPeakList;
+}
+
+int CpuCas01::getPState()
+{
+  return m_pstate;
+}
+
 bool CpuCas01::isUsed()
 {
   return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
@@ -297,7 +307,7 @@ CpuActionPtr CpuCas01::execute(double size)
 CpuActionPtr CpuCas01::sleep(double duration)
 {
   if (duration > 0)
-    duration = MAX(duration, MAXMIN_PRECISION);
+    duration = MAX(duration, sg_surf_precision);
 
   XBT_IN("(%s,%g)", getName(), duration);
   CpuCas01ActionPtr action = new CpuCas01Action(getModel(), 1.0, getState() != SURF_RESOURCE_ON,
@@ -366,9 +376,7 @@ CpuCas01Action::CpuCas01Action(ModelPtr model, double cost, bool failed, double
                     lmm_variable_new(model->getMaxminSystem(), static_cast<ActionPtr>(this),
                     1.0, power, 1))
 {
-  m_suspended = 0;     /* Should be useless because of the
-                                                          calloc but it seems to help valgrind... */
-
+  m_suspended = 0;
   if (model->getUpdateMechanism() == UM_LAZY) {
     m_indexHeap = -1;
     m_lastUpdate = surf_get_clock();