- Agnode_t *dag_node = NULL;
- for (dag_node = agfstnode(dag_dot); dag_node; dag_node = agnxtnode(dag_dot,dag_node)){
- dot_add_task(dag_node);
- }
- agclose(dag_dot);
- xbt_dict_free(&jobs);
-
- /* And now, post-process the files.
- * We want a file task per pair of computation tasks exchanging the file. Duplicate on need
- * Files not produced in the system are said to be produced by root task (top of DAG).
- * Files not consumed in the system are said to be consumed by end task (bottom of DAG).
- */
- xbt_dict_cursor_t cursor;
- SD_task_t file;
- char *name;
- xbt_dict_foreach(files,cursor,name,file) {
- unsigned int cpt1,cpt2;
- SD_task_t newfile = NULL;
- SD_dependency_t depbefore,depafter;
- if (xbt_dynar_length(file->tasks_before) == 0) {
- xbt_dynar_foreach(file->tasks_after,cpt2,depafter) {
- SD_task_t newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount);
- SD_task_dependency_add(NULL,NULL,root_task,newfile);
- SD_task_dependency_add(NULL,NULL,newfile,depafter->dst);
- xbt_dynar_push(result,&newfile);
- }
- } else if (xbt_dynar_length(file->tasks_after) == 0) {
- xbt_dynar_foreach(file->tasks_before,cpt2,depbefore) {
- SD_task_t newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount);
- SD_task_dependency_add(NULL,NULL,depbefore->src,newfile);
- SD_task_dependency_add(NULL,NULL,newfile,end_task);
- xbt_dynar_push(result,&newfile);
- }
- } else {
- xbt_dynar_foreach(file->tasks_before,cpt1,depbefore) {
- xbt_dynar_foreach(file->tasks_after,cpt2,depafter) {
- if (depbefore->src == depafter->dst) {
- WARN2("File %s is produced and consumed by task %s. This loop dependency will prevent the execution of the task.",
- file->name,depbefore->src->name);
- }
- newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount);
- SD_task_dependency_add(NULL,NULL,depbefore->src,newfile);
- SD_task_dependency_add(NULL,NULL,newfile,depafter->dst);
- xbt_dynar_push(result,&newfile);
- }
- }
+ result = xbt_dynar_new(sizeof(SD_task_t), dot_task_free);
+ files = xbt_dict_new_homogeneous(&dot_task_free);
+ jobs = xbt_dict_new_homogeneous(NULL);
+ computers = xbt_dict_new_homogeneous(NULL);
+ root_task = SD_task_create_comp_seq("root", NULL, 0);
+ /* by design the root task is always SCHEDULABLE */
+ __SD_task_set_state(root_task, SD_SCHEDULABLE);
+
+ xbt_dict_set(jobs, "root", root_task, NULL);
+ xbt_dynar_push(result, &root_task);
+ end_task = SD_task_create_comp_seq("end", NULL, 0);
+ xbt_dict_set(jobs, "end", end_task, NULL);
+
+ Agnode_t *dag_node = NULL;
+ for (dag_node = agfstnode(dag_dot); dag_node;
+#ifdef HAVE_CGRAPH_H
+ dag_node = agnxtnode(dag_dot, dag_node)
+#elif HAVE_AGRAPH_H
+ dag_node = agnxtnode(dag_node)
+#endif
+ ) {
+
+ dot_add_task(dag_node);
+ }
+ agclose(dag_dot);
+ xbt_dict_free(&jobs);
+
+ /* And now, post-process the files.
+ * We want a file task per pair of computation tasks exchanging the file. Duplicate on need
+ * Files not produced in the system are said to be produced by root task (top of DAG).
+ * Files not consumed in the system are said to be consumed by end task (bottom of DAG).
+ */
+ xbt_dict_cursor_t cursor;
+ SD_task_t file;
+ char *name;
+ xbt_dict_foreach(files, cursor, name, file) {
+ unsigned int cpt1, cpt2;
+ SD_task_t newfile = NULL;
+ SD_dependency_t depbefore, depafter;
+ if (xbt_dynar_is_empty(file->tasks_before)) {
+ xbt_dynar_foreach(file->tasks_after, cpt2, depafter) {
+ SD_task_t newfile =
+ SD_task_create_comm_e2e(file->name, NULL, file->amount);
+ SD_task_dependency_add(NULL, NULL, root_task, newfile);
+ SD_task_dependency_add(NULL, NULL, newfile, depafter->dst);
+ xbt_dynar_push(result, &newfile);
+ }
+ } else if (xbt_dynar_is_empty(file->tasks_after)) {
+ xbt_dynar_foreach(file->tasks_before, cpt2, depbefore) {
+ SD_task_t newfile =
+ SD_task_create_comm_e2e(file->name, NULL, file->amount);
+ SD_task_dependency_add(NULL, NULL, depbefore->src, newfile);
+ SD_task_dependency_add(NULL, NULL, newfile, end_task);
+ xbt_dynar_push(result, &newfile);
+ }
+ } else {
+ xbt_dynar_foreach(file->tasks_before, cpt1, depbefore) {
+ xbt_dynar_foreach(file->tasks_after, cpt2, depafter) {
+ if (depbefore->src == depafter->dst) {
+ XBT_WARN
+ ("File %s is produced and consumed by task %s. This loop dependency will prevent the execution of the task.",
+ file->name, depbefore->src->name);
+ }
+ newfile =
+ SD_task_create_comm_e2e(file->name, NULL, file->amount);
+ SD_task_dependency_add(NULL, NULL, depbefore->src, newfile);
+ SD_task_dependency_add(NULL, NULL, newfile, depafter->dst);
+ xbt_dynar_push(result, &newfile);