Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
CPU factors: dynamic factors for CPU
[simgrid.git] / src / surf / cpu_cas01.cpp
index 88aab66..b3b215b 100644 (file)
@@ -154,6 +154,9 @@ CpuAction* CpuCas01::execution_start(double size, int requested_cores, double us
   if (user_bound > 0 && user_bound < action->get_bound()) {
     get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), user_bound);
   }
+  if (factor_cb_) {
+    action->set_rate_factor(factor_cb_(size));
+  }
 
   return action;
 }
@@ -184,6 +187,12 @@ CpuAction* CpuCas01::sleep(double duration)
   return action;
 }
 
+void CpuCas01::set_factor_cb(const std::function<s4u::Host::CpuFactorCb>& cb)
+{
+  xbt_assert(not is_sealed(), "Cannot set CPU factor callback in an already sealed CPU(%s)", get_cname());
+  factor_cb_ = cb;
+}
+
 /**********
  * Action *
  **********/