X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/347996b4a10c4e8579080692afa60e0afb88b60a..a3c523fe2be39d16e75fe578d17c0c68a1ff4cee:/src/instr/jedule/jedule_output.cpp diff --git a/src/instr/jedule/jedule_output.cpp b/src/instr/jedule/jedule_output.cpp index 1bac445f37..39874037a2 100644 --- a/src/instr/jedule/jedule_output.cpp +++ b/src/instr/jedule/jedule_output.cpp @@ -13,31 +13,15 @@ #include "simgrid/jedule/jedule_output.h" -#ifdef HAVE_JEDULE +#if HAVE_JEDULE -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_out, jedule, - "Logging specific to Jedule output"); - -/*********************************************************/ +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_out, jedule, "Logging specific to Jedule output"); xbt_dynar_t jedule_event_list; static FILE *jed_file; -static void print_platform(jed_simgrid_container_t root_container); -static void print_container(jed_simgrid_container_t container); -static void print_resources(jed_simgrid_container_t resource_parent); -static void print_key_value_dict(xbt_dict_t meta_info_dict); -static void print_events(xbt_dynar_t event_list); -static void get_hierarchy_list(xbt_dynar_t hier_list, - jed_simgrid_container_t container); - -/*********************************************************/ - - -static void get_hierarchy_list(xbt_dynar_t hier_list, - jed_simgrid_container_t container) { - +static void get_hierarchy_list(xbt_dynar_t hier_list, jed_simgrid_container_t container) { xbt_assert( container != NULL ); if( container->parent != NULL ) { @@ -45,14 +29,12 @@ static void get_hierarchy_list(xbt_dynar_t hier_list, if( container->parent->container_children == NULL ) { // we are in the last level get_hierarchy_list(hier_list, container->parent); - } else { unsigned int i; int child_nb = -1; jed_simgrid_container_t child_container; - xbt_dynar_foreach(container->parent->container_children, i, - child_container) { + xbt_dynar_foreach(container->parent->container_children, i, child_container) { if( child_container == container ) { child_nb = i; break; @@ -60,7 +42,6 @@ static void get_hierarchy_list(xbt_dynar_t hier_list, } xbt_assert( child_nb > - 1); - xbt_dynar_insert_at(hier_list, 0, &child_nb); get_hierarchy_list(hier_list, container->parent); @@ -69,33 +50,31 @@ static void get_hierarchy_list(xbt_dynar_t hier_list, int top_level = 0; xbt_dynar_insert_at(hier_list, 0, &top_level); } - } -static void get_hierarchy_string(jed_simgrid_container_t container, - char *outbuf) { +static void get_hierarchy_string(jed_simgrid_container_t container, char *outbuf, int bufsize) { char buf[1024]; xbt_dynar_t hier_list; unsigned int iter; int number; unsigned int length; - + outbuf[0] = '\0'; hier_list = xbt_dynar_new(sizeof(int), NULL); get_hierarchy_list(hier_list, container); - + length = xbt_dynar_length(hier_list); - + xbt_dynar_foreach(hier_list, iter, number) { if( iter != length-1 ) { - sprintf(buf, "%d.", number); + snprintf(buf, 1024, "%d.", number); } else { - sprintf(buf, "%d", number); + snprintf(buf, 1024, "%d", number); } - strcat(outbuf, buf); + strncat(outbuf, buf, bufsize-strlen(outbuf)-1); } - - xbt_dynar_free(&hier_list); + + xbt_dynar_free(&hier_list); } static void print_key_value_dict(xbt_dict_t key_value_dict) { @@ -109,33 +88,16 @@ static void print_key_value_dict(xbt_dict_t key_value_dict) { } } -static void print_container(jed_simgrid_container_t container) { - unsigned int i; - jed_simgrid_container_t child_container; - - xbt_assert( container != NULL ); - - fprintf(jed_file, " \n", container->name); - if( container->container_children != NULL ) { - xbt_dynar_foreach(container->container_children, i, child_container) { - print_container(child_container); - } - } else { - print_resources(container); - } - fprintf(jed_file, " \n"); -} - static void print_resources(jed_simgrid_container_t resource_parent) { unsigned int res_nb; unsigned int i; char *res_name; - char resid[1024]; + char resid[1024]; xbt_assert( resource_parent->resource_list != NULL ); res_nb = xbt_dynar_length(resource_parent->resource_list); - - get_hierarchy_string(resource_parent, resid); + + get_hierarchy_string(resource_parent, resid, 1024); fprintf(jed_file, " resource_list, i, res_name) { @@ -147,6 +109,22 @@ static void print_resources(jed_simgrid_container_t resource_parent) { fprintf(jed_file, "\" />\n"); } +static void print_container(jed_simgrid_container_t container) { + unsigned int i; + jed_simgrid_container_t child_container; + + xbt_assert( container != NULL ); + + fprintf(jed_file, " \n", container->name); + if( container->container_children != NULL ) { + xbt_dynar_foreach(container->container_children, i, child_container) { + print_container(child_container); + } + } else { + print_resources(container); + } + fprintf(jed_file, " \n"); +} static void print_platform(jed_simgrid_container_t root_container) { fprintf(jed_file, " \n"); @@ -158,46 +136,37 @@ static void print_event(jed_event_t event) { unsigned int i; jed_res_subset_t subset; - xbt_assert( event != NULL ); xbt_assert( event->resource_subsets != NULL ); fprintf(jed_file, " \n"); - fprintf(jed_file, " \n", event->name); - fprintf(jed_file, " \n", - event->start_time); - fprintf(jed_file, " \n", - event->end_time); + fprintf(jed_file, " \n", event->start_time); + fprintf(jed_file, " \n", event->end_time); fprintf(jed_file, " \n", event->type); fprintf(jed_file, " \n"); xbt_dynar_foreach(event->resource_subsets, i, subset) { - int start = subset->start_idx; int end = subset->start_idx + subset->nres - 1; char resid[1024]; - get_hierarchy_string(subset->parent, resid); - + get_hierarchy_string(subset->parent, resid, 1024); fprintf(jed_file, "