Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
this is actually an example of exec, no link to energy things
[simgrid.git] / src / kernel / activity / ExecImpl.cpp
index afb1832eedca6d8d043def1f78900e5a42bdba32..6c0cf00c5891a241d174e12792bc7b274e089667 100644 (file)
@@ -43,7 +43,18 @@ void simgrid::kernel::activity::ExecImpl::resume()
 
 double simgrid::kernel::activity::ExecImpl::remains()
 {
-  return surfAction_->getRemains();
+  xbt_assert(host_ != nullptr, "Calling remains() on a parallel execution is not allowed. "
+                               "We would need to return a vector instead of a scalar. "
+                               "Did you meant remainingRatio() instead?");
+
+  return surfAction_ ? surfAction_->getRemains() : 0;
+}
+double simgrid::kernel::activity::ExecImpl::remainingRatio()
+{
+  if (host_ == nullptr) // parallel task: their remain is already between 0 and 1 (see comment in ExecImpl::remains())
+    return surfAction_->getRemains();
+  else // Actually compute the ratio for sequential tasks
+    return surfAction_->getRemains() / surfAction_->getCost();
 }
 
 void simgrid::kernel::activity::ExecImpl::post()