Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright notices
[simgrid.git] / examples / simdag / metaxml / sd_meta.c
1 /* Copyright (c) 2007-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 /* See examples/platforms/metaxml.xml and examples/platforms/metaxml_platform.xml 
8    for examples on how to use the cluster, foreach, set, route:multi, trace and trace:connect tags
9 */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include "simgrid/simdag.h"
14 #include "xbt/ex.h"
15 #include "xbt/log.h"
16 #include "xbt/dynar.h"
17 #include "xbt/dict.h"
18
19 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test,
20                              "Logging specific to this SimDag example");
21
22 int main(int argc, char **argv)
23 {
24
25   const char *platform_file;
26   const SD_workstation_t *workstations;
27   int ws_nr;
28   SD_workstation_t w1 = NULL;
29   SD_workstation_t w2 = NULL;
30   const char *name1, *name2;
31   int i, j, k;
32
33   /* initialisation of SD */
34   SD_init(&argc, argv);
35
36   /*  xbt_log_control_set("sd.thres=debug"); */
37
38   if (argc < 2) {
39     XBT_INFO("Usage: %s platform_file", argv[0]);
40     XBT_INFO("example: %s sd_platform.xml", argv[0]);
41     exit(1);
42   }
43
44   /* creation of the environment */
45   platform_file = argv[1];
46   SD_create_environment(platform_file);
47
48   /* test the estimation functions */
49   workstations = SD_workstation_get_list();
50   ws_nr = SD_workstation_get_number();
51
52
53   /* Show routes between all workstation */
54
55   for (i = 0; i < ws_nr; i++) {
56     for (j = 0; j < ws_nr; j++) {
57       const SD_link_t *route;
58       int route_size;
59       w1 = workstations[i];
60       w2 = workstations[j];
61       name1 = SD_workstation_get_name(w1);
62       name2 = SD_workstation_get_name(w2);
63       XBT_INFO("Route between %s and %s:", name1, name2);
64       route = SD_route_get_list(w1, w2);
65       route_size = SD_route_get_size(w1, w2);
66       for (k = 0; k < route_size; k++) {
67         XBT_INFO("\tLink %s: latency = %f, bandwidth = %f",
68               SD_link_get_name(route[k]),
69               SD_link_get_current_latency(route[k]),
70               SD_link_get_current_bandwidth(route[k]));
71       }
72     }
73   }
74
75   SD_exit();
76   return 0;
77 }