#include <xbt/graph.h>
#include <map>
+#include <unordered_set>
#include <vector>
namespace simgrid {
/** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
/* returns whether we found a bypass path */
bool get_bypass_route(routing::NetPoint* src, routing::NetPoint* dst,
- /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency);
+ /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
+ std::unordered_set<NetZoneImpl*>& netzones);
public:
enum class RoutingMode {
void set_disk_model(std::shared_ptr<resource::DiskModel> disk_model);
void set_host_model(std::shared_ptr<surf::HostModel> host_model);
- /* @brief get the route between two nodes in the full platform
+ /** @brief get the route between two nodes in the full platform
*
* @param src where from
* @param dst where to
static void get_global_route(routing::NetPoint* src, routing::NetPoint* dst,
/* OUT */ std::vector<resource::LinkImpl*>& links, double* latency);
+ /** @brief Similar to get_global_route but get the NetZones traversed by route */
+ static void get_global_route_with_netzones(routing::NetPoint* src, routing::NetPoint* dst,
+ /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
+ std::unordered_set<NetZoneImpl*>& netzones);
+
virtual void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
std::map<std::string, xbt_edge_t, std::less<>>* edges) = 0;
std::shared_ptr<resource::DiskModel> disk_model_;
std::shared_ptr<simgrid::surf::HostModel> host_model_;
/** @brief Perform sealing procedure for derived classes, if necessary */
- virtual void do_seal() { /* obviously nothing to do by default */ }
+ virtual void do_seal()
+ { /* obviously nothing to do by default */
+ }
void add_child(NetZoneImpl* new_zone);
};
} // namespace routing
/* PRECONDITION: this is the common ancestor of src and dst */
bool NetZoneImpl::get_bypass_route(NetPoint* src, NetPoint* dst,
- /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency)
+ /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
+ std::unordered_set<NetZoneImpl*>& netzones)
{
// If never set a bypass route return nullptr without any further computations
if (bypass_routes_.empty())
"calls to getRoute",
src->get_cname(), dst->get_cname(), bypassedRoute->links.size());
if (src != key.first)
- get_global_route(src, bypassedRoute->gw_src, links, latency);
+ get_global_route_with_netzones(src, bypassedRoute->gw_src, links, latency, netzones);
for (resource::LinkImpl* const& link : bypassedRoute->links) {
links.push_back(link);
if (latency)
*latency += link->get_latency();
}
if (dst != key.second)
- get_global_route(bypassedRoute->gw_dst, dst, links, latency);
+ get_global_route_with_netzones(bypassedRoute->gw_dst, dst, links, latency, netzones);
return true;
}
XBT_DEBUG("No bypass route from '%s' to '%s'.", src->get_cname(), dst->get_cname());
void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst,
/* OUT */ std::vector<resource::LinkImpl*>& links, double* latency)
+{
+ std::unordered_set<NetZoneImpl*> netzones;
+ get_global_route_with_netzones(src, dst, links, latency, netzones);
+}
+
+void NetZoneImpl::get_global_route_with_netzones(NetPoint* src, NetPoint* dst,
+ /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
+ std::unordered_set<NetZoneImpl*>& netzones)
{
Route route;
XBT_DEBUG("elements_father: common ancestor '%s' src ancestor '%s' dst ancestor '%s'", common_ancestor->get_cname(),
src_ancestor->get_cname(), dst_ancestor->get_cname());
+ netzones.insert(src->get_englobing_zone());
+ netzones.insert(dst->get_englobing_zone());
+ netzones.insert(common_ancestor);
/* Check whether a direct bypass is defined. If so, use it and bail out */
- if (common_ancestor->get_bypass_route(src, dst, links, latency))
+ if (common_ancestor->get_bypass_route(src, dst, links, latency, netzones))
return;
/* If src and dst are in the same netzone, life is good */
}
/* Not in the same netzone, no bypass. We'll have to find our path between the netzones recursively */
-
common_ancestor->get_local_route(src_ancestor->netpoint_, dst_ancestor->netpoint_, &route, latency);
xbt_assert((route.gw_src_ != nullptr) && (route.gw_dst_ != nullptr), "Bad gateways for route from '%s' to '%s'.",
src->get_cname(), dst->get_cname());
/* If source gateway is not our source, we have to recursively find our way up to this point */
if (src != route.gw_src_)
- get_global_route(src, route.gw_src_, links, latency);
+ get_global_route_with_netzones(src, route.gw_src_, links, latency, netzones);
links.insert(links.end(), begin(route.link_list_), end(route.link_list_));
/* If dest gateway is not our destination, we have to recursively find our way from this point */
if (route.gw_dst_ != dst)
- get_global_route(route.gw_dst_, dst, links, latency);
+ get_global_route_with_netzones(route.gw_dst_, dst, links, latency, netzones);
}
void NetZoneImpl::seal()
double latency = 0.0;
std::vector<LinkImpl*> back_route;
std::vector<LinkImpl*> route;
+ std::unordered_set<kernel::routing::NetZoneImpl*> netzones;
XBT_IN("(%s,%s,%g,%g)", src->get_cname(), dst->get_cname(), size, rate);
- src->route_to(dst, route, &latency);
+ kernel::routing::NetZoneImpl::get_global_route_with_netzones(src->get_netpoint(), dst->get_netpoint(), route,
+ &latency, netzones);
+
xbt_assert(not route.empty() || latency > 0,
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->get_cname(), dst->get_cname());
{
latency_check(value);
- double delta = value - latency_.peak;
+ double delta = value - latency_.peak;
const kernel::lmm::Element* elem = nullptr;
const kernel::lmm::Element* nextelem = nullptr;
int numelem = 0;