13 #include "simdag/simdag.h"
17 XBT_LOG_NEW_DEFAULT_CATEGORY(validator,
18 "Logging specific to this SimDag example");
20 static int name_compare_hosts(const void *n1, const void *n2)
22 char name1[80], name2[80];
23 strcpy(name1, SD_workstation_get_name(*((SD_workstation_t *) n1)));
24 strcpy(name2, SD_workstation_get_name(*((SD_workstation_t *) n2)));
26 return strcmp(name1, name2);
29 static int name_compare_links(const void *n1, const void *n2)
31 char name1[80], name2[80];
32 strcpy(name1, SD_link_get_name(*((SD_link_t *) n1)));
33 strcpy(name2, SD_link_get_name(*((SD_link_t *) n2)));
35 return strcmp(name1, name2);
38 int main(int argc, char **argv)
40 char *platformFile = NULL;
41 int totalHosts, totalLinks, tmp_length;
43 xbt_dict_t props = NULL;
44 xbt_dict_cursor_t cursor = NULL;
47 const SD_workstation_t *hosts;
48 const SD_link_t *links, *tmp;
52 platformFile = argv[1];
53 DEBUG1("%s", platformFile);
54 SD_create_environment(platformFile);
56 printf("<?xml version='1.0'?>\n");
57 printf("<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n");
58 printf("<platform version=\"2\">\n");
60 totalHosts = SD_workstation_get_number();
61 hosts = SD_workstation_get_list();
62 qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t),
65 for (i = 0; i < totalHosts; i++) {
66 printf(" <host id=\"%s\" power=\"%.0f\"",
67 SD_workstation_get_name(hosts[i]),
68 SD_workstation_get_power(hosts[i]));
69 props = SD_workstation_get_properties(hosts[i]);
70 if (xbt_dict_length(props) > 0) {
72 xbt_dict_foreach(props, cursor, key, data) {
73 printf(" <prop id=\"%s\" value=\"%s\"/>\n", key, data);
81 totalLinks = SD_link_get_number();
82 links = SD_link_get_list();
83 qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links);
85 for (i = 0; i < totalLinks; i++) {
86 printf(" <link id=\"");
88 printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"",
89 SD_link_get_name(links[i]),
90 SD_link_get_current_bandwidth(links[i]),
91 SD_link_get_current_latency(links[i]));
92 if (SD_link_get_sharing_policy(links[i]) == SD_LINK_SHARED) {
95 printf(" sharing_policy=\"FATPIPE\"/>\n");
99 for (i = 0; i < totalHosts; i++) {
100 for (j = 0; j < totalHosts; j++) {
101 tmp = SD_route_get_list(hosts[i], hosts[j]);
103 printf(" <route src=\"%s\" dst=\"%s\">\n ",
104 SD_workstation_get_name(hosts[i]),
105 SD_workstation_get_name(hosts[j]));
107 tmp_length = SD_route_get_size(hosts[i], hosts[j]);
108 for (k = 0; k < tmp_length; k++) {
109 printf("<link:ctn id=\"%s\"/>", SD_link_get_name(tmp[k]));
111 printf("\n </route>\n");
115 printf("</platform>\n");