Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Comment the binary search in ObjectInformation::find_function()
[simgrid.git] / src / simdag / sd_task.c
index 7603ffc..aa31087 100644 (file)
@@ -5,7 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "private.h"
-#include "simdag/simdag.h"
+#include "simgrid/simdag.h"
 #include "xbt/sysdep.h"
 #include "xbt/dynar.h"
 #include "instr/instr_private.h"
@@ -90,9 +90,7 @@ SD_task_t SD_task_create(const char *name, void *data, double amount)
 
   sd_global->task_number++;
 
-#ifdef HAVE_TRACING
   TRACE_sd_task_create(task);
-#endif
 
   return task;
 }
@@ -126,10 +124,8 @@ SD_task_t SD_task_create_comm_e2e(const char *name, void *data,
   res->bytes_amount[2] = amount;
   res->kind = SD_TASK_COMM_E2E;
 
-#ifdef HAVE_TRACING
   TRACE_category("COMM_E2E");
   TRACE_sd_set_task_category(res, "COMM_E2E");
-#endif
 
   return res;
 }
@@ -156,12 +152,10 @@ SD_task_t SD_task_create_comp_seq(const char *name, void *data,
   res->flops_amount[0] = flops_amount;
   res->kind = SD_TASK_COMP_SEQ;
 
-#ifdef HAVE_TRACING
   TRACE_category("COMP_SEQ");
   TRACE_sd_set_task_category(res, "COMP_SEQ");
-#endif
 
-return res;
+  return res;
 }
 
 /** @brief create a parallel computation task that can then be auto-scheduled
@@ -191,10 +185,8 @@ SD_task_t SD_task_create_comp_par_amdahl(const char *name, void *data,
   res->alpha = alpha;
   res->kind = SD_TASK_COMP_PAR_AMDAHL;
 
-#ifdef HAVE_TRACING
   TRACE_category("COMP_PAR_AMDAHL");
   TRACE_sd_set_task_category(res, "COMP_PAR_AMDAHL");
-#endif
 
   return res;
 }
@@ -225,10 +217,8 @@ SD_task_t SD_task_create_comm_par_mxn_1d_block(const char *name, void *data,
   res->workstation_list=NULL;
   res->kind = SD_TASK_COMM_PAR_MXN_1D_BLOCK;
 
-#ifdef HAVE_TRACING
   TRACE_category("COMM_PAR_MXN_1D_BLOCK");
   TRACE_sd_set_task_category(res, "COMM_PAR_MXN_1D_BLOCK");
-#endif
 
   return res;
 }
@@ -263,9 +253,7 @@ void SD_task_destroy(SD_task_t task)
   xbt_free(task->bytes_amount);
   xbt_free(task->flops_amount);
 
-#ifdef HAVE_TRACING
   TRACE_sd_task_destroy(task);
-#endif
 
   xbt_mallocator_release(sd_global->task_mallocator,task);
   sd_global->task_number--;
@@ -304,9 +292,10 @@ void SD_task_set_data(SD_task_t task, void *data)
  * \brief Sets the rate of a task
  *
  * This will change the network bandwidth a task can use. This rate
- * depends on both the nominal bandwidth on the route onto which the task is
- * scheduled (\see SD_task_get_current_bandwidth) and the amount of data to
- * transfer.
+ * cannot be dynamically changed. Once the task has started, this call
+ * is ineffective. This rate depends on both the nominal bandwidth on
+ * the route onto which the task is scheduled (\see
+ * SD_task_get_current_bandwidth) and the amount of data to transfer.
  *
  * To divide the nominal bandwidth by 2, the rate then has to be :
  *    rate = bandwidth/(2*amount)
@@ -318,8 +307,11 @@ void SD_task_set_rate(SD_task_t task, double rate)
 {
   xbt_assert(task->kind == SD_TASK_COMM_E2E,
              "The rate can be modified for end-to-end communications only.");
-
-  task->rate = rate;
+  if(task->start_time<0) {
+    task->rate = rate;
+  } else {
+    XBT_WARN("Task %p has started. Changing rate is ineffective.", task);
+  }
 }
 
 /**
@@ -568,10 +560,8 @@ void SD_task_dump(SD_task_t task)
     }
   }
 
-#ifdef HAVE_TRACING
   if (task->category)
     XBT_INFO("  - tracing category: %s", task->category);
-#endif
 
   XBT_INFO("  - amount: %.0f", SD_task_get_amount(task));
   if (task->kind == SD_TASK_COMP_PAR_AMDAHL)
@@ -1100,7 +1090,7 @@ void __SD_task_really_run(SD_task_t task)
 {
 
   int i;
-  void **surf_workstations;
+  void **surf_hosts;
 
   xbt_assert(__SD_task_is_runnable_or_in_fifo(task),
               "Task '%s' is not runnable or in a fifo! Task state: %d",
@@ -1110,10 +1100,10 @@ void __SD_task_really_run(SD_task_t task)
               SD_task_get_name(task));
 
   XBT_DEBUG("Really running task '%s'", SD_task_get_name(task));
-  int workstation_nb = task->workstation_nb;
+  int host_nb = task->workstation_nb;
 
   /* set this task as current task for the workstations in sequential mode */
-  for (i = 0; i < workstation_nb; i++) {
+  for (i = 0; i < host_nb; i++) {
     if (SD_workstation_get_access_mode(task->workstation_list[i]) ==
         SD_WORKSTATION_SEQUENTIAL_ACCESS) {
       SD_workstation_priv(task->workstation_list[i])->current_task = task;
@@ -1129,25 +1119,25 @@ void __SD_task_really_run(SD_task_t task)
 
   /* we have to create a Surf workstation array instead of the SimDag
    * workstation array */
-  surf_workstations = xbt_new(void *, workstation_nb);
+  surf_hosts = xbt_new(void *, host_nb);
 
-  for (i = 0; i < workstation_nb; i++)
-    surf_workstations[i] =  surf_workstation_resource_priv(task->workstation_list[i]);
+  for (i = 0; i < host_nb; i++)
+    surf_hosts[i] =  surf_host_resource_priv(task->workstation_list[i]);
 
-  double *flops_amount = xbt_new0(double, workstation_nb);
-  double *bytes_amount = xbt_new0(double, workstation_nb * workstation_nb);
+  double *flops_amount = xbt_new0(double, host_nb);
+  double *bytes_amount = xbt_new0(double, host_nb * host_nb);
 
 
   if(task->flops_amount)
     memcpy(flops_amount, task->flops_amount, sizeof(double) *
-           workstation_nb);
+           host_nb);
   if(task->bytes_amount)
     memcpy(bytes_amount, task->bytes_amount,
-           sizeof(double) * workstation_nb * workstation_nb);
+           sizeof(double) * host_nb * host_nb);
 
-  task->surf_action = surf_workstation_model_execute_parallel_task((surf_workstation_model_t)surf_workstation_model,
-                                                                    workstation_nb,
-                                                                    surf_workstations,
+  task->surf_action = surf_host_model_execute_parallel_task((surf_host_model_t)surf_host_model,
+                                                                    host_nb,
+                                                                    surf_hosts,
                                                                     flops_amount,
                                                                     bytes_amount,
                                                                     task->rate);
@@ -1156,10 +1146,8 @@ void __SD_task_really_run(SD_task_t task)
 
   XBT_DEBUG("surf_action = %p", task->surf_action);
 
-#ifdef HAVE_TRACING
   if (task->category)
     TRACE_surf_action(task->surf_action, task->category);
-#endif
 
   __SD_task_destroy_scheduling_data(task);      /* now the scheduling data are not useful anymore */
   __SD_task_set_state(task, SD_RUNNING);