1 /* Copyright (c) 2006-2016. 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. */
7 #include "src/simdag/simdag_private.h"
8 #include "simgrid/s4u/host.hpp"
9 #include "src/surf/HostImpl.hpp"
10 #include "surf/surf.h"
12 /** @brief Returns the route between two workstations
14 * Use SD_route_get_size() to know the array size.
17 * \param dst another host
18 * \return an array of the \ref SD_link_t composing the route
19 * \see SD_route_get_size(), SD_link_t
21 SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst)
23 std::vector<Link*> *route = new std::vector<Link*>();
24 routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, nullptr);
27 SD_link_t *list = xbt_new(SD_link_t, route->size());
28 for (auto link : *route){
37 * \brief Returns the number of links on the route between two workstations
39 * \param src a workstation
40 * \param dst another workstation
41 * \return the number of links on the route between these two workstations
42 * \see SD_route_get_list()
44 int SD_route_get_size(sg_host_t src, sg_host_t dst)
46 std::vector<Link*> *route = new std::vector<Link*>();
47 routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, nullptr);
48 int size = route->size();
54 * \brief Returns the latency of the route between two workstations.
56 * \param src the first workstation
57 * \param dst the second workstation
58 * \return the latency of the route between the two workstations (in seconds)
59 * \see SD_route_get_bandwidth()
61 double SD_route_get_latency(sg_host_t src, sg_host_t dst)
64 std::vector<Link*> *route = new std::vector<Link*>();
65 routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, &latency);
72 * \brief Returns the bandwidth of the route between two workstations,
73 * i.e. the minimum link bandwidth of all between the workstations.
75 * \param src the first workstation
76 * \param dst the second workstation
77 * \return the bandwidth of the route between the two workstations (in bytes/second)
78 * \see SD_route_get_latency()
80 double SD_route_get_bandwidth(sg_host_t src, sg_host_t dst)
82 double min_bandwidth = -1.0;
84 std::vector<Link*> *route = new std::vector<Link*>();
85 routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, nullptr);
87 for (auto link : *route) {
88 double bandwidth = sg_link_bandwidth(link);
89 if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
90 min_bandwidth = bandwidth;