Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Un-deprecate MSG_task_get_flops_amount() and implement it correctly
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 8 Dec 2017 21:16:14 +0000 (22:16 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 8 Dec 2017 22:17:36 +0000 (23:17 +0100)
The problem that pushed us into deprecating it is that for parallel tasks,
there is no way that this function can return an amount of flops:
the remaining work is a vector, not a scalar.

So for parallel tasks, you can only get a completion ratio.

Our fix was to rename this into MSG_task_get_remaining_work_ratio(),
but that's ... suboptimal because for sequential tasks, this actually
returns a scalar (the amount of flops) and not a ratio...

So this commit is the first one in a serie of three:
- here, we implement the correct MSG_task_get_flops_amount()
- next we will stop using MSG_task_get_remaining_work_ratio() where we
  expected flops and only keep it where we expected a ratio (ie, in
  the recently added example)
- next, we will make sure that MSG_task_get_remaining_work_ratio()
  always returns a completion ratio, even for sequential tasks.
- next, we can remove the MSG_task_get_initial_flops_amount() that was
  added as a first attempt to fix this mess

Stay tuned :)

include/simgrid/msg.h
src/msg/msg_task.cpp

index b4e5304..959fe86 100644 (file)
@@ -355,10 +355,7 @@ XBT_PUBLIC(msg_error_t) MSG_process_join(msg_process_t process, double timeout);
 XBT_PUBLIC(msg_error_t) MSG_process_sleep(double nb_sec);
 
 XBT_PUBLIC(void) MSG_task_set_flops_amount(msg_task_t task, double flops_amount);
-XBT_ATTRIB_DEPRECATED_v321("Use MSG_task_get_initial_flops_amount if you want to get initial amounts of flops, or "
-                           "Use MSG_task_get_remaining_work_ratio to get task progress (in order "
-                           "to compute progress in flops)") XBT_PUBLIC(double)
-    MSG_task_get_flops_amount(msg_task_t task);
+XBT_PUBLIC(double) MSG_task_get_flops_amount(msg_task_t task);
 XBT_PUBLIC(double) MSG_task_get_initial_flops_amount(msg_task_t task);
 XBT_PUBLIC(double) MSG_task_get_remaining_work_ratio(msg_task_t task);
 XBT_PUBLIC(void) MSG_task_set_bytes_amount(msg_task_t task, double bytes_amount);
index c971394..3b119af 100644 (file)
@@ -251,10 +251,21 @@ double MSG_task_get_remaining_work_ratio(msg_task_t task) {
   }
 }
 
+/** \ingroup m_task_management
+ * \brief Returns the amount of flops that remain to be computed
+ *
+ * The returned value is initially the cost that you defined for the task, then it decreases until it reaches 0
+ *
+ * It works for sequential tasks, but the remaining amount of work is not a scalar value for parallel tasks.
+ * So you will get an exception if you call this function on parallel tasks. Just don't do it.
+ */
 double MSG_task_get_flops_amount(msg_task_t task) {
-  if (task->simdata->compute) {
+  if (task->simdata->compute != nullptr) {
     return task->simdata->compute->remains();
   } else {
+    // Not started or already done.
+    // - Before starting, flops_amount is initially the task cost
+    // - After execution, flops_amount is set to 0 (until someone uses MSG_task_set_flops_amount, if any)
     return task->simdata->flops_amount;
   }
 }