X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1519c5f2b2fd984d6a96f5901f8cc7effe784188..999a64fe86043f1b9cc777db6a5cdc4e34c4c922:/src/simdag/sd_dotloader.c diff --git a/src/simdag/sd_dotloader.c b/src/simdag/sd_dotloader.c index 18716862ac..2d675aa573 100644 --- a/src/simdag/sd_dotloader.c +++ b/src/simdag/sd_dotloader.c @@ -69,92 +69,6 @@ static void dump_res() } } -bool child_are_marked(SD_task_t task){ - SD_task_t child_task = NULL; - bool all_marked = true; - SD_dependency_t depafter = NULL; - int count; - xbt_dynar_foreach(task->tasks_after,count,depafter){ - child_task = depafter->dst; - //test marked - if(child_task->marked == 0) { - all_marked = false; - break; - } - child_task = NULL; - } - return all_marked; -} - -bool acyclic_graph_detection(xbt_dynar_t dag){ - int count=0, count_current=0; - bool all_marked = true; - SD_task_t task = NULL, parent_task = NULL; - SD_dependency_t depbefore = NULL; - xbt_dynar_t next = NULL, current = xbt_dynar_new(sizeof(SD_task_t),NULL); - - xbt_dynar_foreach(dag,count,task){ - if(task->kind == SD_TASK_COMM_E2E) continue; - task->marked = 0; - if(xbt_dynar_length(task->tasks_after) == 0){ - xbt_dynar_push(current, &task); - } - } - task = NULL; - count = 0; - //test if something has to be done for the next iteration - while(xbt_dynar_length(current) != 0){ - next = xbt_dynar_new(sizeof(SD_task_t),NULL); - //test if the current iteration is done - count_current=0; - xbt_dynar_foreach(current,count_current,task){ - if (task == NULL) continue; - count = 0; - //push task in next - task->marked = 1; - int count = 0; - xbt_dynar_foreach(task->tasks_before,count,depbefore){ - parent_task = depbefore->src; - if(parent_task->kind == SD_TASK_COMM_E2E){ - int j=0; - parent_task->marked = 1; - xbt_dynar_foreach(parent_task->tasks_before,j,depbefore){ - parent_task = depbefore->src; - if(child_are_marked(parent_task)) - xbt_dynar_push(next, &parent_task); - } - } else{ - if(child_are_marked(parent_task)) - xbt_dynar_push(next, &parent_task); - } - parent_task = NULL; - } - task = NULL; - count = 0; - } - xbt_dynar_free(¤t); - current = next; - next = NULL; - } - xbt_dynar_free(¤t); - current = NULL; - all_marked = true; - xbt_dynar_foreach(dag,count,task){ - if(task->kind == SD_TASK_COMM_E2E) continue; - //test if all tasks are marked - if(task->marked == 0){ - WARN1("test %d",task->name); - all_marked = false; - break; - } - } - task = NULL; - if(all_marked){ - WARN0("there are no cycle in your DAG"); - }else{ - WARN0("there are a cycle in your DAG"); - } -} static void dot_task_free(void *task) { @@ -187,9 +101,56 @@ xbt_dynar_t SD_dotload(const char *filename) xbt_assert1(in_file, "Unable to open \"%s\"\n", filename); SD_dotload_FILE(in_file); fclose(in_file); + xbt_dynar_t computer = NULL; + xbt_dict_cursor_t dict_cursor; + char *computer_name; + xbt_dict_foreach(computers,dict_cursor,computer_name,computer){ + xbt_dynar_free(&computer); + } + xbt_dict_free(&computers); return result; } +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; + } + } + xbt_dynar_free(&computer); + } + xbt_dict_free(&computers); + if(acyclic_graph_detection(result)) + return result; + else + WARN0("There is at least one cycle in the provided task graph"); + }else{ + WARN0("The scheduling is ignored"); + } + return NULL; +} + xbt_dynar_t SD_dotload_FILE(FILE * in_file) { xbt_assert0(in_file, "Unable to use a null file descriptor\n"); @@ -273,36 +234,10 @@ xbt_dynar_t SD_dotload_FILE(FILE * in_file) /* Free previous copy of the files */ xbt_dict_free(&files); - if(schedule == false){ - WARN0("No scheduling provided"); - }else{ - 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); - 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; - } - } - xbt_dynar_free(&computer); - } - xbt_dict_free(&computers); - } - acyclic_graph_detection(result); - - return result; + if(acyclic_graph_detection(result)) + return result; + acyclic_graph_detail(result); + return NULL; } /* dot_add_task create a sd_task and all transfers required for this @@ -356,7 +291,7 @@ void dot_add_task(Agnode_t * dag_node) SD_task_dependency_add(NULL, NULL, current_job, end_task); } - if(schedule || true){ + if(schedule || XBT_LOG_ISENABLED(sd_dotparse, xbt_log_priority_verbose)){ /* try to take the information to schedule the task only if all is * right*/ // performer is the computer which execute the task @@ -387,8 +322,8 @@ void dot_add_task(Agnode_t * dag_node) if(task_test != NULL && *task_test != NULL && *task_test != current_job){ /*the user gives the same order to several tasks*/ schedule = false; - WARN0("scheduling does not take into account, several task has\ - the same order"); + VERB4("The task %s starts on the computer %s at the position : %s like the task %s", + (*task_test)->name, char_performer, char_order, current_job->name); }else{ //the parameter seems to be ok xbt_dynar_set_as(computer, order, SD_task_t, current_job); @@ -397,17 +332,13 @@ void dot_add_task(Agnode_t * dag_node) /*the platform has not enough processors to schedule the DAG like *the user wants*/ schedule = false; - WARN0("scheduling does not take into account, not enough computers"); + VERB0("The schedule is ignored, there are not enough computers"); } } - else if((performer == -1 && order != -1) || - (performer != -1 && order == -1)){ + else { //one of necessary parameters are not given schedule = false; - WARN0("scheduling does not take into account"); - } else { - //No schedule available - schedule = false; + VERB1("The schedule is ignored, the task %s is not correctly schedule", current_job->name); } } }