Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
369da0f04d9a443e74f5e5bb506e451ac746b9d6
[simgrid.git] / examples / simdag / metaxml / sd_meta.c
1 /* Copyright (c) 2007, 2008, 2009, 2010. 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 "simdag/simdag.h"
14 #include "xbt/ex.h"
15 #include "xbt/log.h"
16 #include "xbt/dynar.h"
17 #include "xbt/dict.h"
18 #include "xbt/time.h"
19
20 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test,
21                              "Logging specific to this SimDag example");
22
23 int main(int argc, char **argv)
24 {
25
26   const char *platform_file;
27   const SD_workstation_t *workstations;
28   int ws_nr;
29   SD_workstation_t w1 = NULL;
30   SD_workstation_t w2 = NULL;
31   const char *name1, *name2;
32   int i, j, k;
33
34   /* initialisation of SD */
35   SD_init(&argc, argv);
36
37   /*  xbt_log_control_set("sd.thres=debug"); */
38
39   if (argc < 2) {
40     XBT_INFO("Usage: %s platform_file", argv[0]);
41     XBT_INFO("example: %s sd_platform.xml", argv[0]);
42     exit(1);
43   }
44
45   /* creation of the environment */
46   platform_file = argv[1];
47   SD_create_environment(platform_file);
48
49   /* test the estimation functions */
50   workstations = SD_workstation_get_list();
51   ws_nr = SD_workstation_get_number();
52
53
54   /* Show routes between all workstation */
55
56   for (i = 0; i < ws_nr; i++) {
57     for (j = 0; j < ws_nr; j++) {
58       const SD_link_t *route;
59       int route_size;
60       w1 = workstations[i];
61       w2 = workstations[j];
62       name1 = SD_workstation_get_name(w1);
63       name2 = SD_workstation_get_name(w2);
64       XBT_INFO("Route between %s and %s:", name1, name2);
65       route = SD_route_get_list(w1, w2);
66       route_size = SD_route_get_size(w1, w2);
67       for (k = 0; k < route_size; k++) {
68         XBT_INFO("\tLink %s: latency = %f, bandwidth = %f",
69               SD_link_get_name(route[k]),
70               SD_link_get_current_latency(route[k]),
71               SD_link_get_current_bandwidth(route[k]));
72       }
73     }
74   }
75
76   SD_exit();
77   return 0;
78 }