Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
79d75321a334fec3f028f5756d88a978d5289d6b
[simgrid.git] / examples / simdag / metaxml / sd_meta.c
1 /*
2    See examples/platforms/metaxml.xml and examples/platforms/metaxml_platform.xml files for examples on how to use the cluster, foreach, set, route:multi, trace and trace:connect tags
3 */
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include "simdag/simdag.h"
7 #include "xbt/ex.h"
8 #include "xbt/log.h"
9 #include "xbt/dynar.h"
10 #include "xbt/dict.h"
11 #include "xbt/time.h"
12
13 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test,
14                              "Logging specific to this SimDag example");
15
16 int main(int argc, char **argv) {
17   /* initialisation of SD */
18   SD_init(&argc, argv);
19
20   /*  xbt_log_control_set("sd.thres=debug"); */
21
22   if (argc < 2) {
23     INFO1("Usage: %s platform_file", argv[0]);
24     INFO1("example: %s sd_platform.xml", argv[0]);
25     exit(1);
26   }
27
28   /* creation of the environment */
29   const char * platform_file = argv[1];
30   SD_create_environment(platform_file);
31
32   /* test the estimation functions */
33   const SD_workstation_t *workstations = SD_workstation_get_list();
34   int ws_nr = SD_workstation_get_number();
35
36   SD_workstation_t w1 = NULL;
37   SD_workstation_t w2 = NULL;
38   const char *name1, *name2;
39   /* Show routes between all workstation */
40   int i,j,k;
41   for (i=0; i<ws_nr; i++){
42     for (j=0;j<ws_nr; j++){
43       w1 = workstations[i];
44       w2 = workstations[j];
45       name1 = SD_workstation_get_name(w1);
46       name2 = SD_workstation_get_name(w2);
47       INFO2("Route between %s and %s:", name1, name2);   
48       const SD_link_t *route = SD_route_get_list(w1, w2);
49       int route_size = SD_route_get_size(w1, w2);
50       for (k = 0; k < route_size; k++) {
51         INFO3("\tLink %s: latency = %f, bandwidth = %f", SD_link_get_name(route[k]),
52           SD_link_get_current_latency(route[k]), SD_link_get_current_bandwidth(route[k]));
53       }
54     }
55   }
56
57   SD_exit();
58   return 0;
59 }
60