Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / surf / cpu_interface.cpp
index 6bb195a..ee3fc09 100644 (file)
@@ -24,18 +24,7 @@ namespace surf {
  * Callbacks *
  *************/
 
-std::list<Cpu*> getActionCpus(CpuAction *action) {
-  std::list<Cpu*> retlist;
-  lmm_system_t sys = action->getModel()->getMaxminSystem();
-  int llen = lmm_get_number_of_cnst_from_var(sys, action->getVariable());
-
-  for(int i = 0; i<llen; i++) {
-    retlist.push_back( (Cpu*)(lmm_constraint_id( lmm_get_cnst_from_var(sys, action->getVariable(), i) )) );
-  }
-  return retlist;
-}
-
-simgrid::xbt::signal<void(CpuAction*, e_surf_action_state_t, e_surf_action_state_t)> cpuActionStateChangedCallbacks;
+simgrid::xbt::signal<void(CpuAction*, Action::State, Action::State)> cpuActionStateChangedCallbacks;
 
 /*********
  * Model *
@@ -61,7 +50,7 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
 
     /* set the remains to 0 due to precision problems when updating the remaining amount */
     action->setRemains(0);
-    action->setState(SURF_ACTION_DONE);
+    action->setState(Action::State::done);
     action->heapRemove(getActionHeap()); //FIXME: strange call since action was already popped
   }
   if (TRACE_is_enabled()) {
@@ -117,11 +106,11 @@ void CpuModel::updateActionsStateFull(double now, double delta)
     if ((action->getRemainsNoUpdate() <= 0) &&
         (lmm_get_variable_weight(action->getVariable()) > 0)) {
       action->finish();
-      action->setState(SURF_ACTION_DONE);
+      action->setState(Action::State::done);
     } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
                (action->getMaxDuration() <= 0)) {
       action->finish();
-      action->setState(SURF_ACTION_DONE);
+      action->setState(Action::State::done);
     }
   }
 }
@@ -260,21 +249,21 @@ void CpuAction::updateRemainingLazy(double now)
   xbt_assert(getStateSet() == getModel()->getRunningActionSet(), "You're updating an action that is not running.");
   xbt_assert(getPriority() > 0, "You're updating an action that seems suspended.");
 
-  double delta = now - m_lastUpdate;
+  double delta = now - lastUpdate_;
 
-  if (m_remains > 0) {
-    XBT_CDEBUG(surf_kernel, "Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate);
-    double_update(&(m_remains), m_lastValue * delta, sg_maxmin_precision*sg_surf_precision);
+  if (remains_ > 0) {
+    XBT_CDEBUG(surf_kernel, "Updating action(%p): remains was %f, last_update was: %f", this, remains_, lastUpdate_);
+    double_update(&(remains_), lastValue_ * delta, sg_maxmin_precision*sg_surf_precision);
 
     if (TRACE_is_enabled()) {
       Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
-      TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate);
+      TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_);
     }
-    XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %f", this, m_remains);
+    XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %f", this, remains_);
   }
 
-  m_lastUpdate = now;
-  m_lastValue = lmm_variable_getvalue(getVariable());
+  lastUpdate_ = now;
+  lastValue_ = lmm_variable_getvalue(getVariable());
 }
 
 /*
@@ -341,13 +330,23 @@ void CpuAction::setAffinity(Cpu *cpu, unsigned long mask)
   XBT_OUT();
 }
 
-simgrid::xbt::signal<void(simgrid::surf::CpuAction*, e_surf_action_state_t)> CpuAction::onStateChange;
+simgrid::xbt::signal<void(simgrid::surf::CpuAction*, Action::State)> CpuAction::onStateChange;
 
-void CpuAction::setState(e_surf_action_state_t state){
-  e_surf_action_state_t previous = getState();
+void CpuAction::setState(Action::State state){
+  Action::State previous = getState();
   Action::setState(state);
   onStateChange(this, previous);
 }
+std::list<Cpu*> CpuAction::cpus() {
+  std::list<Cpu*> retlist;
+  lmm_system_t sys = getModel()->getMaxminSystem();
+  int llen = lmm_get_number_of_cnst_from_var(sys, getVariable());
+
+  for(int i = 0; i<llen; i++)
+    retlist.push_back( (Cpu*)(lmm_constraint_id( lmm_get_cnst_from_var(sys, getVariable(), i) )) );
+
+  return retlist;
+}
 
 }
 }