X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dff9e15c44ab6340d27215957c56fa72fad246a2..4ce83dbcd75d127f670498bd137f4216d7f646c9:/teshsuite/simdag/platforms/flatifier.c diff --git a/teshsuite/simdag/platforms/flatifier.c b/teshsuite/simdag/platforms/flatifier.c index 33ea0642ce..4ec7ebdd35 100644 --- a/teshsuite/simdag/platforms/flatifier.c +++ b/teshsuite/simdag/platforms/flatifier.c @@ -1,5 +1,10 @@ +/* Copyright (c) 2008, 2009, 2010. The SimGrid Team. + * All rights reserved. */ -#ifndef WIN32 +/* 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 @@ -13,6 +18,9 @@ #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"); @@ -38,25 +46,39 @@ static int name_compare_links(const void *n1, const void *n2) int main(int argc, char **argv) { char *platformFile = NULL; - int totalHosts, totalLinks, tmp_length; - int i, j, k; + int totalHosts, totalLinks; + unsigned int i; xbt_dict_t props = NULL; xbt_dict_cursor_t cursor = NULL; - char *key, *data; + xbt_lib_cursor_t cursor_src = NULL; + xbt_lib_cursor_t cursor_dst = NULL; + char *src,*dst,*key,*data; + sg_routing_edge_t value1; + sg_routing_edge_t value2; + xbt_ex_t e; const SD_workstation_t *hosts; - const SD_link_t *links, *tmp; + const SD_link_t *links; + + setvbuf(stdout, NULL, _IOLBF, 0); SD_init(&argc, argv); platformFile = argv[1]; - DEBUG1("%s", platformFile); - SD_create_environment(platformFile); + XBT_DEBUG("%s", platformFile); + TRY { + SD_create_environment(platformFile); + } + CATCH(e) { + xbt_die("Error while loading %s: %s",platformFile,e.msg); + } 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), @@ -67,7 +89,7 @@ int main(int argc, char **argv) SD_workstation_get_name(hosts[i]), SD_workstation_get_power(hosts[i])); props = SD_workstation_get_properties(hosts[i]); - if (xbt_dict_length(props) > 0) { + if (props && !xbt_dict_is_empty(props)) { printf(">\n"); xbt_dict_foreach(props, cursor, key, data) { printf(" \n", key, data); @@ -78,8 +100,19 @@ int main(int argc, char **argv) } } + // 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(); + qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links); for (i = 0; i < totalLinks; i++) { @@ -96,22 +129,95 @@ int main(int argc, char **argv) } } - for (i = 0; i < totalHosts; i++) { - for (j = 0; j < totalHosts; j++) { - tmp = SD_route_get_list(hosts[i], hosts[j]); - if (tmp) { - printf(" \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 < tmp_length; k++) { - printf("", SD_link_get_name(tmp[k])); - } - printf("\n \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_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(value1,value2,&route,NULL); + for(i=0;iname); + printf("",link_name); + free(link_name); + } + printf("\n \n"); + } + 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(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;iname); + printf("",link_name); + free(link_name); + } + printf("\n \n"); + } + } + } + + printf("\n"); printf("\n"); SD_exit();