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/surf/host_interface.hpp"
8 #include "src/simdag/simdag_private.h"
9 #include "simgrid/simdag.h"
10 #include "simgrid/host.h"
11 #include <simgrid/s4u/host.hpp>
14 #include "xbt/sysdep.h"
15 #include "surf/surf.h"
17 /** @brief Returns the route between two workstations
19 * Use SD_route_get_size() to know the array size.
22 * \param dst another host
23 * \return an array of the \ref SD_link_t composing the route
24 * \see SD_route_get_size(), SD_link_t
26 SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst)
30 xbt_dynar_t surf_route = surf_host_model_get_route((surf_host_model_t)surf_host_model, src, dst);
32 SD_link_t *list = xbt_new(SD_link_t, xbt_dynar_length(surf_route));
33 xbt_dynar_foreach(surf_route, cpt, surf_link) {
34 list[cpt] = (SD_link_t)surf_link;
40 * \brief Returns the number of links on the route between two workstations
42 * \param src a workstation
43 * \param dst another workstation
44 * \return the number of links on the route between these two workstations
45 * \see SD_route_get_list()
47 int SD_route_get_size(sg_host_t src, sg_host_t dst)
49 return xbt_dynar_length(surf_host_model_get_route((surf_host_model_t)surf_host_model, src, dst));
53 * \brief Returns the latency of the route between two workstations.
55 * \param src the first workstation
56 * \param dst the second workstation
57 * \return the latency of the route between the two workstations (in seconds)
58 * \see SD_route_get_bandwidth()
60 double SD_route_get_latency(sg_host_t src, sg_host_t dst)
62 xbt_dynar_t route = NULL;
65 routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &route, &latency);
71 * \brief Returns the bandwidth of the route between two workstations,
72 * i.e. the minimum link bandwidth of all between the workstations.
74 * \param src the first workstation
75 * \param dst the second workstation
76 * \return the bandwidth of the route between the two workstations (in bytes/second)
77 * \see SD_route_get_latency()
79 double SD_route_get_bandwidth(sg_host_t src, sg_host_t dst)
81 xbt_dynar_t route = NULL;
84 double min_bandwidth = -1.0;
87 routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &route, &latency);
89 xbt_dynar_foreach(route, cpt, link){
90 double bandwidth = sg_link_bandwidth(link);
91 if (bandwidth < min_bandwidth || min_bandwidth == -1.0)
92 min_bandwidth = bandwidth;