X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/997eaf52ad0ae1eb34820b135c7ba884b2a17f3c..f74beffac2ba29d933a5edeafb2c1b85196e780c:/src/simdag/sd_daxloader.c diff --git a/src/simdag/sd_daxloader.c b/src/simdag/sd_daxloader.c index a47704d031..9d9d6753b4 100644 --- a/src/simdag/sd_daxloader.c +++ b/src/simdag/sd_daxloader.c @@ -8,6 +8,7 @@ #include "simdag/simdag.h" #include "xbt/misc.h" #include "xbt/log.h" +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd, "Parsing DAX files"); @@ -22,7 +23,7 @@ bool parents_are_marked(SD_task_t task); static void dax_parse_error(char *msg) { fprintf(stderr, "Parse error on line %d: %s\n", dax_lineno, msg); - abort(); + xbt_abort(); } static double dax_parse_double(const char *string) @@ -258,7 +259,7 @@ static void dump_res() unsigned int cursor; SD_task_t task; xbt_dynar_foreach(result, cursor, task) { - XBT_INFO("Task %d", cursor); + XBT_INFO("Task %u", cursor); SD_task_dump(task); } } @@ -286,8 +287,8 @@ xbt_dynar_t SD_daxload(const char *filename) dax_lineno = 1; result = xbt_dynar_new(sizeof(SD_task_t), dax_task_free); - files = xbt_dict_new(); - jobs = xbt_dict_new(); + files = xbt_dict_new_homogeneous(&dax_task_free); + jobs = 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); @@ -312,12 +313,11 @@ xbt_dynar_t SD_daxload(const char *filename) xbt_dict_foreach(files, cursor, name, file) { unsigned int cpt1, cpt2; - SD_task_t newfile = NULL; + SD_task_t newfile; 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); + 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); #ifdef HAVE_TRACING @@ -325,7 +325,7 @@ xbt_dynar_t SD_daxload(const char *filename) const char *category = depafter->src->category; if (category){ TRACE_category (category); - TRACE_sd_set_task_category (newfile, category); + TRACE_sd_set_task_category(newfile, category); } } #endif @@ -333,8 +333,7 @@ xbt_dynar_t SD_daxload(const char *filename) } } 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); + 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); #ifdef HAVE_TRACING @@ -342,7 +341,7 @@ xbt_dynar_t SD_daxload(const char *filename) const char *category = depbefore->src->category; if (category){ TRACE_category (category); - TRACE_sd_set_task_category (newfile, category); + TRACE_sd_set_task_category(newfile, category); } } #endif @@ -356,8 +355,7 @@ xbt_dynar_t SD_daxload(const char *filename) ("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); + 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); #ifdef HAVE_TRACING @@ -365,7 +363,7 @@ xbt_dynar_t SD_daxload(const char *filename) const char *category = depbefore->src->category; if (category){ TRACE_category (category); - TRACE_sd_set_task_category (newfile, category); + TRACE_sd_set_task_category(newfile, category); } } #endif @@ -387,8 +385,16 @@ xbt_dynar_t SD_daxload(const char *filename) } } - acyclic_graph_detail(result); - return result; + if (!acyclic_graph_detail(result)){ + XBT_ERROR("The DAX described in %s is not a DAG. It contains a cycle.", + basename((char*)filename)); + xbt_dynar_foreach(result, cpt, file) + SD_task_destroy(file); + xbt_dynar_free_container(&result); + return NULL; + } else { + return result; + } } void STag_dax__adag(void) @@ -430,7 +436,7 @@ void STag_dax__uses(void) file = xbt_dict_get_or_null(files, A_dax__uses_file); if (file == NULL) { file = SD_task_create_comm_e2e(A_dax__uses_file, NULL, size); - xbt_dict_set(files, A_dax__uses_file, file, &dax_task_free); + xbt_dict_set(files, A_dax__uses_file, file, NULL); } else { if (SD_task_get_amount(file) != size) { XBT_WARN("Ignoring file %s size redefinition from %.0f to %.0f",