1 /* Copyright (c) 2008-2019. The SimGrid Team.
2 * All rights reserved. */
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. */
8 #include "simgrid/simdag.h"
10 int main(int argc, char **argv)
14 /* creation of the environment */
15 SD_create_environment(argv[1]);
16 fprintf(stderr, "Workstation number: %zu, link number: %d\n", sg_host_count(), sg_link_count());
18 sg_host_t *hosts = sg_host_list();
20 if (!strcmp(argv[2], "ONE_LINK")) {
21 sg_host_t h1 = hosts[0];
22 sg_host_t h2 = hosts[1];
23 const char *name1 = sg_host_get_name(h1);
24 const char *name2 = sg_host_get_name(h2);
26 fprintf(stderr, "Route between %s and %s\n", name1, name2);
27 xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
28 sg_host_route(h1, h2, route);
29 fprintf(stderr, "Route size %lu\n", xbt_dynar_length(route));
32 xbt_dynar_foreach(route, i, link)
33 fprintf(stderr, " Link %s: latency = %f, bandwidth = %f\n", sg_link_name(link),
34 sg_link_latency(link), sg_link_bandwidth(link));
35 fprintf(stderr, "Route latency = %f, route bandwidth = %f\n",
36 sg_host_route_latency(h1, h2), sg_host_route_bandwidth(h1, h2));
37 xbt_dynar_free_container(&route);
39 if (!strcmp(argv[2], "FULL_LINK")) {
40 int list_size = sg_host_count();
41 for (int i = 0; i < list_size; i++) {
42 sg_host_t h1 = hosts[i];
43 const char *name1 = sg_host_get_name(h1);
44 for (int j = 0; j < list_size; j++) {
45 sg_host_t h2 = hosts[j];
46 const char *name2 = sg_host_get_name(h2);
47 fprintf(stderr, "Route between %s and %s\n", name1, name2);
48 xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
49 sg_host_route(h1, h2, route);
50 fprintf(stderr, " Route size %lu\n", xbt_dynar_length(route));
53 xbt_dynar_foreach(route, k, link)
54 fprintf(stderr, " Link %s: latency = %f, bandwidth = %f\n",
55 sg_link_name(link), sg_link_latency(link), sg_link_bandwidth(link));
56 fprintf(stderr, " Route latency = %f, route bandwidth = %f\n",
57 sg_host_route_latency(h1, h2), sg_host_route_bandwidth(h1, h2));
58 xbt_dynar_free_container(&route);
62 if (!strcmp(argv[2], "PROP"))
63 fprintf(stderr,"SG_TEST_mem: %s\n", sg_host_get_property_value(sg_host_by_name("host1"), "SG_TEST_mem"));