+ xbt_dynar_free(&result);
+ /* (result == NULL) here */
+ }
+ return result;
+}
+
+
+xbt_dynar_t SD_dotload_generic(const char * filename)
+{
+ xbt_assert(filename, "Unable to use a null file descriptor\n");
+ //dag_dot = agopen((char*)filename,Agstrictdirected,0);
+ FILE *in_file = fopen(filename, "r");
+ dag_dot = agread(in_file, NIL(Agdisc_t *));
+
+ result = xbt_dynar_new(sizeof(SD_task_t), dot_task_p_free);
+ files = xbt_dict_new_homogeneous(NULL);
+ 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; 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) {
+ XBT_DEBUG("Considering file '%s' stored in the dictionnary",
+ file->name);
+ if (xbt_dynar_is_empty(file->tasks_before)) {
+ XBT_DEBUG("file '%s' has no source. Add dependency from 'root'",
+ file->name);
+ SD_task_dependency_add(NULL, NULL, root_task, file);
+ } else if (xbt_dynar_is_empty(file->tasks_after)) {
+ XBT_DEBUG("file '%s' has no destination. Add dependency to 'end'",
+ file->name);
+ SD_task_dependency_add(NULL, NULL, file, end_task);
+ }
+ xbt_dynar_push(result, &file);
+ }
+
+ /* Push end task last */
+ xbt_dynar_push(result, &end_task);
+
+ xbt_dict_free(&files);
+ fclose(in_file);
+ if (!acyclic_graph_detail(result)) {
+ XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.",
+ basename((char*)filename));
+ xbt_dynar_free(&result);
+ /* (result == NULL) here */
+ }
+ return result;
+}
+
+/* dot_add_parallel_task create a sd_task of SD_TASK_COMP_PAR_AMDHAL type and
+ * all transfers required for this task. The execution time of the task is
+ * given by the attribute size. The unit of size is the Flop.*/
+void dot_add_parallel_task(Agnode_t * dag_node)
+{
+ char *name = agnameof(dag_node);
+ SD_task_t current_job;
+ double amount = dot_parse_double(agget(dag_node, (char *) "size"));
+ double alpha = dot_parse_double(agget(dag_node, (char *) "alpha"));
+
+ if (alpha == -1.)
+ alpha = 0.0;
+
+ XBT_DEBUG("See <job id=%s amount=%s %.0f alpha=%.2f>", name,
+ agget(dag_node, (char *) "size"), amount, alpha);
+ if (!strcmp(name, "root")){
+ XBT_WARN("'root' node is explicitly declared in the DOT file. Ignore it");
+ return;
+ }
+ if (!strcmp(name, "end")){
+ XBT_WARN("'end' node is explicitly declared in the DOT file. Ignore it");
+ return;
+ }
+
+ current_job = xbt_dict_get_or_null(jobs, name);
+ if (current_job == NULL) {
+ current_job =
+ SD_task_create_comp_par_amdahl(name, NULL , amount, alpha);
+#ifdef HAVE_TRACING
+ TRACE_sd_dotloader (current_job, agget (dag_node, (char*)"category"));
+#endif
+ xbt_dict_set(jobs, name, current_job, NULL);
+ xbt_dynar_push(result, ¤t_job);
+ }
+ Agedge_t *e;
+ int count = 0;
+
+ for (e = agfstin(dag_dot, dag_node); e; e = agnxtin(dag_dot, e)) {
+ dot_add_input_dependencies(current_job, e, parallel);
+ count++;
+ }
+ if (count == 0 && current_job != root_task) {
+ SD_task_dependency_add(NULL, NULL, root_task, current_job);
+ }
+ count = 0;
+ for (e = agfstout(dag_dot, dag_node); e; e = agnxtout(dag_dot, e)) {
+ dot_add_output_dependencies(current_job, e, parallel);
+ count++;
+ }
+ if (count == 0 && current_job != end_task) {
+ SD_task_dependency_add(NULL, NULL, current_job, end_task);