-xbt_dynar_t SD_dotload_FILE(FILE* in_file){
- xbt_assert0(in_file, "Unable to use a null file descriptor\n");
- dag_dot = agread(in_file,NIL(Agdisc_t*));
-
- result = xbt_dynar_new(sizeof(SD_task_t),dot_task_free);
- files=xbt_dict_new();
- jobs=xbt_dict_new();
- 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) {
- 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);
- }
- }
+xbt_dynar_t SD_dotload_with_sched(const char *filename){
+ FILE *in_file = fopen(filename, "r");
+ xbt_assert1(in_file, "Unable to open \"%s\"\n", filename);
+ SD_dotload_FILE(in_file);
+ fclose(in_file);
+
+ if(schedule == true){
+ xbt_dynar_t computer = NULL;
+ xbt_dict_cursor_t dict_cursor;
+ char *computer_name;
+ const SD_workstation_t *workstations = SD_workstation_get_list ();
+ xbt_dict_foreach(computers,dict_cursor,computer_name,computer){
+ int count_computer = dot_parse_int(computer_name);
+ unsigned int count=0;
+ SD_task_t task;
+ SD_task_t task_previous = NULL;
+ xbt_dynar_foreach(computer,count,task){
+ // add dependency between the previous and the task to avoid
+ // parallel execution
+ if(task != NULL ){
+ if(task_previous != NULL &&
+ !SD_task_dependency_exists(task_previous, task))
+ SD_task_dependency_add(NULL, NULL, task_previous, task);
+ SD_task_schedulel(task, 1, workstations[count_computer]);
+ task_previous = task;