Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ansi C declaration of variables.
[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
18         const char * platform_file;
19         const SD_workstation_t *workstations;
20   int ws_nr;
21    SD_workstation_t w1 = NULL;
22   SD_workstation_t w2 = NULL;
23   const char *name1, *name2;
24    int i,j,k;
25
26   /* initialisation of SD */
27   SD_init(&argc, argv);
28
29   /*  xbt_log_control_set("sd.thres=debug"); */
30
31   if (argc < 2) {
32     INFO1("Usage: %s platform_file", argv[0]);
33     INFO1("example: %s sd_platform.xml", argv[0]);
34     exit(1);
35   }
36
37   /* creation of the environment */
38   platform_file = argv[1];
39   SD_create_environment(platform_file);
40
41   /* test the estimation functions */
42   workstations = SD_workstation_get_list();
43   ws_nr = SD_workstation_get_number();
44
45  
46   /* Show routes between all workstation */
47  
48   for (i=0; i<ws_nr; i++){
49     for (j=0;j<ws_nr; j++){
50                  const SD_link_t *route;
51                  int route_size;
52       w1 = workstations[i];
53       w2 = workstations[j];
54       name1 = SD_workstation_get_name(w1);
55       name2 = SD_workstation_get_name(w2);
56       INFO2("Route between %s and %s:", name1, name2);   
57       route = SD_route_get_list(w1, w2);
58       route_size = SD_route_get_size(w1, w2);
59       for (k = 0; k < route_size; k++) {
60         INFO3("\tLink %s: latency = %f, bandwidth = %f", SD_link_get_name(route[k]),
61           SD_link_get_current_latency(route[k]), SD_link_get_current_bandwidth(route[k]));
62       }
63     }
64   }
65
66   SD_exit();
67   return 0;
68 }
69