X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2f5f41cd822689e734e3992cab93d5a99a894df8..ad59c715eccd3974067bc9b65eca0c0c57df58de:/teshsuite/simdag/platforms/flatifier.c diff --git a/teshsuite/simdag/platforms/flatifier.c b/teshsuite/simdag/platforms/flatifier.c index e696ab0bf7..a4859cfd05 100644 --- a/teshsuite/simdag/platforms/flatifier.c +++ b/teshsuite/simdag/platforms/flatifier.c @@ -1,4 +1,13 @@ +/* Copyright (c) 2008, 2009, 2010. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#ifndef _XBT_WIN32 #include +#endif + #include #include #include @@ -9,63 +18,76 @@ #include "simdag/simdag.h" #include "xbt/log.h" #include "xbt/dict.h" +#include "xbt/ex.h" +#include "surf/surf.h" +#include "surf/surf_private.h" XBT_LOG_NEW_DEFAULT_CATEGORY(validator, - "Logging specific to this SimDag example"); + "Logging specific to this SimDag example"); static int name_compare_hosts(const void *n1, const void *n2) { char name1[80], name2[80]; - strcpy(name1, SD_workstation_get_name(*((SD_workstation_t *)n1))); - strcpy(name2, SD_workstation_get_name(*((SD_workstation_t *)n2))); + strcpy(name1, SD_workstation_get_name(*((SD_workstation_t *) n1))); + strcpy(name2, SD_workstation_get_name(*((SD_workstation_t *) n2))); - return strcmp(name1,name2); + return strcmp(name1, name2); } static int name_compare_links(const void *n1, const void *n2) { char name1[80], name2[80]; - strcpy(name1, SD_link_get_name(*((SD_link_t *)n1))); - strcpy(name2, SD_link_get_name(*((SD_link_t *)n2))); + strcpy(name1, SD_link_get_name(*((SD_link_t *) n1))); + strcpy(name2, SD_link_get_name(*((SD_link_t *) n2))); - return strcmp(name1,name2); + return strcmp(name1, name2); } -int main(int argc, char **argv) { - char *platformFile=NULL; - int totalHosts, totalLinks, tmp_length; - int i,j,k; +int main(int argc, char **argv) +{ + char *platformFile = NULL; + int totalHosts, totalLinks; + unsigned int i; xbt_dict_t props = NULL; - xbt_dict_cursor_t cursor=NULL; - char *key,*data; + xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor_src = NULL; + xbt_dict_cursor_t cursor_dst = NULL; + char *src,*dst,*key,*data; + xbt_ex_t e; const SD_workstation_t *hosts; - const SD_link_t *links, *tmp; + const SD_link_t *links; SD_init(&argc, argv); platformFile = argv[1]; - DEBUG1("%s",platformFile); - SD_create_environment(platformFile); + DEBUG1("%s", platformFile); + TRY { + SD_create_environment(platformFile); + } CATCH(e) { + xbt_die(bprintf("Error while loading %s: %s",platformFile,e.msg)); + } - printf ("\n"); - printf ("\n"); - printf ("\n"); - + 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;i0) { + if (xbt_dict_length(props) > 0) { printf(">\n"); - xbt_dict_foreach(props,cursor,key,data) { - printf(" \n",key,data); + xbt_dict_foreach(props, cursor, key, data) { + printf(" \n", key, data); } printf(" \n"); } else { @@ -73,45 +95,70 @@ int main(int argc, char **argv) { } } + // Routers + xbt_dict_foreach(global_routing->where_network_elements, cursor, key, data) { + if(((network_element_info_t)xbt_dict_get(global_routing->where_network_elements, key))->rc_type + == SURF_NETWORK_ELEMENT_ROUTER) + { + printf(" \n",key); + } + } + + // Links totalLinks = SD_link_get_number(); links = SD_link_get_list(); - qsort((void *)links, totalLinks, sizeof(SD_link_t), - name_compare_links); - - for (i=0;i\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"); } } - for (i=0;i\n ", - SD_workstation_get_name(hosts[i]), - SD_workstation_get_name(hosts[j])); - - tmp_length = SD_route_get_size(hosts[i],hosts[j]); - for (k=0; k", SD_link_get_name(tmp[k])); - } - printf("\n \n"); - } - } + // Routes + xbt_dict_foreach(global_routing->where_network_elements, cursor_src, src, data) + { + if(((network_element_info_t)xbt_dict_get(global_routing->where_network_elements, src))->rc_type + == SURF_NETWORK_ELEMENT_ROUTER || + ((network_element_info_t)xbt_dict_get(global_routing->where_network_elements, src))->rc_type + == SURF_NETWORK_ELEMENT_HOST) + { + xbt_dict_foreach(global_routing->where_network_elements, cursor_dst, dst, data) + { + if(((network_element_info_t)xbt_dict_get(global_routing->where_network_elements, dst))->rc_type + == SURF_NETWORK_ELEMENT_ROUTER || + ((network_element_info_t)xbt_dict_get(global_routing->where_network_elements, dst))->rc_type + == SURF_NETWORK_ELEMENT_HOST) + { + printf(" \n " + ,src + ,dst); + xbt_dynar_t route = global_routing->get_route(src,dst); + for(i=0;iname); + printf("",link_name); + } + printf("\n \n"); + + } + } + } } + + printf("\n"); printf("\n"); SD_exit(); - + return 0; } - -