From 102079f52888bf091ae08562bf7db74aedea494e Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 2 Apr 2018 23:10:16 +0200 Subject: [PATCH] snake_case routing::NetPoint --- include/simgrid/kernel/routing/NetPoint.hpp | 10 +++++----- src/kernel/routing/ClusterZone.cpp | 8 ++++---- src/kernel/routing/DragonflyZone.cpp | 2 +- src/kernel/routing/FatTreeZone.cpp | 2 +- src/kernel/routing/NetPoint.cpp | 2 +- src/kernel/routing/NetZoneImpl.cpp | 18 +++++++++--------- src/kernel/routing/RoutedZone.cpp | 16 ++++++++-------- src/kernel/routing/TorusZone.cpp | 2 +- src/kernel/routing/VivaldiZone.cpp | 7 ++++--- src/simgrid/host.cpp | 2 +- src/surf/instr_routing.cpp | 2 +- src/surf/xml/surfxml_sax_cb.cpp | 2 +- teshsuite/simdag/flatifier/flatifier.cpp | 8 ++++---- teshsuite/simdag/is-router/is-router.cpp | 8 ++++---- 14 files changed, 45 insertions(+), 44 deletions(-) diff --git a/include/simgrid/kernel/routing/NetPoint.hpp b/include/simgrid/kernel/routing/NetPoint.hpp index cc0d807982..cfcd311369 100644 --- a/include/simgrid/kernel/routing/NetPoint.hpp +++ b/include/simgrid/kernel/routing/NetPoint.hpp @@ -34,11 +34,11 @@ public: const std::string& get_name() const { return name_; } const char* get_cname() const { return name_.c_str(); } /** @brief the NetZone in which this NetPoint is included */ - NetZoneImpl* netzone() { return netzone_; } + NetZoneImpl* get_englobing_zone() { return englobing_zone_; } - bool isNetZone() { return component_type_ == Type::NetZone; } - bool isHost() { return component_type_ == Type::Host; } - bool isRouter() { return component_type_ == Type::Router; } + bool is_netzone() { return component_type_ == Type::NetZone; } + bool is_host() { return component_type_ == Type::Host; } + bool is_router() { return component_type_ == Type::Router; } static simgrid::xbt::signal onCreation; @@ -48,7 +48,7 @@ private: unsigned int id_; std::string name_; NetPoint::Type component_type_; - NetZoneImpl* netzone_; + NetZoneImpl* englobing_zone_; }; } // namespace routing } // namespace kernel diff --git a/src/kernel/routing/ClusterZone.cpp b/src/kernel/routing/ClusterZone.cpp index 057b651e57..f8bfb2e51a 100644 --- a/src/kernel/routing/ClusterZone.cpp +++ b/src/kernel/routing/ClusterZone.cpp @@ -28,7 +28,7 @@ void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArgs* "Cluster routing: no links attached to the source node - did you use host_link tag?"); if ((src->id() == dst->id()) && has_loopback_) { - xbt_assert(not src->isRouter(), "Routing from a cluster private router to itself is meaningless"); + xbt_assert(not src->is_router(), "Routing from a cluster private router to itself is meaningless"); std::pair info = private_links_.at(nodePosition(src->id())); route->link_list.push_back(info.first); @@ -37,7 +37,7 @@ void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArgs* return; } - if (not src->isRouter()) { // No private link for the private router + if (not src->is_router()) { // No private link for the private router if (has_limiter_) { // limiter for sender std::pair info = private_links_.at(nodePositionWithLoopback(src->id())); route->link_list.push_back(info.first); @@ -57,7 +57,7 @@ void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArgs* *lat += backbone_->latency(); } - if (not dst->isRouter()) { // No specific link for router + if (not dst->is_router()) { // No specific link for router std::pair info = private_links_.at(nodePositionWithLimiter(dst->id())); if (info.second) { // link down @@ -88,7 +88,7 @@ void ClusterZone::getGraph(xbt_graph_t graph, std::map* } for (auto const& src : getVertices()) { - if (not src->isRouter()) { + if (not src->is_router()) { xbt_node_t previous = new_xbt_graph_node(graph, src->get_cname(), nodes); std::pair info = private_links_.at(src->id()); diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index 7ae3e78d0b..d7bc1a1fca 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -267,7 +267,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArg // Minimal routing version. // TODO : non-minimal random one, and adaptive ? - if (dst->isRouter() || src->isRouter()) + if (dst->is_router() || src->is_router()) return; XBT_VERB("dragonfly getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index e81439a927..66a4fa1097 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -61,7 +61,7 @@ bool FatTreeZone::isInSubTree(FatTreeNode* root, FatTreeNode* node) void FatTreeZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) { - if (dst->isRouter() || src->isRouter()) + if (dst->is_router() || src->is_router()) return; /* Let's find the source and the destination in our internal structure */ diff --git a/src/kernel/routing/NetPoint.cpp b/src/kernel/routing/NetPoint.cpp index c15f13aa47..6c38c0cb86 100644 --- a/src/kernel/routing/NetPoint.cpp +++ b/src/kernel/routing/NetPoint.cpp @@ -16,7 +16,7 @@ namespace routing { simgrid::xbt::signal NetPoint::onCreation; NetPoint::NetPoint(std::string name, NetPoint::Type componentType, NetZoneImpl* netzone_p) - : name_(name), component_type_(componentType), netzone_(netzone_p) + : name_(name), component_type_(componentType), englobing_zone_(netzone_p) { if (netzone_p != nullptr) id_ = netzone_p->addComponent(this); diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 2ec532bb14..35c07ef008 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -148,8 +148,8 @@ static void find_common_ancestors(NetPoint* src, NetPoint* dst, NetZoneImpl** dst_ancestor) { /* Deal with the easy base case */ - if (src->netzone() == dst->netzone()) { - *common_ancestor = src->netzone(); + if (src->get_englobing_zone() == dst->get_englobing_zone()) { + *common_ancestor = src->get_englobing_zone(); *src_ancestor = *common_ancestor; *dst_ancestor = *common_ancestor; return; @@ -158,21 +158,21 @@ static void find_common_ancestors(NetPoint* src, NetPoint* dst, /* engage the full recursive search */ /* (1) find the path to root of src and dst*/ - NetZoneImpl* src_as = src->netzone(); - NetZoneImpl* dst_as = dst->netzone(); + NetZoneImpl* src_as = src->get_englobing_zone(); + NetZoneImpl* dst_as = dst->get_englobing_zone(); xbt_assert(src_as, "Host %s must be in a netzone", src->get_cname()); xbt_assert(dst_as, "Host %s must be in a netzone", dst->get_cname()); /* (2) find the path to the root routing component */ std::vector path_src; - NetZoneImpl* current = src->netzone(); + NetZoneImpl* current = src->get_englobing_zone(); while (current != nullptr) { path_src.push_back(current); current = static_cast(current->getFather()); } std::vector path_dst; - current = dst->netzone(); + current = dst->get_englobing_zone(); while (current != nullptr) { path_dst.push_back(current); current = static_cast(current->getFather()); @@ -211,7 +211,7 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst, return false; /* Base case, no recursion is needed */ - if (dst->netzone() == this && src->netzone() == this) { + if (dst->get_englobing_zone() == this && src->get_englobing_zone() == this) { if (bypass_routes_.find({src, dst}) != bypass_routes_.end()) { BypassRoute* bypassedRoute = bypass_routes_.at({src, dst}); for (surf::LinkImpl* const& link : bypassedRoute->links) { @@ -230,14 +230,14 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst, /* (1) find the path to the root routing component */ std::vector path_src; - NetZone* current = src->netzone(); + NetZone* current = src->get_englobing_zone(); while (current != nullptr) { path_src.push_back(static_cast(current)); current = current->father_; } std::vector path_dst; - current = dst->netzone(); + current = dst->get_englobing_zone(); while (current != nullptr) { path_dst.push_back(static_cast(current)); current = current->father_; diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index acb11d1ecc..7d458d1dfd 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -152,8 +152,8 @@ void RoutedZone::getRouteCheckParams(NetPoint* src, NetPoint* dst) xbt_assert(src, "Cannot find a route from nullptr to %s", dst->get_cname()); xbt_assert(dst, "Cannot find a route from %s to nullptr", src->get_cname()); - NetZone* src_as = src->netzone(); - NetZone* dst_as = dst->netzone(); + NetZone* src_as = src->get_englobing_zone(); + NetZone* dst_as = dst->get_englobing_zone(); xbt_assert(src_as == dst_as, "Internal error: %s@%s and %s@%s are not in the same netzone as expected. Please report that bug.", @@ -176,20 +176,20 @@ void RoutedZone::addRouteCheckParams(kernel::routing::NetPoint* src, kernel::rou 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 link_list.empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName); - xbt_assert(not src->isNetZone(), + xbt_assert(not src->is_netzone(), "When defining a route, src cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?", srcName); - xbt_assert(not dst->isNetZone(), + xbt_assert(not dst->is_netzone(), "When defining a route, dst cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?", dstName); } else { XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", srcName, gw_src->get_cname(), dstName, gw_dst->get_cname()); - xbt_assert(src->isNetZone(), "When defining a NetzoneRoute, src must be a netzone but '%s' is not", srcName); - xbt_assert(dst->isNetZone(), "When defining a NetzoneRoute, dst must be a netzone but '%s' is not", dstName); + xbt_assert(src->is_netzone(), "When defining a NetzoneRoute, src must be a netzone but '%s' is not", srcName); + xbt_assert(dst->is_netzone(), "When defining a NetzoneRoute, dst must be a netzone but '%s' is not", dstName); - xbt_assert(gw_src->isHost() || gw_src->isRouter(), + xbt_assert(gw_src->is_host() || gw_src->is_router(), "When defining a NetzoneRoute, gw_src must be an host or a router but '%s' is not.", srcName); - xbt_assert(gw_dst->isHost() || gw_dst->isRouter(), + xbt_assert(gw_dst->is_host() || gw_dst->is_router(), "When defining a NetzoneRoute, gw_dst must be an host or a router but '%s' is not.", dstName); xbt_assert(gw_src != gw_dst, "Cannot define an NetzoneRoute from '%s' to itself", gw_src->get_cname()); diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index a21579a1f7..d25a3bac29 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -98,7 +98,7 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArgs* r XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id()); - if (dst->isRouter() || src->isRouter()) + if (dst->is_router() || src->is_router()) return; if (src->id() == dst->id() && has_loopback_) { diff --git a/src/kernel/routing/VivaldiZone.cpp b/src/kernel/routing/VivaldiZone.cpp index fc77a23aaf..2d6cb441ab 100644 --- a/src/kernel/routing/VivaldiZone.cpp +++ b/src/kernel/routing/VivaldiZone.cpp @@ -54,7 +54,7 @@ static std::vector* getCoordsFromNetpoint(NetPoint* np) { simgrid::kernel::routing::vivaldi::Coords* coords = np->extension(); xbt_assert(coords, "Please specify the Vivaldi coordinates of %s %s (%p)", - (np->isNetZone() ? "Netzone" : (np->isHost() ? "Host" : "Router")), np->get_cname(), np); + (np->is_netzone() ? "Netzone" : (np->is_host() ? "Host" : "Router")), np->get_cname(), np); return &coords->coords; } @@ -64,7 +64,8 @@ VivaldiZone::VivaldiZone(NetZone* father, std::string name) : ClusterZone(father void VivaldiZone::setPeerLink(NetPoint* netpoint, double bw_in, double bw_out, std::string coord) { - xbt_assert(netpoint->netzone() == this, "Cannot add a peer link to a netpoint that is not in this netzone"); + xbt_assert(netpoint->get_englobing_zone() == this, + "Cannot add a peer link to a netpoint that is not in this netzone"); new simgrid::kernel::routing::vivaldi::Coords(netpoint, coord); @@ -79,7 +80,7 @@ void VivaldiZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArgs* { XBT_DEBUG("vivaldi getLocalRoute from '%s'[%u] '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id()); - if (src->isNetZone()) { + if (src->is_netzone()) { std::string srcName = "router_" + src->get_name(); std::string dstName = "router_" + dst->get_name(); route->gw_src = simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(srcName.c_str()); diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index 84318b32af..f4a89018df 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -76,7 +76,7 @@ xbt_dynar_t sg_hosts_as_dynar() std::vector list = simgrid::s4u::Engine::getInstance()->getAllHosts(); for (auto const& host : list) { - if (host && host->pimpl_netpoint && host->pimpl_netpoint->isHost()) + if (host && host->pimpl_netpoint && host->pimpl_netpoint->is_host()) xbt_dynar_push(res, &host); } xbt_dynar_sort(res, hostcmp_voidp); diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index ddbe0af707..575e4dd284 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -249,7 +249,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) static void sg_instr_new_router(simgrid::kernel::routing::NetPoint * netpoint) { - if (netpoint->isRouter() && TRACE_is_enabled() && TRACE_needs_platform()) + if (netpoint->is_router() && TRACE_is_enabled() && TRACE_needs_platform()) new simgrid::instr::RouterContainer(netpoint->get_cname(), currentContainer.back()); } diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 602728d541..3388b9a03e 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -63,7 +63,7 @@ void surf_parse_assert_netpoint(std::string hostname, std::string pre, std::stri }); bool first = true; for (auto const& np : list) { - if (np->isNetZone()) + if (np->is_netzone()) continue; if (not first) diff --git a/teshsuite/simdag/flatifier/flatifier.cpp b/teshsuite/simdag/flatifier/flatifier.cpp index 53e0efdd64..96ca08adc7 100644 --- a/teshsuite/simdag/flatifier/flatifier.cpp +++ b/teshsuite/simdag/flatifier/flatifier.cpp @@ -105,7 +105,7 @@ static void dump_routers() }); for (auto const& srcCard : netcardList) - if (srcCard->isRouter()) + if (srcCard->is_router()) std::printf(" \n", srcCard->get_cname()); } @@ -139,7 +139,7 @@ static void dump_routes() } for (auto const& netcardDst : netcardList) { // to router - if (netcardDst->isRouter()) { + if (netcardDst->is_router()) { std::printf(" \n ", host1->get_cname(), netcardDst->get_cname()); std::vector route; simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, route, nullptr); @@ -151,9 +151,9 @@ static void dump_routes() } for (auto const& value1 : netcardList) { // Routes from router - if (value1->isRouter()) { + if (value1->is_router()) { for (auto const& value2 : netcardList) { // to router - if (value2->isRouter()) { + if (value2->is_router()) { std::printf(" \n ", value1->get_cname(), value2->get_cname()); std::vector route; simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, route, nullptr); diff --git a/teshsuite/simdag/is-router/is-router.cpp b/teshsuite/simdag/is-router/is-router.cpp index 9091552837..fbfd1dcd4d 100644 --- a/teshsuite/simdag/is-router/is-router.cpp +++ b/teshsuite/simdag/is-router/is-router.cpp @@ -31,11 +31,11 @@ int main(int argc, char **argv) xbt_dynar_foreach(hosts, it, host) { simgrid::kernel::routing::NetPoint* nc = host->pimpl_netpoint; const char *type = "buggy"; - if (nc->isRouter()) + if (nc->is_router()) type = "router"; - if (nc->isNetZone()) + if (nc->is_netzone()) type = "netzone"; - if (nc->isHost()) + if (nc->is_host()) type = "host"; std::printf(" - Seen: \"%s\". Type: %s\n", host->get_cname(), type); } @@ -44,7 +44,7 @@ int main(int argc, char **argv) std::printf("NetCards count: %zu\n", netcardList.size()); for (auto const& nc : netcardList) std::printf(" - Seen: \"%s\". Type: %s\n", nc->get_cname(), - nc->isRouter() ? "router" : (nc->isNetZone() ? "netzone" : (nc->isHost() ? "host" : "buggy"))); + nc->is_router() ? "router" : (nc->is_netzone() ? "netzone" : (nc->is_host() ? "host" : "buggy"))); return 0; } -- 2.20.1