Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Interface cleanup
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 5 Apr 2015 13:32:33 +0000 (15:32 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 5 Apr 2015 13:32:33 +0000 (15:32 +0200)
Merge Task.getRemainingDuration() and Task.getComputeDuration() into
Task.getFlopsAmount() in both C and Java (lua not done yet)

14 files changed:
ChangeLog
examples/java/cloud/migration/Daemon.java
examples/msg/cloud/bound.c
examples/msg/cloud/multicore.c
examples/msg/cloud/two_tasks_vm.c
examples/msg/tracing/ms.c
include/simgrid/msg.h
src/bindings/java/jmsg_task.c
src/bindings/java/jmsg_task.h
src/bindings/java/org/simgrid/msg/Task.java
src/bindings/lua/lua_task.c
src/msg/msg_task.c
src/msg/msg_vm.c
teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c

index 5aa44d4..4a7be35 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,14 +3,18 @@ SimGrid (3.12) NOT RELEASED; urgency=low
  cMSG:
  * Interface improvement:
    - Rename MSG_host_is_avail(h) to MSG_host_is_on(h)
  cMSG:
  * Interface improvement:
    - Rename MSG_host_is_avail(h) to MSG_host_is_on(h)
-   - Rename MSG_task_set_compute_duration(t) to MSG_task_set_flops_amount(t)
-   - Rename MSG_task_set_data_size(t) to MSG_task_set_bytes_amount(t)
-     Rename MSG_task_get_data_size(t) to MSG_task_get_bytes_amount(t)
+   - Sanitize the interface in MSG_task_ module:
+     - Merge two functions that were close enough but misleading:
+       set_compute_duration(t)      -> set_flops_amount(t)
+       get_remaining_computation(t) -> set_flops_amount(t)
+     - set_data_size(t) -> set_bytes_amount(t)
+       get_data_size(t) -> get_bytes_amount(t)
    - Massive cleanups in the functions related to the energy
  jMSG:
  * Interface improvement:
    - Rename Host.isAvail() to Host.isOn()
    - Rename Process.currentProcess() to Process.getCurrentProcess()
    - Massive cleanups in the functions related to the energy
  jMSG:
  * Interface improvement:
    - Rename Host.isAvail() to Host.isOn()
    - Rename Process.currentProcess() to Process.getCurrentProcess()
+   - Merge Task.getRemainingDuration() and Task.getComputeDuration() into Task.getFlopsAmount()
    
  SIMIX:
  * New functions
    
  SIMIX:
  * New functions
index 80cf2a8..68a31f3 100644 (file)
@@ -33,6 +33,6 @@ public class Daemon extends Process {
     }
 
     public double getRemaining(){
     }
 
     public double getRemaining(){
-        return this.currentTask.getRemainingDuration();
-    }
+        return this.currentTask.getFlopsAmount();
     }
     }
+}
index 1eba3d4..d9c6adc 100644 (file)
@@ -92,8 +92,8 @@ static void test_dynamic_change(void)
   msg_process_t pr1 = MSG_process_create("worker1", worker_busy_loop_main, &task1, vm1);
 
 
   msg_process_t pr1 = MSG_process_create("worker1", worker_busy_loop_main, &task1, vm1);
 
 
-  double task0_remain_prev = MSG_task_get_remaining_computation(task0);
-  double task1_remain_prev = MSG_task_get_remaining_computation(task1);
+  double task0_remain_prev = MSG_task_get_flops_amount(task0);
+  double task1_remain_prev = MSG_task_get_flops_amount(task1);
 
   {
     const double cpu_speed = MSG_get_host_speed(pm0);
 
   {
     const double cpu_speed = MSG_get_host_speed(pm0);
@@ -104,8 +104,8 @@ static void test_dynamic_change(void)
       MSG_vm_set_bound(vm1, new_bound);
       MSG_process_sleep(100);
 
       MSG_vm_set_bound(vm1, new_bound);
       MSG_process_sleep(100);
 
-      double task0_remain_now = MSG_task_get_remaining_computation(task0);
-      double task1_remain_now = MSG_task_get_remaining_computation(task1);
+      double task0_remain_now = MSG_task_get_flops_amount(task0);
+      double task1_remain_now = MSG_task_get_flops_amount(task1);
 
       double task0_flops_per_sec = task0_remain_prev - task0_remain_now;
       double task1_flops_per_sec = task1_remain_prev - task1_remain_now;
 
       double task0_flops_per_sec = task0_remain_prev - task0_remain_now;
       double task1_flops_per_sec = task1_remain_prev - task1_remain_now;
index efdb510..8fb26bf 100644 (file)
@@ -37,14 +37,14 @@ struct task_data {
 
 static void task_data_init_clock(struct task_data *t)
 {
 
 static void task_data_init_clock(struct task_data *t)
 {
-  t->prev_computation_amount = MSG_task_get_remaining_computation(t->task);
+  t->prev_computation_amount = MSG_task_get_flops_amount(t->task);
   t->prev_clock = MSG_get_clock();
 }
 
 
 static void task_data_get_clock(struct task_data *t)
 {
   t->prev_clock = MSG_get_clock();
 }
 
 
 static void task_data_get_clock(struct task_data *t)
 {
-  double now_computation_amount = MSG_task_get_remaining_computation(t->task);
+  double now_computation_amount = MSG_task_get_flops_amount(t->task);
   double now_clock = MSG_get_clock();
 
   double done = t->prev_computation_amount - now_computation_amount;
   double now_clock = MSG_get_clock();
 
   double done = t->prev_computation_amount - now_computation_amount;
index 489c90e..a7d61c3 100644 (file)
@@ -71,7 +71,7 @@ static int master_main(int argc, char *argv[])
 
   while(MSG_get_clock()<100) {
        if (atask != NULL)
 
   while(MSG_get_clock()<100) {
        if (atask != NULL)
-         XBT_INFO("aTask remaining duration: %g", MSG_task_get_remaining_computation(atask));
+         XBT_INFO("aTask remaining duration: %g", MSG_task_get_flops_amount(atask));
        MSG_process_sleep(1);
   }
 
        MSG_process_sleep(1);
   }
 
index 9d6e654..52a45c6 100644 (file)
@@ -88,7 +88,7 @@ int slave(int argc, char *argv[])
     //to the variable "task_computation"
     TRACE_host_variable_add(MSG_host_get_name(MSG_host_self()),
                             "task_computation",
     //to the variable "task_computation"
     TRACE_host_variable_add(MSG_host_get_name(MSG_host_self()),
                             "task_computation",
-                            MSG_task_get_compute_duration(task));
+                            MSG_task_get_flops_amount(task));
     MSG_task_execute(task);
     MSG_task_destroy(task);
     task = NULL;
     MSG_task_execute(task);
     MSG_task_destroy(task);
     task = NULL;
index 264a16e..4193fd2 100644 (file)
@@ -444,13 +444,12 @@ XBT_PUBLIC(void) MSG_task_set_affinity(msg_task_t task, msg_host_t host, unsigne
 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(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(double) MSG_task_get_compute_duration(msg_task_t task);
 XBT_PUBLIC(void) MSG_task_set_flops_amount(msg_task_t task,
                                                double flops_amount);
 XBT_PUBLIC(void) MSG_task_set_flops_amount(msg_task_t task,
                                                double flops_amount);
+XBT_PUBLIC(double) MSG_task_get_flops_amount(msg_task_t task);
 XBT_PUBLIC(void) MSG_task_set_bytes_amount(msg_task_t task,
                                         double bytes_amount);
 
 XBT_PUBLIC(void) MSG_task_set_bytes_amount(msg_task_t task,
                                         double bytes_amount);
 
-XBT_PUBLIC(double) MSG_task_get_remaining_computation(msg_task_t task);
 XBT_PUBLIC(double) MSG_task_get_remaining_communication(msg_task_t task);
 XBT_PUBLIC(int) MSG_task_is_latency_bounded(msg_task_t task);
 XBT_PUBLIC(double) MSG_task_get_bytes_amount(msg_task_t task);
 XBT_PUBLIC(double) MSG_task_get_remaining_communication(msg_task_t task);
 XBT_PUBLIC(int) MSG_task_is_latency_bounded(msg_task_t task);
 XBT_PUBLIC(double) MSG_task_get_bytes_amount(msg_task_t task);
index 1a968d1..319a5e1 100644 (file)
@@ -294,8 +294,7 @@ Java_org_simgrid_msg_Task_getSource(JNIEnv * env,
 }
 
 JNIEXPORT jdouble JNICALL
 }
 
 JNIEXPORT jdouble JNICALL
-Java_org_simgrid_msg_Task_getComputeDuration(JNIEnv * env,
-                                                  jobject jtask)
+Java_org_simgrid_msg_Task_getFlopsAmount(JNIEnv * env, jobject jtask)
 {
   msg_task_t ptask = jtask_to_native_task(jtask, env);
 
 {
   msg_task_t ptask = jtask_to_native_task(jtask, env);
 
@@ -303,20 +302,9 @@ Java_org_simgrid_msg_Task_getComputeDuration(JNIEnv * env,
     jxbt_throw_notbound(env, "task", jtask);
     return -1;
   }
     jxbt_throw_notbound(env, "task", jtask);
     return -1;
   }
-  return (jdouble) MSG_task_get_compute_duration(ptask);
+  return (jdouble) MSG_task_get_flops_amount(ptask);
 }
 
 }
 
-JNIEXPORT jdouble JNICALL
-Java_org_simgrid_msg_Task_getRemainingDuration(JNIEnv * env, jobject jtask)
-{
-  msg_task_t ptask = jtask_to_native_task(jtask, env);
-
-  if (!ptask) {
-    jxbt_throw_notbound(env, "task", jtask);
-    return -1;
-  }
-  return (jdouble) MSG_task_get_remaining_computation(ptask);
-}
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Task_setName(JNIEnv *env, jobject jtask, jobject jname) {
        msg_task_t task = jtask_to_native_task(jtask, env);
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Task_setName(JNIEnv *env, jobject jtask, jobject jname) {
        msg_task_t task = jtask_to_native_task(jtask, env);
index c1c108e..b7c7036 100644 (file)
 #include <jni.h>
 #include "simgrid/msg.h"
 
 #include <jni.h>
 #include "simgrid/msg.h"
 
-/**
- * This function returns a global reference to the  java task instance 
- * specified by the parameter jtask.
- *
- * @param jtask                        The original java task instance.
- * @param env                  The environment of the current thread.
- *
- * @return                             The global reference to the original java task 
- *                                             instance.
- */
-/* jobject jtask_new_global_ref(jobject jtask, JNIEnv * env); */
-
-/**
- * This function delete a global reference to a java task instance.
- *
- * @param                              The global refernce to delete.
- * @param env                  The environment of the current thread.
- */
-/* void jtask_delete_global_ref(jobject jtask, JNIEnv * env); */
 
 /**
  * This function associated a native task to a java task instance.
 
 /**
  * This function associated a native task to a java task instance.
@@ -156,19 +137,12 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSource
     (JNIEnv *, jobject);
 /*
  * Class               org_simgrid_msg_Task
     (JNIEnv *, jobject);
 /*
  * Class               org_simgrid_msg_Task
- * Method              getComputeDuration
+ * Method              getFlopsAmount
  * Signature   ()D
  */
  * Signature   ()D
  */
-JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Task_getComputeDuration
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Task_getFlopsAmount
     (JNIEnv *, jobject);
 
     (JNIEnv *, jobject);
 
-/*
- * Class               org_simgrid_msg_Task
- * Method              getRemainingDuration
- * Signature   ()D
- */
-JNIEXPORT jdouble JNICALL
-Java_org_simgrid_msg_Task_getRemainingDuration(JNIEnv *, jobject);
 /**
  * Class               org_simgrid_msg_Task
  * Method              setName
 /**
  * Class               org_simgrid_msg_Task
  * Method              setName
index a6adc84..994d230 100644 (file)
@@ -123,13 +123,12 @@ public class Task {
         * Returns null if the task hasn't been sent yet.
      */
        public native Host getSource();   
         * Returns null if the task hasn't been sent yet.
      */
        public native Host getSource();   
-       /** Gets the computing amount of the task
-     * FIXME: Cache it !
-     */
-       public native double getComputeDuration();
-       /** Gets the remaining computation of the task
-     */
-       public native double getRemainingDuration();
+       
+       /** Gets the remaining amount of flops to execute in this task
+        * 
+        * If it's ongoing, you get the exact amount at the present time. If it's already done, it's 0.
+        */
+       public native double getFlopsAmount();
        /**
         * Sets the name of the task
         * @param name the new task name.c
        /**
         * Sets the name of the task
         * @param name the new task name.c
index 41c744e..38828db 100644 (file)
@@ -112,7 +112,7 @@ static int l_task_get_name(lua_State* L)
 static int l_task_get_computation_duration(lua_State* L)
 {
   msg_task_t task = sglua_check_task(L, 1);
 static int l_task_get_computation_duration(lua_State* L)
 {
   msg_task_t task = sglua_check_task(L, 1);
-  lua_pushnumber(L, MSG_task_get_compute_duration(task));
+  lua_pushnumber(L, MSG_task_get_flops_amount(task));
   return 1;
 }
 
   return 1;
 }
 
index 5703d14..c6055c5 100644 (file)
@@ -311,17 +311,18 @@ msg_error_t MSG_task_cancel(msg_task_t task)
 }
 
 /** \ingroup m_task_management
 }
 
 /** \ingroup m_task_management
- * \brief Returns the computation amount needed to process a task #msg_task_t.
+ * \brief Returns the remaining amount of flops needed to execute a task #msg_task_t.
  *
  * Once a task has been processed, this amount is set to 0. If you want, you
  * can reset this value with #MSG_task_set_flops_amount before restarting the task.
  */
  *
  * Once a task has been processed, this amount is set to 0. If you want, you
  * can reset this value with #MSG_task_set_flops_amount before restarting the task.
  */
-double MSG_task_get_compute_duration(msg_task_t task)
-{
-  xbt_assert((task != NULL)
-              && (task->simdata != NULL), "Invalid parameter");
+double MSG_task_get_flops_amount(msg_task_t task) {
 
 
-  return task->simdata->flops_amount;
+       if (task->simdata->compute) {
+               return simcall_host_execution_get_remains(task->simdata->compute);
+       } else {
+               return task->simdata->flops_amount;
+       }
 }
 
 
 }
 
 
@@ -352,26 +353,6 @@ void MSG_task_set_bytes_amount(msg_task_t task, double data_size)
 }
 
 
 }
 
 
-
-/** \ingroup m_task_management
- * \brief Returns the remaining computation amount of a task #msg_task_t.
- *
- * If the task is ongoing, this call retrieves the remaining amount of work.
- * If it is not ongoing, it returns the total amount of work that will be
- * executed when the task starts.
- */
-double MSG_task_get_remaining_computation(msg_task_t task)
-{
-  xbt_assert((task != NULL)
-              && (task->simdata != NULL), "Invalid parameter");
-
-  if (task->simdata->compute) {
-    return simcall_host_execution_get_remains(task->simdata->compute);
-  } else {
-    return task->simdata->flops_amount;
-  }
-}
-
 /** \ingroup m_task_management
  * \brief Returns the total amount received by a task #msg_task_t.
  *        If the communication does not exist it will return 0.
 /** \ingroup m_task_management
  * \brief Returns the total amount received by a task #msg_task_t.
  *        If the communication does not exist it will return 0.
index c9e1f1f..a2786ac 100644 (file)
@@ -453,7 +453,7 @@ static void reset_dirty_pages(msg_vm_t vm)
   xbt_dict_cursor_t cursor = NULL;
   dirty_page_t dp = NULL;
   xbt_dict_foreach(priv->dp_objs, cursor, key, dp) {
   xbt_dict_cursor_t cursor = NULL;
   dirty_page_t dp = NULL;
   xbt_dict_foreach(priv->dp_objs, cursor, key, dp) {
-    double remaining = MSG_task_get_remaining_computation(dp->task);
+    double remaining = MSG_task_get_flops_amount(dp->task);
     dp->prev_clock = MSG_get_clock();
     dp->prev_remaining = remaining;
 
     dp->prev_clock = MSG_get_clock();
     dp->prev_remaining = remaining;
 
@@ -514,7 +514,7 @@ static double lookup_computed_flop_counts(msg_vm_t vm, int stage_for_fancy_debug
   xbt_dict_cursor_t cursor = NULL;
   dirty_page_t dp = NULL;
   xbt_dict_foreach(priv->dp_objs, cursor, key, dp) {
   xbt_dict_cursor_t cursor = NULL;
   dirty_page_t dp = NULL;
   xbt_dict_foreach(priv->dp_objs, cursor, key, dp) {
-    double remaining = MSG_task_get_remaining_computation(dp->task);
+    double remaining = MSG_task_get_flops_amount(dp->task);
 
     double clock = MSG_get_clock();
 
 
     double clock = MSG_get_clock();
 
@@ -545,7 +545,7 @@ static double lookup_computed_flop_counts(msg_vm_t vm, int stage_for_fancy_debug
 void MSG_host_add_task(msg_host_t host, msg_task_t task)
 {
   msg_host_priv_t priv = msg_host_resource_priv(host);
 void MSG_host_add_task(msg_host_t host, msg_task_t task)
 {
   msg_host_priv_t priv = msg_host_resource_priv(host);
-  double remaining = MSG_task_get_remaining_computation(task);
+  double remaining = MSG_task_get_flops_amount(task);
   char *key = bprintf("%s-%p", task->name, task);
 
   dirty_page_t dp = xbt_new0(s_dirty_page, 1);
   char *key = bprintf("%s-%p", task->name, task);
 
   dirty_page_t dp = xbt_new0(s_dirty_page, 1);
@@ -577,7 +577,7 @@ void MSG_host_del_task(msg_host_t host, msg_task_t task)
    * computation has been done until now, and keep the information for the
    * lookup_() function that will called soon. */
   if (priv->dp_enabled) {
    * computation has been done until now, and keep the information for the
    * lookup_() function that will called soon. */
   if (priv->dp_enabled) {
-    double remaining = MSG_task_get_remaining_computation(task);
+    double remaining = MSG_task_get_flops_amount(task);
     double clock = MSG_get_clock();
     // double updated = calc_updated_pages(key, host, dp, remaining, clock);
     double updated = get_computed(key, host, dp, remaining, clock);
     double clock = MSG_get_clock();
     // double updated = calc_updated_pages(key, host, dp, remaining, clock);
     double updated = get_computed(key, host, dp, remaining, clock);
index 04cecd0..0ba661d 100644 (file)
@@ -126,7 +126,7 @@ int slave(int argc, char *argv[])
     XBT_INFO("Task \"%s\" done in %f (amount %f)"
                , MSG_task_get_name(task)
                , end - start
     XBT_INFO("Task \"%s\" done in %f (amount %f)"
                , MSG_task_get_name(task)
                , end - start
-               , MSG_task_get_remaining_computation(task));
+               , MSG_task_get_flops_amount(task));
 
     MSG_task_destroy(task);
     task = NULL;
 
     MSG_task_destroy(task);
     task = NULL;