Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The basic parser can be run with option.
[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
11 int main(int argc, char **argv)
12 {
13   /* initialisation of SD */
14
15   SD_workstation_t w1, w2;
16   const SD_workstation_t *workstations;
17   const SD_link_t *route;
18   const char *name1;
19   const char *name2;
20   int route_size,i,j,k;
21   int list_size;
22
23   SD_init(&argc, argv);
24
25   /* creation of the environment */
26   SD_create_environment(argv[1]);
27   printf("Workstation number: %d, link number: %d\n",
28          SD_workstation_get_number(), SD_link_get_number());
29
30 if(argc == 3)
31 {
32         if(!strcmp(argv[2],"ONE_LINK"))
33         {
34           workstations = SD_workstation_get_list();
35           w1 = workstations[0];
36           w2 = workstations[1];
37           name1 = SD_workstation_get_name(w1);
38           name2 = SD_workstation_get_name(w2);
39
40           printf("Route between %s and %s\n", name1, name2);
41           route = SD_route_get_list(w1, w2);
42           route_size = SD_route_get_size(w1, w2);
43           printf("Route size %d\n", route_size);
44           for (i = 0; i < route_size; i++) {
45                   printf("   Link %s: latency = %f, bandwidth = %f\n",
46                           SD_link_get_name(route[i]), SD_link_get_current_latency(route[i]),
47                           SD_link_get_current_bandwidth(route[i]));
48           }
49           printf("Route latency = %f, route bandwidth = %f\n",
50                         SD_route_get_current_latency(w1, w2),
51                         SD_route_get_current_bandwidth(w1, w2));
52         }
53         if(!strcmp(argv[2],"FULL_LINK"))
54         {
55                         workstations = SD_workstation_get_list();
56                         list_size = SD_workstation_get_number();
57                         for(i = 0; i < list_size; i++)
58                         {
59                                 for(j = 0 ; j < list_size; j++)
60                                 {
61                                                   w1 = workstations[i];
62                                                   w2 = workstations[j];
63                                                   name1 = SD_workstation_get_name(w1);
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]), SD_link_get_current_latency(route[k]),
72                                                                   SD_link_get_current_bandwidth(route[k]));
73                                                   }
74                                                   printf("\tRoute latency = %f, route bandwidth = %f\n",
75                                                                 SD_route_get_current_latency(w1, w2),
76                                                                 SD_route_get_current_bandwidth(w1, w2));
77                                 }
78                         }
79
80         }
81
82 }
83
84   SD_exit();
85   return 0;
86 }