+ sd_global->task_number--;
+
+ DEBUG0("Task destroyed.");
+}
+
+
+static XBT_INLINE SD_task_t SD_task_create_sized(const char *name,
+ void *data, double amount,
+ int ws_count)
+{
+ SD_task_t task = SD_task_create(name, data, amount);
+ task->communication_amount = xbt_new0(double, ws_count * ws_count);
+ task->computation_amount = xbt_new0(double, ws_count);
+ task->workstation_nb = ws_count;
+ task->workstation_list = xbt_new0(SD_workstation_t, ws_count);
+ return task;
+}
+
+/** @brief create a end-to-end communication task that can then be auto-scheduled
+ *
+ * Auto-scheduling mean that the task can be used with SD_task_schedulev(). This
+ * allows to specify the task costs at creation, and decorelate them from the
+ * scheduling process where you just specify which resource should deliver the
+ * mandatory power.
+ *
+ * A end-to-end communication must be scheduled on 2 hosts, and the amount
+ * specified at creation is sent from hosts[0] to hosts[1].
+ */
+SD_task_t SD_task_create_comm_e2e(const char *name, void *data,
+ double amount)
+{
+ SD_task_t res = SD_task_create_sized(name, data, amount, 2);
+ res->communication_amount[2] = amount;
+ res->kind = SD_TASK_COMM_E2E;
+ return res;
+}
+
+/** @brief create a sequential computation task that can then be auto-scheduled
+ *
+ * Auto-scheduling mean that the task can be used with SD_task_schedulev(). This
+ * allows to specify the task costs at creation, and decorelate them from the
+ * scheduling process where you just specify which resource should deliver the
+ * mandatory power.
+ *
+ * A sequential computation must be scheduled on 1 host, and the amount
+ * specified at creation to be run on hosts[0].
+ */
+SD_task_t SD_task_create_comp_seq(const char *name, void *data,
+ double amount)
+{
+ SD_task_t res = SD_task_create_sized(name, data, amount, 1);
+ res->computation_amount[0] = amount;
+ res->kind = SD_TASK_COMP_SEQ;
+ return res;
+}
+
+/** @brief Auto-schedules a task.
+ *
+ * Auto-scheduling mean that the task can be used with SD_task_schedulev(). This
+ * allows to specify the task costs at creation, and decorelate them from the
+ * scheduling process where you just specify which resource should deliver the
+ * mandatory power.
+ *
+ * To be auto-schedulable, a task must be created with SD_task_create_comm_e2e() or
+ * SD_task_create_comp_seq(). Check their definitions for the exact semantic of each
+ * of them.
+ *
+ * @todo
+ * We should create tasks kind for the following categories:
+ * - Point to point communication (done)
+ * - Sequential computation (done)
+ * - group communication (redistribution, several kinds)
+ * - parallel tasks with no internal communication (one kind per speedup model such as amdal)
+ * - idem+ internal communication. Task type not enough since we cannot store comm cost alongside to comp one)
+ */
+void SD_task_schedulev(SD_task_t task, int count,
+ const SD_workstation_t * list)
+{
+ int i;
+ SD_dependency_t dep;
+ unsigned int cpt;
+ xbt_assert1(task->kind != 0,
+ "Task %s is not typed. Cannot automatically schedule it.",
+ SD_task_get_name(task));
+ switch (task->kind) {
+ case SD_TASK_COMM_E2E:
+ case SD_TASK_COMP_SEQ:
+ xbt_assert(task->workstation_nb == count);
+ for (i = 0; i < count; i++)
+ task->workstation_list[i] = list[i];
+ SD_task_do_schedule(task);
+ break;
+ default:
+ xbt_die(bprintf("Kind of task %s not supported by SD_task_schedulev()",
+ SD_task_get_name(task)));
+ }
+ if (task->kind == SD_TASK_COMM_E2E) {
+ VERB4("Schedule comm task %s between %s -> %s. It costs %.f bytes",
+ SD_task_get_name(task),
+ SD_workstation_get_name(task->workstation_list[0]),
+ SD_workstation_get_name(task->workstation_list[1]),
+ task->communication_amount[2]);