1 /* Copyright (c) 2008, 2009, 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
18 #include "simdag/simdag.h"
23 XBT_LOG_NEW_DEFAULT_CATEGORY(validator,
24 "Logging specific to this SimDag example");
26 static int name_compare_hosts(const void *n1, const void *n2)
28 char name1[80], name2[80];
29 strcpy(name1, SD_workstation_get_name(*((SD_workstation_t *) n1)));
30 strcpy(name2, SD_workstation_get_name(*((SD_workstation_t *) n2)));
32 return strcmp(name1, name2);
35 static int name_compare_links(const void *n1, const void *n2)
37 char name1[80], name2[80];
38 strcpy(name1, SD_link_get_name(*((SD_link_t *) n1)));
39 strcpy(name2, SD_link_get_name(*((SD_link_t *) n2)));
41 return strcmp(name1, name2);
44 int main(int argc, char **argv)
46 char *platformFile = NULL;
47 int totalHosts, totalLinks, tmp_length;
49 xbt_dict_t props = NULL;
50 xbt_dict_cursor_t cursor = NULL;
54 const SD_workstation_t *hosts;
55 const SD_link_t *links, *tmp;
59 platformFile = argv[1];
60 DEBUG1("%s", platformFile);
62 SD_create_environment(platformFile);
64 xbt_die(bprintf("Error while loading %s: %s",platformFile,e.msg));
68 printf("<?xml version='1.0'?>\n");
69 printf("<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n");
70 printf("<platform version=\"3\">\n");
71 printf("<AS id=\"AS0\" routing=\"Full\">\n");
73 totalHosts = SD_workstation_get_number();
74 hosts = SD_workstation_get_list();
75 qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t),
78 for (i = 0; i < totalHosts; i++) {
79 printf(" <host id=\"%s\" power=\"%.0f\"",
80 SD_workstation_get_name(hosts[i]),
81 SD_workstation_get_power(hosts[i]));
82 props = SD_workstation_get_properties(hosts[i]);
83 if (xbt_dict_length(props) > 0) {
85 xbt_dict_foreach(props, cursor, key, data) {
86 printf(" <prop id=\"%s\" value=\"%s\"/>\n", key, data);
94 totalLinks = SD_link_get_number();
95 links = SD_link_get_list();
96 qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links);
98 for (i = 0; i < totalLinks; i++) {
99 printf(" <link id=\"");
101 printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"",
102 SD_link_get_name(links[i]),
103 SD_link_get_current_bandwidth(links[i]),
104 SD_link_get_current_latency(links[i]));
105 if (SD_link_get_sharing_policy(links[i]) == SD_LINK_SHARED) {
108 printf(" sharing_policy=\"FATPIPE\"/>\n");
112 for (i = 0; i < totalHosts; i++) {
113 for (j = 0; j < totalHosts; j++) {
114 tmp = SD_route_get_list(hosts[i], hosts[j]);
116 printf(" <route src=\"%s\" dst=\"%s\">\n ",
117 SD_workstation_get_name(hosts[i]),
118 SD_workstation_get_name(hosts[j]));
120 tmp_length = SD_route_get_size(hosts[i], hosts[j]);
121 for (k = 0; k < tmp_length; k++) {
122 printf("<link_ctn id=\"%s\"/>", SD_link_get_name(tmp[k]));
124 printf("\n </route>\n");
129 printf("</platform>\n");