Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add --cfg to tesh.pl
[simgrid.git] / teshsuite / simdag / platforms / basic_parsing_test.c
1 /* Copyright (c) 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 #include <stdio.h>
8 #include <stdlib.h>
9 #include "simdag/simdag.h"
10 #include "surf/surf_private.h"
11
12 extern routing_global_t global_routing;
13
14 int main(int argc, char **argv)
15 {
16   /* initialisation of SD */
17
18   SD_workstation_t w1, w2;
19   const SD_workstation_t *workstations;
20   const SD_link_t *route;
21   const char *name1;
22   const char *name2;
23   int route_size, i, j, k;
24   int list_size;
25
26   SD_init(&argc, argv);
27
28   /* creation of the environment */
29   SD_create_environment(argv[1]);
30   printf("Workstation number: %d, link number: %d\n",
31          SD_workstation_get_number(), SD_link_get_number());
32
33   if (argc == 3) {
34     if (!strcmp(argv[2], "ONE_LINK")) {
35       workstations = SD_workstation_get_list();
36       w1 = workstations[0];
37       w2 = workstations[1];
38       name1 = SD_workstation_get_name(w1);
39       name2 = SD_workstation_get_name(w2);
40
41       printf("Route between %s and %s\n", name1, name2);
42       route = SD_route_get_list(w1, w2);
43       route_size = SD_route_get_size(w1, w2);
44       printf("Route size %d\n", route_size);
45       for (i = 0; i < route_size; i++) {
46         printf("   Link %s: latency = %f, bandwidth = %f\n",
47                SD_link_get_name(route[i]),
48                SD_link_get_current_latency(route[i]),
49                SD_link_get_current_bandwidth(route[i]));
50       }
51       printf("Route latency = %f, route bandwidth = %f\n",
52              SD_route_get_current_latency(w1, w2),
53              SD_route_get_current_bandwidth(w1, w2));
54
55     }
56     if (!strcmp(argv[2], "FULL_LINK")) {
57       workstations = SD_workstation_get_list();
58       list_size = SD_workstation_get_number();
59       for (i = 0; i < list_size; i++) {
60         w1 = workstations[i];
61         name1 = SD_workstation_get_name(w1);
62         for (j = 0; j < list_size; j++) {
63           w2 = workstations[j];
64           name2 = SD_workstation_get_name(w2);
65           printf("Route between %s and %s\n", name1, name2);
66           route = SD_route_get_list(w1, w2);
67           route_size = SD_route_get_size(w1, w2);
68           printf("\tRoute size %d\n", route_size);
69           for (k = 0; k < route_size; k++) {
70             printf("\tLink %s: latency = %f, bandwidth = %f\n",
71                    SD_link_get_name(route[k]),
72                    SD_link_get_current_latency(route[k]),
73                    SD_link_get_current_bandwidth(route[k]));
74           }
75           printf("\tRoute latency = %f, route bandwidth = %f\n",
76                  SD_route_get_current_latency(w1, w2),
77                  SD_route_get_current_bandwidth(w1, w2));
78         }
79       }
80
81     }
82
83   }
84
85   SD_exit();
86   return 0;
87 }