Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
implement ExecImpl::remainingRatio and make sure we never call ExecImpl::remaining...
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 8 Dec 2017 21:54:06 +0000 (22:54 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 8 Dec 2017 22:18:21 +0000 (23:18 +0100)
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/msg/msg_task.cpp

index afb1832..5ecdf6a 100644 (file)
@@ -43,7 +43,21 @@ void simgrid::kernel::activity::ExecImpl::resume()
 
 double simgrid::kernel::activity::ExecImpl::remains()
 {
-  return surfAction_->getRemains();
+  if (host_ == nullptr) // parallel task: their remain is not in flops (we'd need a vector to express it this way
+                        // instead of a scalar), but between 0 and 1
+    throw new std::logic_error(
+        "The remaining work on parallel tasks cannot be defined as a scalar amount of flops (it's a vector). "
+        "So parallel_task->remains() is not defined. "
+        "You are probably looking for parallel_task->remainingRatio().");
+  else // sequential task: everything's fine
+    return surfAction_->getRemains();
+}
+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()
index 63e3dcb..e5fe71b 100644 (file)
@@ -23,6 +23,7 @@ public:
   void resume() override;
   void post() override;
   double remains();
+  double remainingRatio();
 
   /* The host where the execution takes place. If nullptr, then this is a parallel exec (and only surf
                   knows the hosts) */
index 3b119af..e31fb10 100644 (file)
@@ -239,12 +239,7 @@ double MSG_task_get_remaining_work_ratio(msg_task_t task) {
   xbt_assert((task != nullptr), "Cannot get information from a nullptr task");
   if (task->simdata->compute) {
     // Task in progress
-    return task->simdata->compute->remains();
-
-  //} else if ((MSG_task_get_flops_amount(task) == 0 and task->simdata->flops_parallel_amount == nullptr) //this is a sequential task
-  //    or (task->simdata->flops_parallel_amount != nullptr and task->simdata->flops_parallel_amount == 0)) {
-  //  // Task finished
-  //  return 1;
+    return task->simdata->compute->remainingRatio();
   } else {
     // Task not started or finished
     return 0;