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) {
39 char *platformFile=NULL;
40 int totalHosts, totalLinks, tmp_length;
42 xbt_dict_t props = NULL;
43 xbt_dict_cursor_t cursor=NULL;
46 const SD_workstation_t *hosts;
47 const SD_link_t *links, *tmp;
51 platformFile = argv[1];
52 DEBUG1("%s",platformFile);
53 SD_create_environment(platformFile);
55 printf ("<?xml version='1.0'?>\n");
56 printf ("<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n");
57 printf ("<platform version=\"2\">\n");
59 totalHosts = SD_workstation_get_number();
60 hosts = SD_workstation_get_list();
61 qsort((void *)hosts, totalHosts, sizeof(SD_workstation_t),
64 for (i=0;i<totalHosts;i++){
65 printf(" <host id=\"%s\" power=\"%.0f\"",
66 SD_workstation_get_name(hosts[i]),
67 SD_workstation_get_power(hosts[i]));
68 props = SD_workstation_get_properties(hosts[i]);
69 if (xbt_dict_length(props)>0) {
71 xbt_dict_foreach(props,cursor,key,data) {
72 printf(" <prop id=\"%s\" value=\"%s\"/>\n",key,data);
80 totalLinks = SD_link_get_number();
81 links = SD_link_get_list();
82 qsort((void *)links, totalLinks, sizeof(SD_link_t),
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");