Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove attribute amount from structure task
authorthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 30 Jun 2006 11:34:28 +0000 (11:34 +0000)
committerthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 30 Jun 2006 11:34:28 +0000 (11:34 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2463 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/simdag/sd_test.c
include/simdag/simdag.h
src/simdag/private.h
src/simdag/sd_task.c

index 72105d5..e9e9a31 100644 (file)
@@ -10,7 +10,7 @@ int main(int argc, char **argv) {
 
   if (argc < 2) {
      printf ("Usage: %s platform_file\n", argv[0]);
-     printf ("example: %s msg_platform.xml\n", argv[0]);
+     printf ("example: %s sd_platform.xml\n", argv[0]);
      exit(1);
   }
 
@@ -19,10 +19,10 @@ int main(int argc, char **argv) {
   SD_create_environment(platform_file);
 
   /* creation of the tasks and their dependencies */
-  SD_task_t taskA = SD_task_create("Task A", NULL, 10.0);
-  SD_task_t taskB = SD_task_create("Task B", NULL, 40.0);
-  SD_task_t taskC = SD_task_create("Task C", NULL, 30.0);
-  SD_task_t taskD = SD_task_create("Task D", NULL, 60.0);
+  SD_task_t taskA = SD_task_create("Task A", NULL);
+  SD_task_t taskB = SD_task_create("Task B", NULL);
+  SD_task_t taskC = SD_task_create("Task C", NULL);
+  SD_task_t taskD = SD_task_create("Task D", NULL);
   
   SD_task_dependency_add(NULL, NULL, taskB, taskA);
   SD_task_dependency_add(NULL, NULL, taskC, taskA);
index 9690a03..4050cc6 100644 (file)
@@ -71,7 +71,7 @@ double             SD_workstation_get_available_power(SD_workstation_t workstati
  *  @see SD_task_t, SD_task_dependency_management
  *  @{
  */
-SD_task_t         SD_task_create(const char *name, void *data, double amount);
+SD_task_t         SD_task_create(const char *name, void *data);
 void*             SD_task_get_data(SD_task_t task);
 void              SD_task_set_data(SD_task_t task, void *data);
 e_SD_task_state_t SD_task_get_state(SD_task_t task);
@@ -81,8 +81,8 @@ double            SD_task_get_remaining_amount(SD_task_t task);
 void              SD_task_watch(SD_task_t task, e_SD_task_state_t state);
 void              SD_task_unwatch(SD_task_t task, e_SD_task_state_t state);
 void              SD_task_schedule(SD_task_t task, int workstation_nb,
-                                  const SD_workstation_t *workstation_list, double *computation_amount,
-                                  double *communication_amount, double rate);
+                                  const SD_workstation_t *workstation_list, const double *computation_amount,
+                                  const double *communication_amount, double rate);
 void              SD_task_unschedule(SD_task_t task);
 void              SD_task_destroy(SD_task_t task);
 /** @} */
index 0ef4402..ed79e69 100644 (file)
@@ -47,7 +47,6 @@ typedef struct SD_task {
   xbt_swag_t state_set;
   void *data; /* user data */
   char *name;
-  double amount;
   surf_action_t surf_action;
   unsigned short watch_points;
   int state_changed; /* used only by SD_simulate, to make sure we put
index 1578ff1..c507caf 100644 (file)
@@ -10,13 +10,11 @@ static void __SD_task_remove_dependencies(SD_task_t task);
  *
  * \param name the name of the task (can be \c NULL)
  * \param data the user data you want to associate with the task (can be \c NULL)
- * \param amount the computing amount necessary to do this task
  * \return the new task
  * \see SD_task_destroy()
  */
-SD_task_t SD_task_create(const char *name, void *data, double amount) {
+SD_task_t SD_task_create(const char *name, void *data) {
   SD_CHECK_INIT_DONE();
-  xbt_assert0(amount > 0, "amount must be positive");
 
   SD_task_t task = xbt_new0(s_SD_task_t, 1);
 
@@ -30,7 +28,6 @@ SD_task_t SD_task_create(const char *name, void *data, double amount) {
   task->state_set = sd_global->not_scheduled_task_set;
   xbt_swag_insert(task,task->state_set);
 
-  task->amount = amount;
   task->surf_action = NULL;
   task->watch_points = 0;
   task->state_changed = 0;
@@ -151,33 +148,31 @@ const char* SD_task_get_name(SD_task_t task) {
 }
 
 /**
- * \brief Returns the computing amount of a task
+ * \brief Returns the total amount of a task
  *
  * \param task a task
- * \return the total computing amount of this task
+ * \return the total amount of this task
  * \see SD_task_get_remaining_amount()
  */
 double SD_task_get_amount(SD_task_t task) {
   SD_CHECK_INIT_DONE();
   xbt_assert0(task != NULL, "Invalid parameter");
-  return task->amount;
+  xbt_assert1(task->surf_action != NULL, "The task '%s' is not running", SD_task_get_name(task));
+  return task->surf_action->cost;
 }
 
 /**
- * \brief Returns the remaining computing amount of a task
+ * \brief Returns the remaining amount of a task
  *
  * \param task a task
- * \return the remaining computing amount of this task
+ * \return the remaining amount of this task
  * \see SD_task_get_amount()
  */
 double SD_task_get_remaining_amount(SD_task_t task) {
   SD_CHECK_INIT_DONE();
   xbt_assert0(task != NULL, "Invalid parameter");
-  
-  if (task->surf_action)
-    return task->amount;
-  else
-    return task->surf_action->remains;
+  xbt_assert1(task->surf_action != NULL, "The task '%s' is not running", SD_task_get_name(task));
+  return task->surf_action->remains / task->surf_action->cost;
 }
 
 /* temporary function for debbuging */
@@ -420,8 +415,8 @@ static void __SD_task_destroy_scheduling_data(SD_task_t task) {
  * \see SD_task_unschedule()
  */
 void SD_task_schedule(SD_task_t task, int workstation_nb,
-                    const SD_workstation_t *workstation_list, double *computation_amount,
-                    double *communication_amount, double rate) {
+                    const SD_workstation_t *workstation_list, const double *computation_amount,
+                    const double *communication_amount, double rate) {
   SD_CHECK_INIT_DONE();
   xbt_assert0(task, "Invalid parameter");
   xbt_assert1(__SD_task_is_not_scheduled(task), "Task '%s' has already been scheduled.", SD_task_get_name(task));
@@ -494,7 +489,7 @@ surf_action_t __SD_task_run(SD_task_t task) {
                          task->workstation_list,
                          task->computation_amount,
                          task->communication_amount,
-                         task->amount,
+                         1.0,
                          task->rate);
 
   __SD_task_destroy_scheduling_data(task); /* now the scheduling data are not useful anymore */