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()
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;