9 #include "simdag/simdag.h"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(validator,
14 "Logging specific to this SimDag example");
16 static int name_compare_hosts(const void *n1, const void *n2)
18 char name1[80], name2[80];
19 strcpy(name1, SD_workstation_get_name(*((SD_workstation_t *)n1)));
20 strcpy(name2, SD_workstation_get_name(*((SD_workstation_t *)n2)));
22 return strcmp(name1,name2);
25 static int name_compare_links(const void *n1, const void *n2)
27 char name1[80], name2[80];
28 strcpy(name1, SD_link_get_name(*((SD_link_t *)n1)));
29 strcpy(name2, SD_link_get_name(*((SD_link_t *)n2)));
31 return strcmp(name1,name2);
34 int main(int argc, char **argv) {
35 char *platformFile=NULL;
36 int totalHosts, totalLinks, tmp_length;
38 xbt_dict_t props = NULL;
39 xbt_dict_cursor_t cursor=NULL;
42 const SD_workstation_t *hosts;
43 const SD_link_t *links, *tmp;
47 platformFile = argv[1];
48 DEBUG1("%s",platformFile);
49 SD_create_environment(platformFile);
51 printf ("<?xml version='1.0'?>\n");
52 printf ("<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n");
53 printf ("<platform version=\"2\">\n");
55 totalHosts = SD_workstation_get_number();
56 hosts = SD_workstation_get_list();
57 qsort((void *)hosts, totalHosts, sizeof(SD_workstation_t),
60 for (i=0;i<totalHosts;i++){
61 printf(" <host id=\"%s\" power=\"%.0f\"",
62 SD_workstation_get_name(hosts[i]),
63 SD_workstation_get_power(hosts[i]));
64 props = SD_workstation_get_properties(hosts[i]);
65 if (xbt_dict_length(props)>0) {
67 xbt_dict_foreach(props,cursor,key,data) {
68 printf(" <prop id=\"%s\" value=\"%s\"/>\n",key,data);
76 totalLinks = SD_link_get_number();
77 links = SD_link_get_list();
78 qsort((void *)links, totalLinks, sizeof(SD_link_t),
81 for (i=0;i<totalLinks;i++){
82 printf(" <link id=\"");
84 printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"",
85 SD_link_get_name(links[i]),
86 SD_link_get_current_bandwidth(links[i]),
87 SD_link_get_current_latency(links[i]));
88 if (SD_link_get_sharing_policy(links[i])== SD_LINK_SHARED) {
91 printf(" sharing_policy=\"FATPIPE\"/>\n");
95 for (i=0;i<totalHosts;i++){
96 for (j=0;j<totalHosts;j++){
97 tmp = SD_route_get_list(hosts[i],hosts[j]);
99 printf (" <route src=\"%s\" dst=\"%s\">\n ",
100 SD_workstation_get_name(hosts[i]),
101 SD_workstation_get_name(hosts[j]));
103 tmp_length = SD_route_get_size(hosts[i],hosts[j]);
104 for (k=0; k<tmp_length;k++){
105 printf("<link:ctn id=\"%s\"/>", SD_link_get_name(tmp[k]));
107 printf("\n </route>\n");
111 printf("</platform>\n");