1 /* Copyright (c) 2008-2021. 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 static void test_one_link(const sg_host_t* hosts)
12 const_sg_host_t h1 = hosts[0];
13 const_sg_host_t h2 = hosts[1];
14 const char* name1 = sg_host_get_name(h1);
15 const char* name2 = sg_host_get_name(h2);
17 fprintf(stderr, "Route between %s and %s\n", name1, name2);
18 xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
19 sg_host_get_route(h1, h2, route);
20 fprintf(stderr, "Route size %lu\n", xbt_dynar_length(route));
23 xbt_dynar_foreach (route, i, link)
24 fprintf(stderr, " Link %s: latency = %f, bandwidth = %f\n", sg_link_get_name(link), sg_link_get_latency(link),
25 sg_link_get_bandwidth(link));
26 fprintf(stderr, "Route latency = %f, route bandwidth = %f\n", sg_host_get_route_latency(h1, h2),
27 sg_host_get_route_bandwidth(h1, h2));
28 xbt_dynar_free_container(&route);
31 static void test_full_link(const sg_host_t* hosts)
33 size_t list_size = sg_host_count();
34 for (size_t i = 0; i < list_size; i++) {
35 const_sg_host_t h1 = hosts[i];
36 const char* name1 = sg_host_get_name(h1);
37 for (size_t j = 0; j < list_size; j++) {
38 const_sg_host_t h2 = hosts[j];
39 const char* name2 = sg_host_get_name(h2);
40 fprintf(stderr, "Route between %s and %s\n", name1, name2);
41 xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
42 sg_host_get_route(h1, h2, route);
43 fprintf(stderr, " Route size %lu\n", xbt_dynar_length(route));
46 xbt_dynar_foreach (route, k, link)
47 fprintf(stderr, " Link %s: latency = %f, bandwidth = %f\n", sg_link_get_name(link), sg_link_get_latency(link),
48 sg_link_get_bandwidth(link));
49 fprintf(stderr, " Route latency = %f, route bandwidth = %f\n", sg_host_get_route_latency(h1, h2),
50 sg_host_get_route_bandwidth(h1, h2));
51 xbt_dynar_free_container(&route);
56 int main(int argc, char** argv)
60 /* creation of the environment */
61 SD_create_environment(argv[1]);
62 fprintf(stderr, "Workstation number: %zu, link number: %d\n", sg_host_count(), sg_link_count());
64 sg_host_t* hosts = sg_host_list();
66 if (!strcmp(argv[2], "ONE_LINK"))
68 if (!strcmp(argv[2], "FULL_LINK"))
69 test_full_link(hosts);
70 if (!strcmp(argv[2], "PROP"))
71 fprintf(stderr,"SG_TEST_mem: %s\n", sg_host_get_property_value(sg_host_by_name("host1"), "SG_TEST_mem"));