Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update MSG_task_destroy for parallel tasks
[simgrid.git] / src / msg / task.c
index af973f0..1fe3975 100644 (file)
@@ -13,6 +13,18 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(task, msg,
 
 static char sprint_buffer[64];
 
+/** \defgroup m_task_management Managing functions of Tasks
+ *  \brief This section describes the task structure of MSG
+ *  (#m_task_t) and the functions for managing it.
+ *
+ *  Since most scheduling algorithms rely on a concept of task
+ *  that can be either <em>computed</em> locally or
+ *  <em>transferred</em> on another processor, it seems to be the
+ *  right level of abstraction for our purposes. A <em>task</em>
+ *  may then be defined by a <em>computing amount</em>, a
+ *  <em>message size</em> and some <em>private data</em>.
+ */
+
 /********************************* Task **************************************/
 /** \ingroup m_task_management
  * \brief Creates a new #m_task_t.
@@ -33,8 +45,8 @@ static char sprint_buffer[64];
  * \see m_task_t
  * \return The new corresponding object.
  */
-m_task_t MSG_task_create(const char *name, long double compute_duration,
-                        long double message_size, void *data)
+m_task_t MSG_task_create(const char *name, double compute_duration,
+                        double message_size, void *data)
 {
   simdata_task_t simdata = xbt_new0(s_simdata_task_t,1);
   m_task_t task = xbt_new0(s_m_task_t,1);
@@ -48,6 +60,7 @@ m_task_t MSG_task_create(const char *name, long double compute_duration,
   simdata->sleeping = xbt_dynar_new(sizeof(m_process_t),NULL);
   simdata->computation_amount = compute_duration;
   simdata->message_size = message_size;
+  simdata->rate = -1.0;
   simdata->using = 1;
   simdata->sender = NULL;
 
@@ -78,6 +91,17 @@ m_process_t MSG_task_get_sender(m_task_t task)
    return ((simdata_task_t) task->simdata)->sender;
 }
 
+/** \ingroup m_task_management
+ * \brief Return the name of a #m_task_t.
+ *
+ * This functions returns the name of a #m_task_t as specified on creation
+ */
+const char *MSG_task_get_name(m_task_t task)
+{
+   xbt_assert0(task, "Invalid parameters");
+   return task->name;
+}
+
 
 /** \ingroup m_task_management
  * \brief Destroy a #m_task_t.
@@ -99,7 +123,7 @@ MSG_error_t MSG_task_destroy(m_task_t task)
   xbt_assert0((xbt_dynar_length(task->simdata->sleeping)==0), 
              "Task still used. There is a problem. Cannot destroy it now!");
 
-  if(task->name) xbt_free(task->name);
+  if(task->name) free(task->name);
 
   xbt_dynar_free(&(task->simdata->sleeping));
 
@@ -107,14 +131,40 @@ MSG_error_t MSG_task_destroy(m_task_t task)
   if(action) action->resource_type->common_public->action_free(action);
   action = task->simdata->comm;
   if(action) action->resource_type->common_public->action_free(action);
+  if(task->simdata->host_list) xbt_free(task->simdata->host_list);
 
-
-  xbt_free(task->simdata);
-  xbt_free(task);
+  free(task->simdata);
+  free(task);
 
   return MSG_OK;
 }
 
+/** \ingroup m_task_management
+ * \brief Returns the computation amount needed to process a task #m_task_t.
+ *
+ */
+double MSG_task_get_compute_duration(m_task_t task)
+{
+  simdata_task_t simdata = NULL;
+
+  xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
+
+  return task->simdata->computation_amount;
+}
+
+/** \ingroup m_task_management
+ * \brief Returns the size of the data attached to a task #m_task_t.
+ *
+ */
+double MSG_task_get_data_size(m_task_t task)
+{
+  simdata_task_t simdata = NULL;
+
+  xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
+
+  return task->simdata->message_size;
+}
+
 /* static MSG_error_t __MSG_task_check(m_task_t task) */
 /* { */
 /*   simdata_task_t simdata = NULL; */