XBT_INFO("Route between %s and %s:", h1->getCname(), h2->getCname());
std::vector<sg_link_t> route;
double latency = 0;
- h1->routeTo(h2, &route, &latency);
+ h1->routeTo(h2, route, &latency);
for (auto const& link : route)
XBT_INFO(" Link %s: latency = %f, bandwidth = %f", sg_link_name(link), sg_link_latency(link),
*/
std::unordered_map<std::string, Storage*> const& getMountedStorages();
- void routeTo(Host * dest, std::vector<Link*> * links, double* latency);
- void routeTo(Host * dest, std::vector<surf::LinkImpl*> * links, double* latency);
+ void routeTo(Host* dest, std::vector<Link*>& links, double* latency);
+ void routeTo(Host* dest, std::vector<surf::LinkImpl*>& links, double* latency);
/** Block the calling actor on an execution located on the called host
*
/*** Called on each newly created regular route (not on bypass routes) */
static simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
- std::vector<surf::LinkImpl*>* link_list)>
+ std::vector<surf::LinkImpl*>& link_list)>
onRouteCreation;
static simgrid::xbt::signal<void(NetZone&)> onCreation;
static simgrid::xbt::signal<void(NetZone&)> onSeal;
type = lua_gettable(L,-2);
lua_ensure(type == LUA_TSTRING,
"Attribute 'links' must be specified for any route and must be a string (different links separated by commas or single spaces.");
- route.link_list = new std::vector<simgrid::surf::LinkImpl*>();
std::vector<std::string> names;
const char* str = lua_tostring(L, -1);
boost::split(names, str, boost::is_any_of(", \t\r\n"));
if (names.empty()) {
/* unique name */
- route.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
+ route.link_list.push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
} else {
// Several names separated by , \t\r\n
for (auto const& name : names) {
if (name.length() > 0) {
simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
- route.link_list->push_back(link);
+ route.link_list.push_back(link);
}
}
}
route.gw_dst = nullptr;
sg_platf_new_route(&route);
- delete route.link_list;
return 0;
}
lua_pushstring(L,"links");
lua_gettable(L,-2);
- ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
std::vector<std::string> names;
const char* str = lua_tostring(L, -1);
boost::split(names, str, boost::is_any_of(", \t\r\n"));
if (names.empty()) {
/* unique name with no comma */
- ASroute.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
+ ASroute.link_list.push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
} else {
// Several names separated by , \t\r\n
for (auto const& name : names) {
if (name.length() > 0) {
simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
- ASroute.link_list->push_back(link);
+ ASroute.link_list.push_back(link);
}
}
}
lua_pop(L,1);
sg_platf_new_route(&ASroute);
- delete ASroute.link_list;
return 0;
}
xbt_die("Element '%s' not found!",dst);
std::vector<simgrid::surf::LinkImpl*> route;
- simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(src_elm, dst_elm, &route, nullptr);
+ simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(src_elm, dst_elm, route, nullptr);
for (auto const& link : route)
instr_user_variable(time, link->getCname(), variable, father_type, value, what, nullptr, &user_link_variables);
}
xbt_assert(not src->isRouter(), "Routing from a cluster private router to itself is meaningless");
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePosition(src->id()));
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
if (lat)
*lat += info.first->latency();
return;
if (not src->isRouter()) { // No private link for the private router
if (hasLimiter_) { // limiter for sender
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(src->id()));
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
}
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLimiter(src->id()));
if (info.first) { // link up
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
if (lat)
*lat += info.first->latency();
}
}
if (backbone_) {
- route->link_list->push_back(backbone_);
+ route->link_list.push_back(backbone_);
if (lat)
*lat += backbone_->latency();
}
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLimiter(dst->id()));
if (info.second) { // link down
- route->link_list->push_back(info.second);
+ route->link_list.push_back(info.second);
if (lat)
*lat += info.second->latency();
}
if (hasLimiter_) { // limiter for receiver
info = privateLinks_.at(nodePositionWithLoopback(dst->id()));
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
}
}
}
delete data;
}
-static void graph_edge_data_free(void* e) // FIXME: useless code duplication
+static void graph_edge_data_free(void* e)
{
sg_platf_route_cbarg_t e_route = static_cast<sg_platf_route_cbarg_t>(e);
- if (e_route) {
- delete e_route->link_list;
- delete e_route;
- }
+ delete e_route;
}
/* Utility functions */
if (not found) {
sg_platf_route_cbarg_t e_route = new s_sg_platf_route_cbarg_t;
- e_route->link_list = new std::vector<surf::LinkImpl*>();
- e_route->link_list->push_back(surf_network_model->loopback_);
+ e_route->link_list.push_back(surf_network_model->loopback_);
xbt_graph_new_edge(routeGraph_, node, node, e_route);
}
}
sg_platf_route_cbarg_t e_route = static_cast<sg_platf_route_cbarg_t>(xbt_graph_edge_get_data(edge));
- for (auto const& link : *e_route->link_list) {
- route->link_list->insert(route->link_list->begin(), link);
+ for (auto const& link : e_route->link_list) {
+ route->link_list.insert(route->link_list.begin(), link);
if (lat)
*lat += static_cast<surf::LinkImpl*>(link)->latency();
}
graph_node_data_t data = static_cast<graph_node_data_t>(xbt_graph_node_get_data(u_node));
int u_id = data->graph_id;
sg_platf_route_cbarg_t tmp_e_route = static_cast<sg_platf_route_cbarg_t>(xbt_graph_edge_get_data(edge));
- int cost_v_u = tmp_e_route->link_list->size(); /* count of links, old model assume 1 */
+ int cost_v_u = tmp_e_route->link_list.size(); /* count of links, old model assume 1 */
if (cost_v_u + cost_arr[v_id] < cost_arr[u_id]) {
pred_arr[u_id] = v_id;
NetPoint* gw_dst_net_elm = nullptr;
NetPoint* prev_gw_src_net_elm = nullptr;
- getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, &e_route_as_to_as, nullptr);
- auto pos = route->link_list->begin();
+ getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
+ auto pos = route->link_list.begin();
for (auto const& link : e_route_as_to_as) {
- route->link_list->insert(pos, link);
+ route->link_list.insert(pos, link);
if (lat)
*lat += link->latency();
pos++;
}
}
- for (auto const& link : *e_route->link_list) {
- route->link_list->insert(route->link_list->begin(), link);
+ for (auto const& link : e_route->link_list) {
+ route->link_list.insert(route->link_list.begin(), link);
if (lat)
*lat += static_cast<surf::LinkImpl*>(link)->latency();
}
if ((src->id() == dst->id()) && hasLoopback_) {
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePosition(src->id()));
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
if (latency)
*latency += info.first->latency();
return;
DragonflyRouter* currentRouter = myRouter;
// node->router local link
- route->link_list->push_back(myRouter->myNodes_[myCoords[3] * numLinksperLink_]);
+ route->link_list.push_back(myRouter->myNodes_[myCoords[3] * numLinksperLink_]);
if (latency)
*latency += myRouter->myNodes_[myCoords[3] * numLinksperLink_]->latency();
if (hasLimiter_) { // limiter for sender
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(src->id()));
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
}
if (targetRouter != myRouter) {
// go to the router of our group connected to this one.
if (currentRouter->blade_ != targetCoords[0]) {
// go to the nth router in our chassis
- route->link_list->push_back(currentRouter->greenLinks_[targetCoords[0]]);
+ route->link_list.push_back(currentRouter->greenLinks_[targetCoords[0]]);
if (latency)
*latency += currentRouter->greenLinks_[targetCoords[0]]->latency();
currentRouter = routers_[myCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) +
if (currentRouter->chassis_ != 0) {
// go to the first chassis of our group
- route->link_list->push_back(currentRouter->blackLinks_[0]);
+ route->link_list.push_back(currentRouter->blackLinks_[0]);
if (latency)
*latency += currentRouter->blackLinks_[0]->latency();
currentRouter = routers_[myCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + targetCoords[0]];
}
// go to destination group - the only optical hop
- route->link_list->push_back(currentRouter->blueLinks_[0]);
+ route->link_list.push_back(currentRouter->blueLinks_[0]);
if (latency)
*latency += currentRouter->blueLinks_[0]->latency();
currentRouter = routers_[targetCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + myCoords[0]];
// same group, but same blade ?
if (targetRouter->blade_ != currentRouter->blade_) {
- route->link_list->push_back(currentRouter->greenLinks_[targetCoords[2]]);
+ route->link_list.push_back(currentRouter->greenLinks_[targetCoords[2]]);
if (latency)
*latency += currentRouter->greenLinks_[targetCoords[2]]->latency();
currentRouter = routers_[targetCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + targetCoords[2]];
// same blade, but same chassis ?
if (targetRouter->chassis_ != currentRouter->chassis_) {
- route->link_list->push_back(currentRouter->blackLinks_[targetCoords[1]]);
+ route->link_list.push_back(currentRouter->blackLinks_[targetCoords[1]]);
if (latency)
*latency += currentRouter->blackLinks_[targetCoords[1]]->latency();
}
if (hasLimiter_) { // limiter for receiver
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(dst->id()));
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
}
// router->node local link
- route->link_list->push_back(targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]);
+ route->link_list.push_back(targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]);
if (latency)
*latency += targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]->latency();
}
/* In case destination is the source, and there is a loopback, let's use it instead of going up to a switch */
if (source->id == destination->id && this->hasLoopback_) {
- into->link_list->push_back(source->loopback);
+ into->link_list.push_back(source->loopback);
if (latency)
*latency += source->loopback->latency();
return;
int k = this->upperLevelNodesNumber_[currentNode->level];
d = d % k;
- into->link_list->push_back(currentNode->parents[d]->upLink);
+ into->link_list.push_back(currentNode->parents[d]->upLink);
if (latency)
*latency += currentNode->parents[d]->upLink->latency();
if (this->hasLimiter_)
- into->link_list->push_back(currentNode->limiterLink);
+ into->link_list.push_back(currentNode->limiterLink);
currentNode = currentNode->parents[d]->upNode;
}
while (currentNode != destination) {
for (unsigned int i = 0; i < currentNode->children.size(); i++) {
if (i % this->lowerLevelNodesNumber_[currentNode->level - 1] == destination->label[currentNode->level - 1]) {
- into->link_list->push_back(currentNode->children[i]->downLink);
+ into->link_list.push_back(currentNode->children[i]->downLink);
if (latency)
*latency += currentNode->children[i]->downLink->latency();
currentNode = currentNode->children[i]->downNode;
if (this->hasLimiter_)
- into->link_list->push_back(currentNode->limiterLink);
+ into->link_list.push_back(currentNode->limiterLink);
XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, destination->level,
destination->position, currentNode->id, currentNode->level, currentNode->position);
}
/* Delete link_table */
for (unsigned int i = 0; i < table_size; i++)
for (unsigned int j = 0; j < table_size; j++)
- routing_route_free(TO_FLOYD_LINK(i, j));
+ delete TO_FLOYD_LINK(i, j);
delete[] linkTable_;
delete[] predecessorTable_;
getGlobalRoute(prev_dst_gw, e_route->gw_src, route->link_list, lat);
}
- for (auto const& link : *e_route->link_list) {
- route->link_list->push_back(link);
+ for (auto const& link : e_route->link_list) {
+ route->link_list.push_back(link);
if (lat)
*lat += link->latency();
}
TO_FLOYD_LINK(route->src->id(), route->dst->id()) = newExtendedRoute(hierarchy_, route, 1);
TO_FLOYD_PRED(route->src->id(), route->dst->id()) = route->src->id();
TO_FLOYD_COST(route->src->id(), route->dst->id()) =
- (TO_FLOYD_LINK(route->src->id(), route->dst->id()))->link_list->size();
+ (TO_FLOYD_LINK(route->src->id(), route->dst->id()))->link_list.size();
if (route->symmetrical == true) {
if (route->gw_dst) // netzone route (to adapt the error message, if any)
TO_FLOYD_LINK(route->dst->id(), route->src->id()) = newExtendedRoute(hierarchy_, route, 0);
TO_FLOYD_PRED(route->dst->id(), route->src->id()) = route->dst->id();
TO_FLOYD_COST(route->dst->id(), route->src->id()) =
- (TO_FLOYD_LINK(route->dst->id(), route->src->id()))->link_list->size(); /* count of links, old model assume 1 */
+ (TO_FLOYD_LINK(route->dst->id(), route->src->id()))->link_list.size(); /* count of links, old model assume 1 */
}
}
e_route = new s_sg_platf_route_cbarg_t;
e_route->gw_src = nullptr;
e_route->gw_dst = nullptr;
- e_route->link_list = new std::vector<surf::LinkImpl*>();
- e_route->link_list->push_back(surf_network_model->loopback_);
+ e_route->link_list.push_back(surf_network_model->loopback_);
TO_FLOYD_LINK(i, i) = e_route;
TO_FLOYD_PRED(i, i) = i;
TO_FLOYD_COST(i, i) = 1;
e_route = new s_sg_platf_route_cbarg_t;
e_route->gw_src = nullptr;
e_route->gw_dst = nullptr;
- e_route->link_list = new std::vector<surf::LinkImpl*>();
- e_route->link_list->push_back(surf_network_model->loopback_);
+ e_route->link_list.push_back(surf_network_model->loopback_);
TO_ROUTE_FULL(i, i) = e_route;
}
}
unsigned int table_size = getTableSize();
/* Delete routing table */
for (unsigned int i = 0; i < table_size; i++)
- for (unsigned int j = 0; j < table_size; j++) {
- if (TO_ROUTE_FULL(i, j)) {
- delete TO_ROUTE_FULL(i, j)->link_list;
- delete TO_ROUTE_FULL(i, j);
- }
- }
+ for (unsigned int j = 0; j < table_size; j++)
+ delete TO_ROUTE_FULL(i, j);
delete[] routingTable_;
}
}
if (e_route != nullptr) {
res->gw_src = e_route->gw_src;
res->gw_dst = e_route->gw_dst;
- for (auto const& link : *e_route->link_list) {
- res->link_list->push_back(link);
+ for (auto const& link : e_route->link_list) {
+ res->link_list.push_back(link);
if (lat)
*lat += link->latency();
}
if (e_route->gw_dst) {
XBT_DEBUG("Load bypassNetzoneRoute from %s@%s to %s@%s", e_route->src->getCname(), e_route->gw_src->getCname(),
e_route->dst->getCname(), e_route->gw_dst->getCname());
- xbt_assert(not e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
+ xbt_assert(not e_route->link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
e_route->src->getCname(), e_route->gw_src->getCname(), e_route->dst->getCname(),
e_route->gw_dst->getCname());
xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
e_route->gw_src->getCname(), e_route->dst->getCname(), e_route->gw_dst->getCname());
} else {
XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->getCname(), e_route->dst->getCname());
- xbt_assert(not e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.",
+ xbt_assert(not e_route->link_list.empty(), "Bypass route between %s and %s cannot be empty.",
e_route->src->getCname(), e_route->dst->getCname());
xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
"The bypass route between %s and %s already exists.", e_route->src->getCname(),
/* Build a copy that will be stored in the dict */
kernel::routing::BypassRoute* newRoute = new kernel::routing::BypassRoute(e_route->gw_src, e_route->gw_dst);
- for (auto const& link : *e_route->link_list)
+ for (auto const& link : e_route->link_list)
newRoute->links.push_back(link);
/* Store it */
/* PRECONDITION: this is the common ancestor of src and dst */
bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
- /* OUT */ std::vector<surf::LinkImpl*>* links, double* latency)
+ /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency)
{
// If never set a bypass route return nullptr without any further computations
if (bypassRoutes_.empty())
if (bypassRoutes_.find({src, dst}) != bypassRoutes_.end()) {
BypassRoute* bypassedRoute = bypassRoutes_.at({src, dst});
for (surf::LinkImpl* const& link : bypassedRoute->links) {
- links->push_back(link);
+ links.push_back(link);
if (latency)
*latency += link->latency();
}
if (src != key.first)
getGlobalRoute(src, bypassedRoute->gw_src, links, latency);
for (surf::LinkImpl* const& link : bypassedRoute->links) {
- links->push_back(link);
+ links.push_back(link);
if (latency)
*latency += link->latency();
}
}
void NetZoneImpl::getGlobalRoute(routing::NetPoint* src, routing::NetPoint* dst,
- /* OUT */ std::vector<surf::LinkImpl*>* links, double* latency)
+ /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency)
{
s_sg_platf_route_cbarg_t route{};
/* If src and dst are in the same netzone, life is good */
if (src_ancestor == dst_ancestor) { /* SURF_ROUTING_BASE */
- route.link_list = links;
+ route.link_list = std::move(links);
common_ancestor->getLocalRoute(src, dst, &route, latency);
+ links = std::move(route.link_list);
return;
}
/* Not in the same netzone, no bypass. We'll have to find our path between the netzones recursively */
- route.link_list = new std::vector<surf::LinkImpl*>();
-
common_ancestor->getLocalRoute(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->getCname(), dst->getCname());
/* If source gateway is not our source, we have to recursively find our way up to this point */
if (src != route.gw_src)
getGlobalRoute(src, route.gw_src, links, latency);
- for (auto const& link : *route.link_list)
- links->push_back(link);
- delete route.link_list;
+ for (auto const& link : route.link_list)
+ links.push_back(link);
/* If dest gateway is not our destination, we have to recursively find our way from this point */
if (route.gw_dst != dst)
-/* Copyright (c) 2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/** @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 getBypassRoute(routing::NetPoint * src, routing::NetPoint * dst,
- /* OUT */ std::vector<surf::LinkImpl*> * links, double* latency);
+ /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency);
public:
/* @brief get the route between two nodes in the full platform
* @param latency Accumulator in which the latencies should be added (caller must set it to 0)
*/
static void getGlobalRoute(routing::NetPoint * src, routing::NetPoint * dst,
- /* OUT */ std::vector<surf::LinkImpl*> * links, double* latency);
+ /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency);
virtual void getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t> * nodes,
std::map<std::string, xbt_edge_t> * edges) = 0;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
-void routing_route_free(sg_platf_route_cbarg_t route)
-{
- if (route) {
- delete route->link_list;
- delete route;
- }
-}
-
/* ***************************************************************** */
/* *********************** GENERIC METHODS ************************* */
continue;
sg_platf_route_cbarg_t route = new s_sg_platf_route_cbarg_t;
- route->link_list = new std::vector<surf::LinkImpl*>();
getLocalRoute(my_src, my_dst, route, nullptr);
previous_name = my_src->getCname();
}
- for (auto const& link : *route->link_list) {
+ for (auto const& link : route->link_list) {
const char* link_name = link->getCname();
current = new_xbt_graph_node(graph, link_name, nodes);
current_name = link_name;
new_xbt_graph_edge(graph, previous, current, edges);
XBT_DEBUG(" %s -> %s", previous_name, current_name);
- delete route->link_list;
delete route;
}
}
sg_platf_route_cbarg_t result;
result = new s_sg_platf_route_cbarg_t;
- result->link_list = new std::vector<surf::LinkImpl*>();
xbt_assert(hierarchy == RoutingMode::base || hierarchy == RoutingMode::recursive,
"The hierarchy of this netzone is neither BASIC nor RECURSIVE, I'm lost here.");
result->gw_dst = routearg->gw_dst;
}
- for (auto const& link : *routearg->link_list) {
+ for (auto const& link : routearg->link_list) {
if (change_order)
- result->link_list->push_back(link);
+ result->link_list.push_back(link);
else
- result->link_list->insert(result->link_list->begin(), link);
+ result->link_list.insert(result->link_list.begin(), link);
}
- result->link_list->shrink_to_fit();
+ result->link_list.shrink_to_fit();
return result;
}
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName);
xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName);
xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName);
- xbt_assert(not route->link_list->empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
+ xbt_assert(not route->link_list.empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
xbt_assert(not src->isNetZone(),
"When defining a route, src cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?",
srcName);
dstName, route->gw_dst->getCname(), srcName);
xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->getCname(),
dstName, route->gw_dst->getCname(), dstName);
- xbt_assert(not route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
+ xbt_assert(not route->link_list.empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
route->gw_src->getCname(), dstName, route->gw_dst->getCname());
}
if (src->id() == dst->id() && hasLoopback_) {
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id() * linkCountPerNode_);
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
if (lat)
*lat += info.first->latency();
return;
if (hasLimiter_) { // limiter for sender
info = privateLinks_.at(nodeOffset + (hasLoopback_ ? 1 : 0));
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
}
info = privateLinks_.at(linkOffset);
if (use_lnk_up == false) {
- route->link_list->push_back(info.second);
+ route->link_list.push_back(info.second);
if (lat)
*lat += info.second->latency();
} else {
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
if (lat)
*lat += info.first->latency();
}
if (src_link != privateLinks_.end()) {
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = src_link->second;
if (info.first) {
- route->link_list->push_back(info.first);
+ route->link_list.push_back(info.first);
if (lat)
*lat += info.first->latency();
}
if (dst_link != privateLinks_.end()) {
std::pair<surf::LinkImpl*, surf::LinkImpl*> info = dst_link->second;
if (info.second) {
- route->link_list->push_back(info.second);
+ route->link_list.push_back(info.second);
if (lat)
*lat += info.second->latency();
}
* walk through the routing components tree and find a route between hosts
* by calling each "get_route" function in each routing component.
*/
-void Host::routeTo(Host* dest, std::vector<Link*>* links, double* latency)
+void Host::routeTo(Host* dest, std::vector<Link*>& links, double* latency)
{
std::vector<surf::LinkImpl*> linkImpls;
- this->routeTo(dest, &linkImpls, latency);
+ this->routeTo(dest, linkImpls, latency);
for (surf::LinkImpl* const& l : linkImpls)
- links->push_back(&l->piface_);
+ links.push_back(&l->piface_);
}
/** @brief Just like Host::routeTo, but filling an array of link implementations */
-void Host::routeTo(Host* dest, std::vector<surf::LinkImpl*>* links, double* latency)
+void Host::routeTo(Host* dest, std::vector<surf::LinkImpl*>& links, double* latency)
{
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(pimpl_netpoint, dest->pimpl_netpoint, links, latency);
if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", getCname(), dest->getCname(),
(latency == nullptr ? -1 : *latency));
- for (auto const& link : *links)
+ for (auto const& link : links)
XBT_CDEBUG(surf_route, "Link %s", link->getCname());
}
}
simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
- std::vector<surf::LinkImpl*>* link_list)>
+ std::vector<surf::LinkImpl*>& link_list)>
NetZone::onRouteCreation;
simgrid::xbt::signal<void(NetZone&)> NetZone::onCreation;
simgrid::xbt::signal<void(NetZone&)> NetZone::onSeal;
void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links)
{
std::vector<simgrid::s4u::Link*> vlinks;
- from->routeTo(to, &vlinks, nullptr);
+ from->routeTo(to, vlinks, nullptr);
for (auto const& link : vlinks)
xbt_dynar_push(links, &link);
}
{
std::vector<simgrid::s4u::Link*> vlinks;
double res = 0;
- from->routeTo(to, &vlinks, &res);
+ from->routeTo(to, vlinks, &res);
return res;
}
/**
double min_bandwidth = -1.0;
std::vector<simgrid::s4u::Link*> vlinks;
- from->routeTo(to, &vlinks, nullptr);
+ from->routeTo(to, vlinks, nullptr);
for (auto const& link : vlinks) {
double bandwidth = link->bandwidth();
if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
{
int failed = 0;
double latency = 0.0;
- std::vector<LinkImpl*>* back_route = nullptr;
- std::vector<LinkImpl*>* route = new std::vector<LinkImpl*>();
+ std::vector<LinkImpl*> back_route;
+ std::vector<LinkImpl*> route;
XBT_IN("(%s,%s,%g,%g)", src->getCname(), dst->getCname(), size, rate);
src->routeTo(dst, route, &latency);
- xbt_assert(not route->empty() || latency,
+ xbt_assert(not route.empty() || latency,
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->getCname(), dst->getCname());
- for (auto const& link : *route)
+ for (auto const& link : route)
if (link->isOff())
failed = 1;
if (sg_network_crosstraffic == 1) {
- back_route = new std::vector<LinkImpl*>();
dst->routeTo(src, back_route, nullptr);
- for (auto const& link : *back_route)
+ for (auto const& link : back_route)
if (link->isOff())
failed = 1;
}
double bandwidth_bound = -1.0;
if (sg_weight_S_parameter > 0)
- for (auto const& link : *route)
+ for (auto const& link : route)
action->weight_ += sg_weight_S_parameter / link->bandwidth();
- for (auto const& link : *route) {
+ for (auto const& link : route) {
double bb = bandwidthFactor(size) * link->bandwidth();
bandwidth_bound = (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
}
action->latency_ *= latencyFactor(size);
action->rate_ = bandwidthConstraint(action->rate_, bandwidth_bound, size);
- int constraints_per_variable = route->size();
- if (back_route != nullptr)
- constraints_per_variable += back_route->size();
+ int constraints_per_variable = route.size();
+ constraints_per_variable += back_route.size();
if (action->latency_ > 0) {
action->setVariable(lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable));
if (getUpdateMechanism() == UM_LAZY) {
// add to the heap the event when the latency is payed
XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->getLastUpdate());
- action->heapInsert(actionHeap_, action->latency_ + action->getLastUpdate(), route->empty() ? NORMAL : LATENCY);
+ action->heapInsert(actionHeap_, action->latency_ + action->getLastUpdate(), route.empty() ? NORMAL : LATENCY);
}
} else
action->setVariable(lmm_variable_new(maxminSystem_, action, 1.0, -1.0, constraints_per_variable));
lmm_update_variable_bound(maxminSystem_, action->getVariable(), (action->latCurrent_ > 0) ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)) : action->rate_);
}
- for (auto const& link : *route)
+ for (auto const& link : route)
lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), 1.0);
- if (back_route != nullptr) { // sg_network_crosstraffic was activated
+ if (not back_route.empty()) { // sg_network_crosstraffic was activated
XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
- for (auto const& link : *back_route)
+ for (auto const& link : back_route)
lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), .05);
//Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
//(You would also have to change lmm_element_concurrency())
//lmm_variable_concurrency_share_set(action->getVariable(),2);
}
-
- delete route;
- delete back_route;
XBT_OUT();
simgrid::s4u::Link::onCommunicate(action, src, dst);
static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoint* src,
simgrid::kernel::routing::NetPoint* dst, simgrid::kernel::routing::NetPoint* gw_src,
simgrid::kernel::routing::NetPoint* gw_dst,
- std::vector<simgrid::surf::LinkImpl*>* link_list)
+ std::vector<simgrid::surf::LinkImpl*>& link_list)
{
- if (link_list->size() == 1) {
- simgrid::surf::LinkNS3* link = static_cast<simgrid::surf::LinkNS3*>(link_list->at(0));
+ if (link_list.size() == 1) {
+ simgrid::surf::LinkNS3* link = static_cast<simgrid::surf::LinkNS3*>(link_list[0]);
XBT_DEBUG("Route from '%s' to '%s' with link '%s' %s", src->getCname(), dst->getCname(), link->getCname(),
(symmetrical ? "(symmetrical)" : "(not symmetrical)"));
"of length 1.\n"
"WARNING: Remove long routes to avoid this harmless message; subsequent long routes will be silently "
"ignored.",
- src->getCname(), dst->getCname(), link_list->size());
+ src->getCname(), dst->getCname(), link_list.size());
warned_about_long_routes = true;
}
}
std::vector<LinkImpl*> route = std::vector<LinkImpl*>();
- action->src_->routeTo(action->dst_, &route, nullptr);
+ action->src_->routeTo(action->dst_, route, nullptr);
for (auto const& link : route)
TRACE_surf_link_set_utilization(link->getCname(), action->getCategory(), (data_delta_sent) / delta, now - delta,
delta);
double lat=0.0;
std::vector<LinkImpl*> route;
- hostList_->at(i)->routeTo(hostList_->at(j), &route, &lat);
+ hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
latency = MAX(latency, lat);
for (auto const& link : route)
for (int j = 0; j < host_nb; j++) {
if (bytes_amount[i * host_nb + j] > 0.0) {
std::vector<LinkImpl*> route;
- hostList_->at(i)->routeTo(hostList_->at(j), &route, nullptr);
+ hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr);
for (auto const& link : route)
lmm_expand_add(model->getMaxminSystem(), link->constraint(), this->getVariable(),
if (communicationAmount_[i * hostNb + j] > 0) {
double lat = 0.0;
std::vector<LinkImpl*> route;
- hostList_->at(i)->routeTo(hostList_->at(j), &route, &lat);
+ hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
lat_current = MAX(lat_current, lat * communicationAmount_[i * hostNb + j]);
}
};
struct s_sg_platf_route_cbarg_t {
- bool symmetrical = false;
- sg_netpoint_t src = nullptr;
- sg_netpoint_t dst = nullptr;
- sg_netpoint_t gw_src = nullptr;
- sg_netpoint_t gw_dst = nullptr;
- std::vector<simgrid::surf::LinkImpl*>* link_list = nullptr;
+ bool symmetrical = false;
+ sg_netpoint_t src = nullptr;
+ sg_netpoint_t dst = nullptr;
+ sg_netpoint_t gw_src = nullptr;
+ sg_netpoint_t gw_dst = nullptr;
+ std::vector<simgrid::surf::LinkImpl*> link_list;
};
typedef s_sg_platf_route_cbarg_t* sg_platf_route_cbarg_t;
XBT_PUBLIC(int) surf_parse_get_debug();
XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
XBT_PUBLIC(int) surf_parse_lex_destroy();
-
-XBT_PUBLIC(void) routing_route_free(sg_platf_route_cbarg_t route);
}
namespace simgrid {
route.dst = sg_netpoint_by_name_or_null(A_surfxml_route_dst); // tested to not be nullptr in start tag
route.gw_src = nullptr;
route.gw_dst = nullptr;
- route.link_list = new std::vector<simgrid::surf::LinkImpl*>();
route.symmetrical = (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES);
- for (auto const& link : parsed_link_list)
- route.link_list->push_back(link);
- parsed_link_list.clear();
+ route.link_list.swap(parsed_link_list);
sg_platf_new_route(&route);
- delete route.link_list;
}
void ETag_surfxml_ASroute()
ASroute.gw_src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___src); // tested to not be nullptr in start tag
ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___dst); // tested to not be nullptr in start tag
- ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
-
- for (auto const& link : parsed_link_list)
- ASroute.link_list->push_back(link);
- parsed_link_list.clear();
+ ASroute.link_list.swap(parsed_link_list);
switch (A_surfxml_zoneRoute_symmetrical) {
case AU_surfxml_zoneRoute_symmetrical:
}
sg_platf_new_route(&ASroute);
- delete ASroute.link_list;
}
void ETag_surfxml_bypassRoute(){
route.gw_src = nullptr;
route.gw_dst = nullptr;
route.symmetrical = false;
- route.link_list = new std::vector<simgrid::surf::LinkImpl*>();
- for (auto const& link : parsed_link_list)
- route.link_list->push_back(link);
- parsed_link_list.clear();
+ route.link_list.swap(parsed_link_list);
sg_platf_new_bypassRoute(&route);
- delete route.link_list;
}
void ETag_surfxml_bypassASroute()
ASroute.src = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_src);
ASroute.dst = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_dst);
- ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
- for (auto const& link : parsed_link_list)
- ASroute.link_list->push_back(link);
- parsed_link_list.clear();
+ ASroute.link_list.swap(parsed_link_list);
ASroute.symmetrical = false;
ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_gw___dst);
sg_platf_new_bypassRoute(&ASroute);
- delete ASroute.link_list;
}
void ETag_surfxml_trace(){
simgrid::s4u::Host* host2 = hosts[it_dst];
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
- simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
+ simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, route, nullptr);
if (not route.empty()) {
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->getCname(), host2->getCname());
for (auto const& link : route)
if (netcardDst->isRouter()) {
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->getCname(), netcardDst->getCname());
std::vector<simgrid::surf::LinkImpl*> route;
- simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
+ simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, route, nullptr);
for (auto const& link : route)
std::printf("<link_ctn id=\"%s\"/>", link->getCname());
std::printf("\n </route>\n");
if (value2->isRouter()) {
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", value1->getCname(), value2->getCname());
std::vector<simgrid::surf::LinkImpl*> route;
- simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, &route, nullptr);
+ simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, route, nullptr);
for (auto const& link : route)
std::printf("<link_ctn id=\"%s\"/>", link->getCname());
std::printf("\n </route>\n");
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", value1->getCname(), host2->getCname());
std::vector<simgrid::surf::LinkImpl*> route;
simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
- simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, netcardDst, &route, nullptr);
+ simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, netcardDst, route, nullptr);
for (auto const& link : route)
std::printf("<link_ctn id=\"%s\"/>", link->getCname());
std::printf("\n </route>\n");