From 0438cb0afe03a5f104af019df44f52aec27d2458 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 8 Nov 2012 20:36:58 +0100 Subject: [PATCH] enhance the flatifier so that it can be used for platform parsing performance measurement --- teshsuite/simdag/platforms/flatifier.c | 226 +++++++++++++------------ 1 file changed, 120 insertions(+), 106 deletions(-) diff --git a/teshsuite/simdag/platforms/flatifier.c b/teshsuite/simdag/platforms/flatifier.c index c2e576d7cf..de0bd15007 100644 --- a/teshsuite/simdag/platforms/flatifier.c +++ b/teshsuite/simdag/platforms/flatifier.c @@ -22,8 +22,8 @@ #include "surf/surf.h" #include "surf/surf_private.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(validator, - "Logging specific to this SimDag example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(flatifier, + "Logging specific to this platform parsing tool"); static int name_compare_hosts(const void *n1, const void *n2) { @@ -47,6 +47,7 @@ int main(int argc, char **argv) { char *platformFile = NULL; int totalHosts, totalLinks; + int timings=0; unsigned int i; xbt_dict_t props = NULL; xbt_dict_cursor_t cursor = NULL; @@ -59,80 +60,92 @@ int main(int argc, char **argv) const SD_workstation_t *hosts; const SD_link_t *links; + xbt_os_timer_t parse_time = xbt_os_timer_new(); setvbuf(stdout, NULL, _IOLBF, 0); SD_init(&argc, argv); platformFile = argv[1]; + if (!strcmp(platformFile,"--timings")) { + platformFile=argv[2]; + timings=1; + } + XBT_DEBUG("%s", platformFile); TRY { + xbt_os_timer_start(parse_time); SD_create_environment(platformFile); + xbt_os_timer_stop(parse_time); } CATCH(e) { xbt_die("Error while loading %s: %s",platformFile,e.msg); } - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); - - // Hosts - totalHosts = SD_workstation_get_number(); - hosts = SD_workstation_get_list(); - qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t), + if (timings) { + XBT_INFO("Parsing time: %fs (%d hosts, %d links)", + xbt_os_timer_elapsed(parse_time),SD_workstation_get_number(),SD_link_get_number()); + } else { + printf("\n"); + printf("\n"); + printf("\n"); + printf("\n"); + + // Hosts + totalHosts = SD_workstation_get_number(); + hosts = SD_workstation_get_list(); + qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t), name_compare_hosts); - for (i = 0; i < totalHosts; i++) { - printf(" \n"); - xbt_dict_foreach(props, cursor, key, data) { - printf(" \n", key, data); + for (i = 0; i < totalHosts; i++) { + printf(" \n"); + xbt_dict_foreach(props, cursor, key, data) { + printf(" \n", key, data); + } + printf(" \n"); + } else { + printf("/>\n"); } - printf(" \n"); - } else { - printf("/>\n"); } - } - // Routers - xbt_lib_foreach(as_router_lib, cursor_src, key, value1) { - if(((sg_routing_edge_t)xbt_lib_get_or_null(as_router_lib, key, - ROUTING_ASR_LEVEL))->rc_type == SURF_NETWORK_ELEMENT_ROUTER) - { - printf(" \n",key); + // Routers + xbt_lib_foreach(as_router_lib, cursor_src, key, value1) { + if(((sg_routing_edge_t)xbt_lib_get_or_null(as_router_lib, key, + ROUTING_ASR_LEVEL))->rc_type == SURF_NETWORK_ELEMENT_ROUTER) + { + printf(" \n",key); + } } - } - // Links - totalLinks = SD_link_get_number(); - links = SD_link_get_list(); + // Links + totalLinks = SD_link_get_number(); + links = SD_link_get_list(); - qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links); + qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links); - for (i = 0; i < totalLinks; i++) { - printf(" \n"); - } else { - printf(" sharing_policy=\"FATPIPE\"/>\n"); + printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", + SD_link_get_name(links[i]), + SD_link_get_current_bandwidth(links[i]), + SD_link_get_current_latency(links[i])); + if (SD_link_get_sharing_policy(links[i]) == SD_LINK_SHARED) { + printf("/>\n"); + } else { + printf(" sharing_policy=\"FATPIPE\"/>\n"); + } } - } - xbt_lib_foreach(host_lib, cursor_src, src, value1) // Routes from host - { - value1 = xbt_lib_get_or_null(host_lib,src,ROUTING_HOST_LEVEL); + xbt_lib_foreach(host_lib, cursor_src, src, value1) // Routes from host + { + value1 = xbt_lib_get_or_null(host_lib,src,ROUTING_HOST_LEVEL); xbt_lib_foreach(host_lib, cursor_dst, dst, value2) //to host { printf(" \n " @@ -153,72 +166,73 @@ int main(int argc, char **argv) } xbt_lib_foreach(as_router_lib, cursor_dst, dst, value2) //to router { - if(routing_get_network_element_type(dst) == SURF_NETWORK_ELEMENT_ROUTER){ - printf(" \n " - ,src - ,dst); - xbt_dynar_t route=NULL; - value2 = xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL); - routing_get_route_and_latency((sg_routing_edge_t)value1,(sg_routing_edge_t)value2,&route,NULL); - for(i=0;iname); - printf("",link_name); - free(link_name); - } - printf("\n \n"); + if(routing_get_network_element_type(dst) == SURF_NETWORK_ELEMENT_ROUTER){ + printf(" \n " + ,src + ,dst); + xbt_dynar_t route=NULL; + value2 = xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL); + routing_get_route_and_latency((sg_routing_edge_t)value1,(sg_routing_edge_t)value2,&route,NULL); + for(i=0;iname); + printf("",link_name); + free(link_name); } + printf("\n \n"); + } } - } + } - xbt_lib_foreach(as_router_lib, cursor_src, src, value1) // Routes from router - { + xbt_lib_foreach(as_router_lib, cursor_src, src, value1) // Routes from router + { value1 = xbt_lib_get_or_null(as_router_lib,src,ROUTING_ASR_LEVEL); - if(routing_get_network_element_type(src) == SURF_NETWORK_ELEMENT_ROUTER){ - xbt_lib_foreach(as_router_lib, cursor_dst, dst, value2) //to router - { - if(routing_get_network_element_type(dst) == SURF_NETWORK_ELEMENT_ROUTER){ - printf(" \n " - ,src - ,dst); - xbt_dynar_t route=NULL; - value2 = xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL); - routing_get_route_and_latency((sg_routing_edge_t)value1,(sg_routing_edge_t)value2,&route,NULL); - for(i=0;iname); - printf("",link_name); - free(link_name); - } - printf("\n \n"); - } - } - xbt_lib_foreach(host_lib, cursor_dst, dst, value2) //to host - { - printf(" \n " - ,src, dst); - xbt_dynar_t route=NULL; - value2 = xbt_lib_get_or_null(host_lib,dst,ROUTING_HOST_LEVEL); - routing_get_route_and_latency((sg_routing_edge_t)value1,(sg_routing_edge_t)value2,&route, NULL); - for(i=0;i\n " + ,src + ,dst); + xbt_dynar_t route=NULL; + value2 = xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL); + routing_get_route_and_latency((sg_routing_edge_t)value1,(sg_routing_edge_t)value2,&route,NULL); + for(i=0;iname); + printf("",link_name); + free(link_name); + } + printf("\n \n"); + } + } + xbt_lib_foreach(host_lib, cursor_dst, dst, value2) //to host { - void *link = xbt_dynar_get_as(route,i,void *); - - char *link_name = xbt_strdup(((surf_resource_t)link)->name); - printf("",link_name); - free(link_name); + printf(" \n " + ,src, dst); + xbt_dynar_t route=NULL; + value2 = xbt_lib_get_or_null(host_lib,dst,ROUTING_HOST_LEVEL); + routing_get_route_and_latency((sg_routing_edge_t)value1,(sg_routing_edge_t)value2,&route, NULL); + for(i=0;iname); + printf("",link_name); + free(link_name); + } + printf("\n \n"); } - printf("\n \n"); } } - } - printf("\n"); - printf("\n"); + printf("\n"); + printf("\n"); + } SD_exit(); return 0; -- 2.20.1