From 0fa053f89a0b5f34a050f4790925d9d63ac11073 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 7 Apr 2018 08:24:46 +0200 Subject: [PATCH] move all network models to the kernel::resource namespace --- include/simgrid/forward.h | 17 ++-- .../simgrid/kernel/routing/ClusterZone.hpp | 4 +- .../simgrid/kernel/routing/DijkstraZone.hpp | 2 +- .../simgrid/kernel/routing/DragonflyZone.hpp | 10 +-- .../simgrid/kernel/routing/FatTreeZone.hpp | 8 +- include/simgrid/kernel/routing/FloydZone.hpp | 5 +- include/simgrid/kernel/routing/FullZone.hpp | 5 +- .../simgrid/kernel/routing/NetZoneImpl.hpp | 6 +- include/simgrid/kernel/routing/RoutedZone.hpp | 7 +- include/simgrid/s4u/Host.hpp | 2 +- include/simgrid/s4u/Link.hpp | 13 ++- include/simgrid/s4u/NetZone.hpp | 10 +-- src/bindings/lua/lua_platf.cpp | 10 +-- src/instr/instr_interface.cpp | 2 +- src/kernel/routing/ClusterZone.cpp | 22 ++--- src/kernel/routing/DijkstraZone.cpp | 11 ++- src/kernel/routing/DragonflyZone.cpp | 31 +++---- src/kernel/routing/FatTreeZone.cpp | 10 +-- src/kernel/routing/FloydZone.cpp | 2 +- src/kernel/routing/FullZone.cpp | 5 +- src/kernel/routing/NetZoneImpl.cpp | 14 ++-- src/kernel/routing/RoutedZone.cpp | 7 +- src/kernel/routing/TorusZone.cpp | 14 ++-- src/kernel/routing/VivaldiZone.cpp | 8 +- src/s4u/s4u_engine.cpp | 6 +- src/s4u/s4u_host.cpp | 6 +- src/s4u/s4u_link.cpp | 12 +-- src/s4u/s4u_netzone.cpp | 4 +- src/surf/network_cm02.cpp | 45 +++++------ src/surf/network_cm02.hpp | 25 +++--- src/surf/network_constant.cpp | 6 +- src/surf/network_constant.hpp | 44 +++++----- src/surf/network_ib.cpp | 24 +++--- src/surf/network_ib.hpp | 81 +++++++++---------- src/surf/network_interface.cpp | 56 +++++++------ src/surf/network_interface.hpp | 33 ++++---- src/surf/network_ns3.cpp | 10 ++- src/surf/network_ns3.hpp | 4 +- src/surf/network_smpi.cpp | 6 +- src/surf/network_smpi.hpp | 22 ++--- src/surf/ns3/ns3_simulator.cpp | 2 +- src/surf/ns3/ns3_simulator.hpp | 11 +-- src/surf/plugins/link_energy.cpp | 9 ++- src/surf/ptask_L07.cpp | 12 +-- src/surf/ptask_L07.hpp | 8 +- src/surf/sg_platf.cpp | 20 ++--- src/surf/xml/platf_private.hpp | 4 +- src/surf/xml/surfxml_sax_cb.cpp | 13 +-- teshsuite/simdag/flatifier/flatifier.cpp | 8 +- 49 files changed, 347 insertions(+), 349 deletions(-) diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index fa46962cda..15adc03554 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -17,12 +17,9 @@ namespace simgrid { namespace config { template class Flag; } + namespace kernel { class EngineImpl; -namespace context { -class Context; -class ContextFactory; -} namespace actor { class ActorImpl; using ActorImplPtr = boost::intrusive_ptr; @@ -48,6 +45,10 @@ namespace activity { class MailboxImpl; } +namespace context { +class Context; +class ContextFactory; +} // namespace context namespace lmm { class Element; class Variable; @@ -60,6 +61,8 @@ class Action; class Model; class Resource; class TraceEvent; +class LinkImpl; +class NetworkAction; } namespace routing { class ClusterCreationArgs; @@ -68,14 +71,12 @@ class NetPoint; class NetZoneImpl; class RouteCreationArgs; } -} +} // namespace kernel namespace simix { class Host; } - namespace surf { class Cpu; - class LinkImpl; class HostImpl; class StorageImpl; class StorageType; @@ -84,7 +85,7 @@ namespace trace_mgr { class trace; class future_evt_set; } -} +} // namespace simgrid typedef simgrid::s4u::Actor s4u_Actor; typedef simgrid::s4u::Host s4u_Host; diff --git a/include/simgrid/kernel/routing/ClusterZone.hpp b/include/simgrid/kernel/routing/ClusterZone.hpp index 0005d46756..44212a9f42 100644 --- a/include/simgrid/kernel/routing/ClusterZone.hpp +++ b/include/simgrid/kernel/routing/ClusterZone.hpp @@ -81,14 +81,14 @@ public: /* We use a map instead of a std::vector here because that's a sparse vector. Some values may not exist */ /* The pair is {linkUp, linkDown} */ - std::unordered_map> private_links_; + std::unordered_map> private_links_; unsigned int node_pos(int id) { return id * num_links_per_node_; } unsigned int node_pos_with_loopback(int id) { return node_pos(id) + (has_loopback_ ? 1 : 0); } unsigned int node_pos_with_loopback_limiter(int id) { return node_pos_with_loopback(id) + (has_limiter_ ? 1 : 0); } void* loopback_ = nullptr; - surf::LinkImpl* backbone_ = nullptr; + kernel::resource::LinkImpl* backbone_ = nullptr; NetPoint* router_ = nullptr; bool has_limiter_ = false; bool has_loopback_ = false; diff --git a/include/simgrid/kernel/routing/DijkstraZone.hpp b/include/simgrid/kernel/routing/DijkstraZone.hpp index 2003a9a70d..b3a53224b2 100644 --- a/include/simgrid/kernel/routing/DijkstraZone.hpp +++ b/include/simgrid/kernel/routing/DijkstraZone.hpp @@ -53,7 +53,7 @@ public: */ void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) override; void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, - std::vector& link_list, bool symmetrical) override; + std::vector& link_list, bool symmetrical) override; xbt_graph_t route_graph_ = nullptr; /* xbt_graph */ std::map graph_node_map_; /* map */ diff --git a/include/simgrid/kernel/routing/DragonflyZone.hpp b/include/simgrid/kernel/routing/DragonflyZone.hpp index f11a8e5469..bb06b63e0c 100644 --- a/include/simgrid/kernel/routing/DragonflyZone.hpp +++ b/include/simgrid/kernel/routing/DragonflyZone.hpp @@ -17,10 +17,10 @@ public: unsigned int group_; unsigned int chassis_; unsigned int blade_; - surf::LinkImpl** blue_links_ = nullptr; - surf::LinkImpl** black_links_ = nullptr; - surf::LinkImpl** green_links_ = nullptr; - surf::LinkImpl** my_nodes_ = nullptr; + resource::LinkImpl** blue_links_ = nullptr; + resource::LinkImpl** black_links_ = nullptr; + resource::LinkImpl** green_links_ = nullptr; + resource::LinkImpl** my_nodes_ = nullptr; DragonflyRouter(int i, int j, int k); ~DragonflyRouter(); }; @@ -68,7 +68,7 @@ public: void seal() override; void generateRouters(); void generateLinks(); - void createLink(const std::string& id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown); + void createLink(const std::string& id, int numlinks, resource::LinkImpl** linkup, resource::LinkImpl** linkdown); void rankId_to_coords(int rankId, unsigned int (*coords)[4]); diff --git a/include/simgrid/kernel/routing/FatTreeZone.hpp b/include/simgrid/kernel/routing/FatTreeZone.hpp index 1fb72300dc..b7023dcb7f 100644 --- a/include/simgrid/kernel/routing/FatTreeZone.hpp +++ b/include/simgrid/kernel/routing/FatTreeZone.hpp @@ -46,11 +46,11 @@ public: /** Virtual link standing for the node global capacity. */ - surf::LinkImpl* limiter_link_; + resource::LinkImpl* limiter_link_; /** If present, communications from this node to this node will pass through it * instead of passing by an upper level switch. */ - surf::LinkImpl* loopback; + resource::LinkImpl* loopback; FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int position); }; @@ -63,9 +63,9 @@ class FatTreeLink { public: FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* source, FatTreeNode* destination); /** Link going up in the tree */ - surf::LinkImpl* up_link_; + resource::LinkImpl* up_link_; /** Link going down in the tree */ - surf::LinkImpl* down_link_; + resource::LinkImpl* down_link_; /** Upper end of the link */ FatTreeNode* up_node_; /** Lower end of the link */ diff --git a/include/simgrid/kernel/routing/FloydZone.hpp b/include/simgrid/kernel/routing/FloydZone.hpp index e9e65ec459..92fe57f9a1 100644 --- a/include/simgrid/kernel/routing/FloydZone.hpp +++ b/include/simgrid/kernel/routing/FloydZone.hpp @@ -27,9 +27,8 @@ public: ~FloydZone() override; void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; - void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src, - kernel::routing::NetPoint* gw_dst, std::vector& link_list, - bool symmetrical) override; + void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) override; void seal() override; private: diff --git a/include/simgrid/kernel/routing/FullZone.hpp b/include/simgrid/kernel/routing/FullZone.hpp index 5f8fcde90b..99722a1afa 100644 --- a/include/simgrid/kernel/routing/FullZone.hpp +++ b/include/simgrid/kernel/routing/FullZone.hpp @@ -25,9 +25,8 @@ public: ~FullZone() override; void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; - void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src, - kernel::routing::NetPoint* gw_dst, std::vector& link_list, - bool symmetrical) override; + void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) override; private: RouteCreationArgs** routing_table_ = nullptr; diff --git a/include/simgrid/kernel/routing/NetZoneImpl.hpp b/include/simgrid/kernel/routing/NetZoneImpl.hpp index 18a525bfa9..ba1d690726 100644 --- a/include/simgrid/kernel/routing/NetZoneImpl.hpp +++ b/include/simgrid/kernel/routing/NetZoneImpl.hpp @@ -59,7 +59,7 @@ public: std::map* props); /** @brief Creates a new route in this NetZone */ void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, - std::vector& link_list, bool symmetrical) override; + std::vector& link_list, bool symmetrical) override; protected: /** @@ -74,7 +74,7 @@ protected: /** @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& links, double* latency); + /* OUT */ std::vector& links, double* latency); public: /* @brief get the route between two nodes in the full platform @@ -85,7 +85,7 @@ public: * @param latency Accumulator in which the latencies should be added (caller must set it to 0) */ static void get_global_route(routing::NetPoint* src, routing::NetPoint* dst, - /* OUT */ std::vector& links, double* latency); + /* OUT */ std::vector& links, double* latency); virtual void get_graph(xbt_graph_t graph, std::map* nodes, std::map* edges) = 0; diff --git a/include/simgrid/kernel/routing/RoutedZone.hpp b/include/simgrid/kernel/routing/RoutedZone.hpp index 81d7c43afd..60bb1d5cc4 100644 --- a/include/simgrid/kernel/routing/RoutedZone.hpp +++ b/include/simgrid/kernel/routing/RoutedZone.hpp @@ -55,14 +55,13 @@ public: void get_graph(xbt_graph_t graph, std::map* nodes, std::map* edges) override; virtual RouteCreationArgs* newExtendedRoute(RoutingMode hierarchy, NetPoint* src, NetPoint* dst, NetPoint* gw_src, - NetPoint* gw_dst, std::vector& link_list, + NetPoint* gw_dst, std::vector& link_list, bool symmetrical, bool change_order); protected: void getRouteCheckParams(NetPoint* src, NetPoint* dst); - void addRouteCheckParams(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, - kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, - std::vector& link_list, bool symmetrical); + void addRouteCheckParams(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, + std::vector& link_list, bool symmetrical); }; } // namespace routing } // namespace kernel diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index db09e0d4d5..3696d9142b 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -112,7 +112,7 @@ public: std::unordered_map const& getMountedStorages(); void routeTo(Host* dest, std::vector& links, double* latency); - void routeTo(Host* dest, std::vector& links, double* latency); + void routeTo(Host* dest, std::vector& links, double* latency); /** Block the calling actor on an execution located on the called host * diff --git a/include/simgrid/s4u/Link.hpp b/include/simgrid/s4u/Link.hpp index d236911394..62f76333dd 100644 --- a/include/simgrid/s4u/Link.hpp +++ b/include/simgrid/s4u/Link.hpp @@ -18,19 +18,16 @@ ***********/ namespace simgrid { -namespace surf { -class NetworkAction; -}; namespace s4u { /** @brief A Link represents the network facilities between [hosts](\ref simgrid::s4u::Host) */ class XBT_PUBLIC Link : public simgrid::xbt::Extendable { - friend simgrid::surf::LinkImpl; + friend simgrid::kernel::resource::LinkImpl; // Links are created from the NetZone, and destroyed by their private implementation when the simulation ends - explicit Link(surf::LinkImpl* pimpl) : pimpl_(pimpl) {} + explicit Link(kernel::resource::LinkImpl* pimpl) : pimpl_(pimpl) {} virtual ~Link() = default; // The private implementation, that never changes - surf::LinkImpl* const pimpl_; + kernel::resource::LinkImpl* const pimpl_; public: /** @brief Retrieve a link from its name */ @@ -87,10 +84,10 @@ public: static simgrid::xbt::signal onStateChange; /** @brief Callback signal fired when a communication starts */ - static simgrid::xbt::signal onCommunicate; + static simgrid::xbt::signal onCommunicate; /** @brief Callback signal fired when a communication changes it state (ready/done/cancel) */ - static simgrid::xbt::signal onCommunicationStateChange; + static simgrid::xbt::signal onCommunicationStateChange; XBT_ATTRIB_DEPRECATED_v321("Use get_cname(): v3.21 will turn this warning into an error.") const char* name(); }; diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index 2b6b42edd0..13e8780f35 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -48,13 +48,13 @@ public: XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_cname()") const char* getCname() const { return get_cname(); } XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::add_route()") void addRoute( kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src, - kernel::routing::NetPoint* gw_dst, std::vector& link_list, bool symmetrical) + kernel::routing::NetPoint* gw_dst, std::vector& link_list, bool symmetrical) { add_route(src, dst, gw_src, gw_dst, link_list, symmetrical); } XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::add_bypass_route()") void addBypassRoute( kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src, - kernel::routing::NetPoint* gw_dst, std::vector& link_list, bool symmetrical) + kernel::routing::NetPoint* gw_dst, std::vector& link_list, bool symmetrical) { add_bypass_route(src, dst, gw_src, gw_dst, link_list, symmetrical); } @@ -74,15 +74,15 @@ public: virtual int addComponent(kernel::routing::NetPoint * elm); /* A host, a router or a netzone, whatever */ virtual void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, - std::vector& link_list, bool symmetrical); + std::vector& link_list, bool symmetrical); virtual void add_bypass_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, - std::vector& link_list, bool symmetrical) = 0; + std::vector& link_list, bool symmetrical) = 0; /*** Called on each newly created regular route (not on bypass routes) */ static simgrid::xbt::signal& link_list)> + std::vector& link_list)> onRouteCreation; static simgrid::xbt::signal onCreation; static simgrid::xbt::signal onSeal; diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index 90a2afa876..3275d94d06 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -103,7 +103,7 @@ int console_add_backbone(lua_State *L) { } sg_platf_new_link(&link); - routing_cluster_add_backbone(simgrid::surf::LinkImpl::byName(link.id)); + routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl::byName(link.id)); return 0; } @@ -336,12 +336,12 @@ int console_add_route(lua_State *L) { 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::kernel::resource::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); + simgrid::kernel::resource::LinkImpl* link = simgrid::kernel::resource::LinkImpl::byName(name); route.link_list.push_back(link); } } @@ -414,12 +414,12 @@ int console_add_ASroute(lua_State *L) { 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::kernel::resource::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); + simgrid::kernel::resource::LinkImpl* link = simgrid::kernel::resource::LinkImpl::byName(name); ASroute.link_list.push_back(link); } } diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index c5ff45cddf..62ca5c1a8f 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -305,7 +305,7 @@ static void instr_user_srcdst_variable(double time, const char *src, const char if (not dst_elm) xbt_die("Element '%s' not found!",dst); - std::vector route; + std::vector route; simgrid::kernel::routing::NetZoneImpl::get_global_route(src_elm, dst_elm, route, nullptr); for (auto const& link : route) instr_user_variable(time, link->get_cname(), variable, father_type, value, what, nullptr, &user_link_variables); diff --git a/src/kernel/routing/ClusterZone.cpp b/src/kernel/routing/ClusterZone.cpp index f162c5bf56..e3f8505603 100644 --- a/src/kernel/routing/ClusterZone.cpp +++ b/src/kernel/routing/ClusterZone.cpp @@ -30,7 +30,7 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg if ((src->id() == dst->id()) && has_loopback_) { xbt_assert(not src->is_router(), "Routing from a cluster private router to itself is meaningless"); - std::pair info = private_links_.at(node_pos(src->id())); + std::pair info = private_links_.at(node_pos(src->id())); route->link_list.push_back(info.first); if (lat) *lat += info.first->latency(); @@ -39,11 +39,12 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg if (not src->is_router()) { // No private link for the private router if (has_limiter_) { // limiter for sender - std::pair info = private_links_.at(node_pos_with_loopback(src->id())); + std::pair info = private_links_.at(node_pos_with_loopback(src->id())); route->link_list.push_back(info.first); } - std::pair info = private_links_.at(node_pos_with_loopback_limiter(src->id())); + std::pair info = + private_links_.at(node_pos_with_loopback_limiter(src->id())); if (info.first) { // link up route->link_list.push_back(info.first); if (lat) @@ -59,7 +60,8 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg if (not dst->is_router()) { // No specific link for router - std::pair info = private_links_.at(node_pos_with_loopback_limiter(dst->id())); + std::pair info = + private_links_.at(node_pos_with_loopback_limiter(dst->id())); if (info.second) { // link down route->link_list.push_back(info.second); if (lat) @@ -91,7 +93,7 @@ void ClusterZone::get_graph(xbt_graph_t graph, std::map 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()); + std::pair info = private_links_.at(src->id()); if (info.first) { // link up xbt_node_t current = new_xbt_graph_node(graph, info.first->get_cname(), nodes); @@ -129,13 +131,13 @@ void ClusterZone::create_links_for_node(ClusterCreationArgs* cluster, int id, in link.policy = cluster->sharing_policy; sg_platf_new_link(&link); - surf::LinkImpl *linkUp; - surf::LinkImpl *linkDown; + resource::LinkImpl* linkUp; + resource::LinkImpl* linkDown; if (link.policy == SURF_LINK_SPLITDUPLEX) { - linkUp = surf::LinkImpl::byName(link_id + "_UP"); - linkDown = surf::LinkImpl::byName(link_id + "_DOWN"); + linkUp = resource::LinkImpl::byName(link_id + "_UP"); + linkDown = resource::LinkImpl::byName(link_id + "_DOWN"); } else { - linkUp = surf::LinkImpl::byName(link_id); + linkUp = resource::LinkImpl::byName(link_id); linkDown = linkUp; } private_links_.insert({position, {linkUp, linkDown}}); diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index f6ae5a1675..4aa05bb001 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -154,7 +154,7 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr for (auto const& link : e_route->link_list) { route->link_list.insert(route->link_list.begin(), link); if (lat) - *lat += static_cast(link)->latency(); + *lat += static_cast(link)->latency(); } } @@ -229,7 +229,7 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr first_gw = gw_dst; if (hierarchy_ == RoutingMode::recursive && v != dst_node_id && gw_dst->get_name() != prev_gw_src->get_name()) { - std::vector e_route_as_to_as; + std::vector e_route_as_to_as; NetPoint* gw_dst_net_elm = nullptr; NetPoint* prev_gw_src_net_elm = nullptr; @@ -246,7 +246,7 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr for (auto const& link : e_route->link_list) { route->link_list.insert(route->link_list.begin(), link); if (lat) - *lat += static_cast(link)->latency(); + *lat += static_cast(link)->latency(); } } @@ -270,9 +270,8 @@ DijkstraZone::DijkstraZone(NetZone* father, std::string name, bool cached) : Rou { } -void DijkstraZone::add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, - kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, - std::vector& link_list, bool symmetrical) +void DijkstraZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) { const char* srcName = src->get_cname(); const char* dstName = dst->get_cname(); diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index a0ada55487..dbb52a3ab4 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -159,7 +159,8 @@ void DragonflyZone::generateRouters() } } -void DragonflyZone::createLink(const std::string& id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown) +void DragonflyZone::createLink(const std::string& id, int numlinks, resource::LinkImpl** linkup, + resource::LinkImpl** linkdown) { *linkup = nullptr; *linkdown = nullptr; @@ -170,12 +171,12 @@ void DragonflyZone::createLink(const std::string& id, int numlinks, surf::LinkIm linkTemplate.id = id; sg_platf_new_link(&linkTemplate); XBT_DEBUG("Generating link %s", id.c_str()); - surf::LinkImpl* link; + resource::LinkImpl* link; if (this->sharing_policy_ == SURF_LINK_SPLITDUPLEX) { - *linkup = surf::LinkImpl::byName(linkTemplate.id + "_UP"); // check link? - *linkdown = surf::LinkImpl::byName(linkTemplate.id + "_DOWN"); // check link ? + *linkup = resource::LinkImpl::byName(linkTemplate.id + "_UP"); // check link? + *linkdown = resource::LinkImpl::byName(linkTemplate.id + "_DOWN"); // check link ? } else { - link = surf::LinkImpl::byName(linkTemplate.id); + link = resource::LinkImpl::byName(linkTemplate.id); *linkup = link; *linkdown = link; } @@ -184,17 +185,17 @@ void DragonflyZone::createLink(const std::string& id, int numlinks, surf::LinkIm void DragonflyZone::generateLinks() { static int uniqueId = 0; - surf::LinkImpl* linkup; - surf::LinkImpl* linkdown; + resource::LinkImpl* linkup; + resource::LinkImpl* linkdown; unsigned int numRouters = this->num_groups_ * this->num_chassis_per_group_ * this->num_blades_per_chassis_; // Links from routers to their local nodes. for (unsigned int i = 0; i < numRouters; i++) { // allocate structures - this->routers_[i]->my_nodes_ = new surf::LinkImpl*[num_links_per_link_ * this->num_nodes_per_blade_]; - this->routers_[i]->green_links_ = new surf::LinkImpl*[this->num_blades_per_chassis_]; - this->routers_[i]->black_links_ = new surf::LinkImpl*[this->num_chassis_per_group_]; + this->routers_[i]->my_nodes_ = new resource::LinkImpl*[num_links_per_link_ * this->num_nodes_per_blade_]; + this->routers_[i]->green_links_ = new resource::LinkImpl*[this->num_blades_per_chassis_]; + this->routers_[i]->black_links_ = new resource::LinkImpl*[this->num_chassis_per_group_]; for (unsigned int j = 0; j < num_links_per_link_ * this->num_nodes_per_blade_; j += num_links_per_link_) { std::string id = "local_link_from_router_" + std::to_string(i) + "_to_node_" + @@ -250,8 +251,8 @@ void DragonflyZone::generateLinks() for (unsigned int j = i + 1; j < this->num_groups_; j++) { unsigned int routernumi = i * num_blades_per_chassis_ * num_chassis_per_group_ + j; unsigned int routernumj = j * num_blades_per_chassis_ * num_chassis_per_group_ + i; - this->routers_[routernumi]->blue_links_ = new surf::LinkImpl*; - this->routers_[routernumj]->blue_links_ = new surf::LinkImpl*; + this->routers_[routernumi]->blue_links_ = new resource::LinkImpl*; + this->routers_[routernumj]->blue_links_ = new resource::LinkImpl*; std::string id = "blue_link_between_group_"+ std::to_string(i) +"_and_" + std::to_string(j) +"_routers_" + std::to_string(routernumi) + "_and_" + std::to_string(routernumj) + "_" + std::to_string(uniqueId); this->createLink(id, this->num_links_blue_, &linkup, &linkdown); @@ -275,7 +276,7 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA dst->id()); if ((src->id() == dst->id()) && has_loopback_) { - std::pair info = private_links_.at(node_pos(src->id())); + std::pair info = private_links_.at(node_pos(src->id())); route->link_list.push_back(info.first); if (latency) @@ -303,7 +304,7 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA *latency += myRouter->my_nodes_[myCoords[3] * num_links_per_link_]->latency(); if (has_limiter_) { // limiter for sender - std::pair info = private_links_.at(node_pos_with_loopback(src->id())); + std::pair info = private_links_.at(node_pos_with_loopback(src->id())); route->link_list.push_back(info.first); } @@ -353,7 +354,7 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA } if (has_limiter_) { // limiter for receiver - std::pair info = private_links_.at(node_pos_with_loopback(dst->id())); + std::pair info = private_links_.at(node_pos_with_loopback(dst->id())); route->link_list.push_back(info.first); } diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index 08849428c2..f2fa5dc6d9 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -450,7 +450,7 @@ FatTreeNode::FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int po linkTemplate.policy = SURF_LINK_SHARED; linkTemplate.id = "limiter_"+std::to_string(id); sg_platf_new_link(&linkTemplate); - this->limiter_link_ = surf::LinkImpl::byName(linkTemplate.id); + this->limiter_link_ = resource::LinkImpl::byName(linkTemplate.id); } if (cluster->loopback_bw || cluster->loopback_lat) { linkTemplate.bandwidth = cluster->loopback_bw; @@ -458,7 +458,7 @@ FatTreeNode::FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int po linkTemplate.policy = SURF_LINK_FATPIPE; linkTemplate.id = "loopback_"+ std::to_string(id); sg_platf_new_link(&linkTemplate); - this->loopback = surf::LinkImpl::byName(linkTemplate.id); + this->loopback = resource::LinkImpl::byName(linkTemplate.id); } } @@ -476,11 +476,11 @@ FatTreeLink::FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* downNode, Fa if (cluster->sharing_policy == SURF_LINK_SPLITDUPLEX) { std::string tmpID = std::string(linkTemplate.id) + "_UP"; - this->up_link_ = surf::LinkImpl::byName(tmpID); // check link? + this->up_link_ = resource::LinkImpl::byName(tmpID); // check link? tmpID = std::string(linkTemplate.id) + "_DOWN"; - this->down_link_ = surf::LinkImpl::byName(tmpID); // check link ? + this->down_link_ = resource::LinkImpl::byName(tmpID); // check link ? } else { - this->up_link_ = surf::LinkImpl::byName(linkTemplate.id); + this->up_link_ = resource::LinkImpl::byName(linkTemplate.id); this->down_link_ = this->up_link_; } uniqueId++; diff --git a/src/kernel/routing/FloydZone.cpp b/src/kernel/routing/FloydZone.cpp index f702344828..40e85f3f68 100644 --- a/src/kernel/routing/FloydZone.cpp +++ b/src/kernel/routing/FloydZone.cpp @@ -86,7 +86,7 @@ void FloydZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* } void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, - std::vector& link_list, bool symmetrical) + std::vector& link_list, bool symmetrical) { /* set the size of table routing */ unsigned int table_size = getTableSize(); diff --git a/src/kernel/routing/FullZone.cpp b/src/kernel/routing/FullZone.cpp index 208d9376ba..b0c87c0e86 100644 --- a/src/kernel/routing/FullZone.cpp +++ b/src/kernel/routing/FullZone.cpp @@ -71,9 +71,8 @@ void FullZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* } } -void FullZone::add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, - kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, - std::vector& link_list, bool symmetrical) +void FullZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) { addRouteCheckParams(src, dst, gw_src, gw_dst, link_list, symmetrical); diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 7e9aa1d3d9..240309ee9a 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -23,7 +23,7 @@ public: explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {} NetPoint* gw_src; NetPoint* gw_dst; - std::vector links; + std::vector links; }; NetZoneImpl::NetZoneImpl(NetZone* father, std::string name) : NetZone(father, name) @@ -65,7 +65,7 @@ simgrid::s4u::Host* NetZoneImpl::create_host(const char* name, std::vector& link_list, bool symmetrical) + std::vector& link_list, bool symmetrical) { /* Argument validity checks */ if (gw_dst) { @@ -204,7 +204,7 @@ static void find_common_ancestors(NetPoint* src, NetPoint* dst, /* PRECONDITION: this is the common ancestor of src and dst */ bool NetZoneImpl::get_bypass_route(routing::NetPoint* src, routing::NetPoint* dst, - /* OUT */ std::vector& links, double* latency) + /* OUT */ std::vector& links, double* latency) { // If never set a bypass route return nullptr without any further computations if (bypass_routes_.empty()) @@ -214,7 +214,7 @@ bool NetZoneImpl::get_bypass_route(routing::NetPoint* src, routing::NetPoint* ds 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) { + for (resource::LinkImpl* const& link : bypassedRoute->links) { links.push_back(link); if (latency) *latency += link->latency(); @@ -298,7 +298,7 @@ bool NetZoneImpl::get_bypass_route(routing::NetPoint* src, routing::NetPoint* ds src->get_cname(), dst->get_cname(), bypassedRoute->links.size()); if (src != key.first) get_global_route(src, bypassedRoute->gw_src, links, latency); - for (surf::LinkImpl* const& link : bypassedRoute->links) { + for (resource::LinkImpl* const& link : bypassedRoute->links) { links.push_back(link); if (latency) *latency += link->latency(); @@ -311,8 +311,8 @@ bool NetZoneImpl::get_bypass_route(routing::NetPoint* src, routing::NetPoint* ds return false; } -void NetZoneImpl::get_global_route(routing::NetPoint* src, routing::NetPoint* dst, - /* OUT */ std::vector& links, double* latency) +void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst, + /* OUT */ std::vector& links, double* latency) { RouteCreationArgs route; diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index d61f453c45..249320a36b 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -121,7 +121,7 @@ void RoutedZone::get_graph(xbt_graph_t graph, std::map* /* ************************* GENERIC AUX FUNCTIONS ************************** */ /* change a route containing link names into a route containing link entities */ RouteCreationArgs* RoutedZone::newExtendedRoute(RoutingMode hierarchy, NetPoint* src, NetPoint* dst, NetPoint* gw_src, - NetPoint* gw_dst, std::vector& link_list, + NetPoint* gw_dst, std::vector& link_list, bool symmetrical, bool change_order) { RouteCreationArgs* result = new RouteCreationArgs(); @@ -164,9 +164,8 @@ void RoutedZone::getRouteCheckParams(NetPoint* src, NetPoint* dst) "%s@%s). Please report that bug.", src->get_cname(), dst->get_cname(), src_as->get_cname(), dst_as->get_cname(), get_cname()); } -void RoutedZone::addRouteCheckParams(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, - kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, - std::vector& link_list, bool symmetrical) +void RoutedZone::addRouteCheckParams(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) { const char* srcName = src->get_cname(); const char* dstName = dst->get_cname(); diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index e2041cd665..c65d9a70b5 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -54,15 +54,15 @@ void TorusZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int link.latency = cluster->lat; link.policy = cluster->sharing_policy; sg_platf_new_link(&link); - surf::LinkImpl* linkUp; - surf::LinkImpl* linkDown; + resource::LinkImpl* linkUp; + resource::LinkImpl* linkDown; if (link.policy == SURF_LINK_SPLITDUPLEX) { std::string tmp_link = link_id + "_UP"; - linkUp = surf::LinkImpl::byName(tmp_link); + linkUp = resource::LinkImpl::byName(tmp_link); tmp_link = link_id + "_DOWN"; - linkDown = surf::LinkImpl::byName(tmp_link); + linkDown = resource::LinkImpl::byName(tmp_link); } else { - linkUp = surf::LinkImpl::byName(link_id); + linkUp = resource::LinkImpl::byName(link_id); linkDown = linkUp; } /* @@ -102,7 +102,7 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* return; if (src->id() == dst->id() && has_loopback_) { - std::pair info = private_links_.at(src->id() * num_links_per_node_); + std::pair info = private_links_.at(src->id() * num_links_per_node_); route->link_list.push_back(info.first); if (lat) @@ -177,7 +177,7 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* dim_product *= cur_dim; } - std::pair info; + std::pair info; if (has_limiter_) { // limiter for sender info = private_links_.at(nodeOffset + (has_loopback_ ? 1 : 0)); diff --git a/src/kernel/routing/VivaldiZone.cpp b/src/kernel/routing/VivaldiZone.cpp index 70c2b083ba..56cc29e901 100644 --- a/src/kernel/routing/VivaldiZone.cpp +++ b/src/kernel/routing/VivaldiZone.cpp @@ -72,8 +72,8 @@ void VivaldiZone::setPeerLink(NetPoint* netpoint, double bw_in, double bw_out, s std::string link_up = "link_" + netpoint->get_name() + "_UP"; std::string link_down = "link_" + netpoint->get_name() + "_DOWN"; - surf::LinkImpl* linkUp = surf_network_model->createLink(link_up, bw_out, 0, SURF_LINK_SHARED); - surf::LinkImpl* linkDown = surf_network_model->createLink(link_down, bw_in, 0, SURF_LINK_SHARED); + resource::LinkImpl* linkUp = surf_network_model->createLink(link_up, bw_out, 0, SURF_LINK_SHARED); + resource::LinkImpl* linkDown = surf_network_model->createLink(link_down, bw_in, 0, SURF_LINK_SHARED); private_links_.insert({netpoint->id(), {linkUp, linkDown}}); } @@ -91,7 +91,7 @@ void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg /* Retrieve the private links */ auto src_link = private_links_.find(src->id()); if (src_link != private_links_.end()) { - std::pair info = src_link->second; + std::pair info = src_link->second; if (info.first) { route->link_list.push_back(info.first); if (lat) @@ -103,7 +103,7 @@ void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg auto dst_link = private_links_.find(dst->id()); if (dst_link != private_links_.end()) { - std::pair info = dst_link->second; + std::pair info = dst_link->second; if (info.second) { route->link_list.push_back(info.second); if (lat) diff --git a/src/s4u/s4u_engine.cpp b/src/s4u/s4u_engine.cpp index c2bb1b643f..ba7530147c 100644 --- a/src/s4u/s4u_engine.cpp +++ b/src/s4u/s4u_engine.cpp @@ -158,7 +158,7 @@ void Engine::delStorage(std::string name) /** @brief Returns the amount of links in the platform */ size_t Engine::getLinkCount() { - return simgrid::surf::LinkImpl::linksCount(); + return kernel::resource::LinkImpl::linksCount(); } /** @brief Fills the passed list with all links found in the platform @@ -167,14 +167,14 @@ size_t Engine::getLinkCount() void XBT_ATTRIB_DEPRECATED_v322("Engine::getLinkList() is deprecated in favor of Engine::getAllLinks(). Please switch before v3.22") Engine::getLinkList(std::vector* list) { - simgrid::surf::LinkImpl::linksList(list); + kernel::resource::LinkImpl::linksList(list); } /** @brief Returns the list of all links found in the platform */ std::vector Engine::getAllLinks() { std::vector res; - simgrid::surf::LinkImpl::linksList(&res); + kernel::resource::LinkImpl::linksList(&res); return res; } diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index 481c10ac71..42b87910dd 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -143,14 +143,14 @@ void Host::actorList(std::vector* whereto) */ void Host::routeTo(Host* dest, std::vector& links, double* latency) { - std::vector linkImpls; + std::vector linkImpls; this->routeTo(dest, linkImpls, latency); - for (surf::LinkImpl* const& l : linkImpls) + for (kernel::resource::LinkImpl* const& l : linkImpls) links.push_back(&l->piface_); } /** @brief Just like Host::routeTo, but filling an array of link implementations */ -void Host::routeTo(Host* dest, std::vector& links, double* latency) +void Host::routeTo(Host* dest, std::vector& links, double* latency) { simgrid::kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint, dest->pimpl_netpoint, links, latency); if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) { diff --git a/src/s4u/s4u_link.cpp b/src/s4u/s4u_link.cpp index d9a5089527..031f57d268 100644 --- a/src/s4u/s4u_link.cpp +++ b/src/s4u/s4u_link.cpp @@ -49,11 +49,11 @@ void sg_link_data_set(sg_link_t link, void* data) } int sg_link_count() { - return simgrid::surf::LinkImpl::linksCount(); + return simgrid::kernel::resource::LinkImpl::linksCount(); } sg_link_t* sg_link_list() { - simgrid::surf::LinkImpl** list = simgrid::surf::LinkImpl::linksList(); + simgrid::kernel::resource::LinkImpl** list = simgrid::kernel::resource::LinkImpl::linksList(); sg_link_t* res = (sg_link_t*)list; // Use the same memory area int size = sg_link_count(); @@ -64,7 +64,7 @@ sg_link_t* sg_link_list() } void sg_link_exit() { - simgrid::surf::LinkImpl::linksExit(); + simgrid::kernel::resource::LinkImpl::linksExit(); } /*********** @@ -75,7 +75,7 @@ namespace simgrid { namespace s4u { Link* Link::byName(const char* name) { - surf::LinkImpl* res = surf::LinkImpl::byName(name); + kernel::resource::LinkImpl* res = kernel::resource::LinkImpl::byName(name); if (res == nullptr) return nullptr; return &res->piface_; @@ -171,7 +171,7 @@ void Link::setProperty(std::string key, std::string value) simgrid::xbt::signal Link::onCreation; simgrid::xbt::signal Link::onDestruction; simgrid::xbt::signal Link::onStateChange; -simgrid::xbt::signal Link::onCommunicate; -simgrid::xbt::signal Link::onCommunicationStateChange; +simgrid::xbt::signal Link::onCommunicate; +simgrid::xbt::signal Link::onCommunicationStateChange; } } diff --git a/src/s4u/s4u_netzone.cpp b/src/s4u/s4u_netzone.cpp index 03ba50ec39..5588961b53 100644 --- a/src/s4u/s4u_netzone.cpp +++ b/src/s4u/s4u_netzone.cpp @@ -16,7 +16,7 @@ namespace s4u { simgrid::xbt::signal& link_list)> + std::vector& link_list)> NetZone::onRouteCreation; simgrid::xbt::signal NetZone::onCreation; simgrid::xbt::signal NetZone::onSeal; @@ -103,7 +103,7 @@ int NetZone::addComponent(kernel::routing::NetPoint* elm) void NetZone::add_route(kernel::routing::NetPoint* /*src*/, kernel::routing::NetPoint* /*dst*/, kernel::routing::NetPoint* /*gw_src*/, kernel::routing::NetPoint* /*gw_dst*/, - std::vector& /*link_list*/, bool /*symmetrical*/) + std::vector& /*link_list*/, bool /*symmetrical*/) { xbt_die("NetZone '%s' does not accept new routes (wrong class).", name_.c_str()); } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 27b98cbc55..035ca869fe 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -35,7 +35,7 @@ void surf_network_model_init_LegrandVelho() if (surf_network_model) return; - surf_network_model = new simgrid::surf::NetworkCm02Model(); + surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(); all_existing_models->push_back(surf_network_model); xbt_cfg_setdefault_double("network/latency-factor", 13.01); @@ -64,7 +64,7 @@ void surf_network_model_init_CM02() xbt_cfg_setdefault_double("network/bandwidth-factor", 1.0); xbt_cfg_setdefault_double("network/weight-S", 0.0); - surf_network_model = new simgrid::surf::NetworkCm02Model(); + surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(); all_existing_models->push_back(surf_network_model); } @@ -90,7 +90,7 @@ void surf_network_model_init_Reno() xbt_cfg_setdefault_double("network/bandwidth-factor", 0.97); xbt_cfg_setdefault_double("network/weight-S", 20537); - surf_network_model = new simgrid::surf::NetworkCm02Model(&simgrid::kernel::lmm::make_new_lagrange_system); + surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(&simgrid::kernel::lmm::make_new_lagrange_system); all_existing_models->push_back(surf_network_model); } @@ -107,7 +107,7 @@ void surf_network_model_init_Reno2() xbt_cfg_setdefault_double("network/bandwidth-factor", 0.97); xbt_cfg_setdefault_double("network/weight-S", 20537); - surf_network_model = new simgrid::surf::NetworkCm02Model(&simgrid::kernel::lmm::make_new_lagrange_system); + surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(&simgrid::kernel::lmm::make_new_lagrange_system); all_existing_models->push_back(surf_network_model); } @@ -123,16 +123,16 @@ void surf_network_model_init_Vegas() xbt_cfg_setdefault_double("network/bandwidth-factor", 0.97); xbt_cfg_setdefault_double("network/weight-S", 20537); - surf_network_model = new simgrid::surf::NetworkCm02Model(&simgrid::kernel::lmm::make_new_lagrange_system); + surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(&simgrid::kernel::lmm::make_new_lagrange_system); all_existing_models->push_back(surf_network_model); } namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { NetworkCm02Model::NetworkCm02Model(kernel::lmm::System* (*make_new_lmm_system)(bool)) - : NetworkModel(xbt_cfg_get_string("network/optim") == "Full" ? kernel::resource::Model::UpdateAlgo::Full - : kernel::resource::Model::UpdateAlgo::Lazy) + : NetworkModel(xbt_cfg_get_string("network/optim") == "Full" ? Model::UpdateAlgo::Full : Model::UpdateAlgo::Lazy) { std::string optim = xbt_cfg_get_string("network/optim"); bool select = xbt_cfg_get_boolean("network/maxmin-selective-update"); @@ -172,19 +172,18 @@ void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/) } // if I am wearing a latency hat - if (action->get_type() == kernel::resource::ActionHeap::Type::latency) { + if (action->get_type() == ActionHeap::Type::latency) { XBT_DEBUG("Latency paid for action %p. Activating", action); get_maxmin_system()->update_variable_weight(action->get_variable(), action->weight_); get_action_heap().remove(action); action->set_last_update(); // if I am wearing a max_duration or normal hat - } else if (action->get_type() == kernel::resource::ActionHeap::Type::max_duration || - action->get_type() == kernel::resource::ActionHeap::Type::normal) { + } else if (action->get_type() == ActionHeap::Type::max_duration || action->get_type() == ActionHeap::Type::normal) { // no need to communicate anymore // assume that flows that reached max_duration have remaining of 0 XBT_DEBUG("Action %p finished", action); - action->finish(kernel::resource::Action::State::done); + action->finish(Action::State::done); get_action_heap().remove(action); } } @@ -232,12 +231,12 @@ void NetworkCm02Model::update_actions_state_full(double now, double delta) if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) || ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { - action.finish(kernel::resource::Action::State::done); + action.finish(Action::State::done); } } } -kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) +Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) { int failed = 0; double latency = 0.0; @@ -266,7 +265,7 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos action->weight_ = latency; action->latency_ = latency; action->rate_ = rate; - if (get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) { + if (get_update_algorithm() == Model::UpdateAlgo::Lazy) { action->set_last_update(); } @@ -289,14 +288,14 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos if (action->latency_ > 0) { action->set_variable(get_maxmin_system()->variable_new(action, 0.0, -1.0, constraints_per_variable)); - if (get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) { + if (get_update_algorithm() == Model::UpdateAlgo::Lazy) { // add to the heap the event when the latency is payed double date = action->latency_ + action->get_last_update(); - kernel::resource::ActionHeap::Type type; + ActionHeap::Type type; if (route.empty()) - type = kernel::resource::ActionHeap::Type::normal; + type = ActionHeap::Type::normal; else - type = kernel::resource::ActionHeap::Type::latency; + type = ActionHeap::Type::latency; XBT_DEBUG("Added action (%p) one latency event at date %f", action, date); get_action_heap().insert(action, date, type); @@ -372,12 +371,11 @@ void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value) turn_off(); while ((var = get_constraint()->get_variable(&elem))) { - kernel::resource::Action* action = static_cast(var->get_id()); + Action* action = static_cast(var->get_id()); - if (action->get_state() == kernel::resource::Action::State::running || - action->get_state() == kernel::resource::Action::State::ready) { + if (action->get_state() == Action::State::running || action->get_state() == Action::State::ready) { action->set_finish_time(now); - action->set_state(kernel::resource::Action::State::failed); + action->set_state(Action::State::failed); } } } @@ -484,3 +482,4 @@ void NetworkCm02Action::update_remains_lazy(double now) } } +} // namespace simgrid diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index 689ba92e34..2860c7c850 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -17,31 +17,26 @@ ***********/ namespace simgrid { - namespace surf { +namespace kernel { +namespace resource { - class XBT_PRIVATE NetworkCm02Model; - class XBT_PRIVATE NetworkCm02Action; - class XBT_PRIVATE NetworkSmpiModel; - - } -} +class XBT_PRIVATE NetworkCm02Model; +class XBT_PRIVATE NetworkCm02Action; +class XBT_PRIVATE NetworkSmpiModel; /********* * Model * *********/ -namespace simgrid { -namespace surf { - class NetworkCm02Model : public NetworkModel { public: - explicit NetworkCm02Model(kernel::lmm::System* (*make_new_sys)(bool) = &simgrid::kernel::lmm::make_new_maxmin_system); + explicit NetworkCm02Model(lmm::System* (*make_new_sys)(bool) = &lmm::make_new_maxmin_system); virtual ~NetworkCm02Model() = default; LinkImpl* createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) override; void update_actions_state_lazy(double now, double delta) override; void update_actions_state_full(double now, double delta) override; - kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; + Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; }; /************ @@ -51,7 +46,7 @@ public: class NetworkCm02Link : public LinkImpl { public: NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency, - e_surf_link_sharing_policy_t policy, kernel::lmm::System* system); + e_surf_link_sharing_policy_t policy, lmm::System* system); virtual ~NetworkCm02Link() = default; void apply_event(tmgr_trace_event_t event, double value) override; void setBandwidth(double value) override; @@ -66,11 +61,11 @@ class NetworkCm02Action : public NetworkAction { friend NetworkSmpiModel; public: - NetworkCm02Action(kernel::resource::Model* model, double cost, bool failed) : NetworkAction(model, cost, failed){}; + NetworkCm02Action(Model* model, double cost, bool failed) : NetworkAction(model, cost, failed){}; virtual ~NetworkCm02Action() = default; void update_remains_lazy(double now) override; }; } } - +} // namespace simgrid #endif /* SURF_NETWORK_CM02_HPP_ */ diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 4c0bd88d84..be5f87c75f 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -15,12 +15,13 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); void surf_network_model_init_Constant() { xbt_assert(surf_network_model == nullptr); - surf_network_model = new simgrid::surf::NetworkConstantModel(); + surf_network_model = new simgrid::kernel::resource::NetworkConstantModel(); all_existing_models->push_back(surf_network_model); } namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { LinkImpl* NetworkConstantModel::createLink(const std::string& name, double bw, double lat, e_surf_link_sharing_policy_t policy) { @@ -91,4 +92,5 @@ void NetworkConstantAction::update_remains_lazy(double /*now*/) THROW_IMPOSSIBLE; } } +} // namespace kernel } diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index 151b2d072a..c2219d97fd 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -11,28 +11,27 @@ #include "network_interface.hpp" namespace simgrid { - namespace surf { - - /*********** - * Classes * - ***********/ - - class XBT_PRIVATE NetworkConstantModel; - class XBT_PRIVATE NetworkConstantAction; - - /********* - * Model * - *********/ - class NetworkConstantModel : public NetworkModel { - public: - NetworkConstantModel() : NetworkModel(Model::UpdateAlgo::Full) {} - kernel::resource::Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size, - double rate) override; - double next_occuring_event(double now) override; - void update_actions_state(double now, double delta) override; - - LinkImpl* createLink(const std::string& name, double bw, double lat, - e_surf_link_sharing_policy_t policy) override; +namespace kernel { +namespace resource { + +/*********** + * Classes * + ***********/ + +class XBT_PRIVATE NetworkConstantModel; +class XBT_PRIVATE NetworkConstantAction; + +/********* + * Model * + *********/ +class NetworkConstantModel : public NetworkModel { +public: + NetworkConstantModel() : NetworkModel(Model::UpdateAlgo::Full) {} + Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size, double rate) override; + double next_occuring_event(double now) override; + void update_actions_state(double now, double delta) override; + + LinkImpl* createLink(const std::string& name, double bw, double lat, e_surf_link_sharing_policy_t policy) override; }; /********** @@ -48,5 +47,6 @@ namespace simgrid { } } +} // namespace simgrid #endif /* NETWORK_CONSTANT_HPP_ */ diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index ee9d50edb0..bbba768abf 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -15,8 +15,8 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); static void IB_create_host_callback(simgrid::s4u::Host& host){ - using simgrid::surf::NetworkIBModel; - using simgrid::surf::IBNode; + using simgrid::kernel::resource::IBNode; + using simgrid::kernel::resource::NetworkIBModel; static int id=0; // pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives @@ -27,10 +27,10 @@ static void IB_create_host_callback(simgrid::s4u::Host& host){ ((NetworkIBModel*)surf_network_model)->active_nodes.insert({host.get_name(), act}); } -static void IB_action_state_changed_callback(simgrid::surf::NetworkAction* action) +static void IB_action_state_changed_callback(simgrid::kernel::resource::NetworkAction* action) { - using simgrid::surf::NetworkIBModel; - using simgrid::surf::IBNode; + using simgrid::kernel::resource::IBNode; + using simgrid::kernel::resource::NetworkIBModel; if (action->get_state() != simgrid::kernel::resource::Action::State::done) return; @@ -43,12 +43,12 @@ static void IB_action_state_changed_callback(simgrid::surf::NetworkAction* actio } -static void IB_action_init_callback(simgrid::surf::NetworkAction* action, simgrid::s4u::Host* src, +static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction* action, simgrid::s4u::Host* src, simgrid::s4u::Host* dst) { - simgrid::surf::NetworkIBModel* ibModel = (simgrid::surf::NetworkIBModel*)surf_network_model; - simgrid::surf::IBNode* act_src; - simgrid::surf::IBNode* act_dst; + simgrid::kernel::resource::NetworkIBModel* ibModel = (simgrid::kernel::resource::NetworkIBModel*)surf_network_model; + simgrid::kernel::resource::IBNode* act_src; + simgrid::kernel::resource::IBNode* act_dst; auto asrc = ibModel->active_nodes.find(src->get_name()); if (asrc != ibModel->active_nodes.end()) { @@ -88,7 +88,7 @@ void surf_network_model_init_IB() if (surf_network_model) return; - surf_network_model = new simgrid::surf::NetworkIBModel(); + surf_network_model = new simgrid::kernel::resource::NetworkIBModel(); all_existing_models->push_back(surf_network_model); simgrid::s4u::Link::onCommunicationStateChange.connect(IB_action_state_changed_callback); simgrid::s4u::Link::onCommunicate.connect(IB_action_init_callback); @@ -98,7 +98,8 @@ void surf_network_model_init_IB() } namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { NetworkIBModel::NetworkIBModel() : NetworkSmpiModel() { @@ -237,3 +238,4 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode } } } +} // namespace simgrid diff --git a/src/surf/network_ib.hpp b/src/surf/network_ib.hpp index df41a8873a..960f2413c9 100644 --- a/src/surf/network_ib.hpp +++ b/src/surf/network_ib.hpp @@ -14,53 +14,52 @@ #include namespace simgrid { - namespace surf { +namespace kernel { +namespace resource { - class XBT_PRIVATE IBNode; +class XBT_PRIVATE IBNode; - class XBT_PRIVATE ActiveComm{ - public : - //IBNode* origin; - IBNode* destination; - NetworkAction *action; - double init_rate; - ActiveComm() : destination(nullptr),action(nullptr),init_rate(-1){}; - virtual ~ActiveComm() = default; - }; +class XBT_PRIVATE ActiveComm { +public: + IBNode* destination; + NetworkAction* action; + double init_rate; + ActiveComm() : destination(nullptr), action(nullptr), init_rate(-1){}; + virtual ~ActiveComm() = default; +}; - class IBNode{ - public : - int id; - //store related links, to ease computation of the penalties - std::vector ActiveCommsUp; - //store the number of comms received from each node - std::map ActiveCommsDown; - //number of comms the node is receiving - int nbActiveCommsDown; - explicit IBNode(int id) : id(id),nbActiveCommsDown(0){}; - virtual ~IBNode() = default; - }; +class IBNode { +public: + int id; + // store related links, to ease computation of the penalties + std::vector ActiveCommsUp; + // store the number of comms received from each node + std::map ActiveCommsDown; + // number of comms the node is receiving + int nbActiveCommsDown; + explicit IBNode(int id) : id(id), nbActiveCommsDown(0){}; + virtual ~IBNode() = default; +}; - class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel { - private: - void updateIBfactors_rec(IBNode* root, std::vector& updatedlist); - void computeIBfactors(IBNode *root); - public: - NetworkIBModel(); - explicit NetworkIBModel(const char *name); - ~NetworkIBModel() override; - void updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove); +class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel { +private: + void updateIBfactors_rec(IBNode* root, std::vector& updatedlist); + void computeIBfactors(IBNode* root); - std::unordered_map active_nodes; - std::unordered_map> active_comms; +public: + NetworkIBModel(); + explicit NetworkIBModel(const char* name); + ~NetworkIBModel() override; + void updateIBfactors(NetworkAction* action, IBNode* from, IBNode* to, int remove); - double Bs; - double Be; - double ys; + std::unordered_map active_nodes; + std::unordered_map> active_comms; - }; - - } + double Bs; + double Be; + double ys; +}; } - +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index acfa0d1479..4d6e228d2c 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -13,15 +13,16 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf, "Logging specific to the SURF network module"); namespace simgrid { - namespace surf { +namespace kernel { +namespace resource { - /* List of links */ - std::unordered_map* LinkImpl::links = new std::unordered_map(); +/* List of links */ +std::unordered_map* LinkImpl::links = new std::unordered_map(); - LinkImpl* LinkImpl::byName(std::string name) - { - auto link = links->find(name); - return link == links->end() ? nullptr : link->second; +LinkImpl* LinkImpl::byName(std::string name) +{ + auto link = links->find(name); + return link == links->end() ? nullptr : link->second; } /** @brief Returns the amount of links in the platform */ int LinkImpl::linksCount() @@ -55,32 +56,35 @@ namespace simgrid { } } } +} // namespace simgrid /********* * Model * *********/ -simgrid::surf::NetworkModel *surf_network_model = nullptr; +simgrid::kernel::resource::NetworkModel* surf_network_model = nullptr; namespace simgrid { - namespace surf { +namespace kernel { +namespace resource { - /** @brief Command-line option 'network/TCP-gamma' -- see \ref options_model_network_gamma */ - simgrid::config::Flag NetworkModel::cfg_tcp_gamma( - {"network/TCP-gamma", "network/TCP_gamma"}, - "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; " - "Use the last given value, which is the max window size)", - 4194304.0); +/** @brief Command-line option 'network/TCP-gamma' -- see \ref options_model_network_gamma */ +simgrid::config::Flag NetworkModel::cfg_tcp_gamma( + {"network/TCP-gamma", "network/TCP_gamma"}, + "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; " + "Use the last given value, which is the max window size)", + 4194304.0); - /** @brief Command-line option 'network/crosstraffic' -- see \ref options_model_network_crosstraffic */ - simgrid::config::Flag NetworkModel::cfg_crosstraffic( - "network/crosstraffic", - "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)", "yes"); +/** @brief Command-line option 'network/crosstraffic' -- see \ref options_model_network_crosstraffic */ +simgrid::config::Flag NetworkModel::cfg_crosstraffic( + "network/crosstraffic", + "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)", "yes"); - NetworkModel::~NetworkModel() = default; +NetworkModel::~NetworkModel() = default; - double NetworkModel::latencyFactor(double /*size*/) { - return sg_latency_factor; +double NetworkModel::latencyFactor(double /*size*/) +{ + return sg_latency_factor; } double NetworkModel::bandwidthFactor(double /*size*/) { @@ -95,7 +99,7 @@ namespace simgrid { { double minRes = Model::next_occuring_event_full(now); - for (kernel::resource::Action const& action : *get_running_action_set()) { + for (Action const& action : *get_running_action_set()) { const NetworkAction& net_action = static_cast(action); if (net_action.latency_ > 0) minRes = (minRes < 0) ? net_action.latency_ : std::min(minRes, net_action.latency_); @@ -110,7 +114,7 @@ namespace simgrid { * Resource * ************/ - LinkImpl::LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, kernel::lmm::Constraint* constraint) + LinkImpl::LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint* constraint) : Resource(model, name, constraint), piface_(this) { @@ -212,8 +216,7 @@ namespace simgrid { for (int i = 0; i < llen; i++) { /* Beware of composite actions: ptasks put links and cpus together */ // extra pb: we cannot dynamic_cast from void*... - kernel::resource::Resource* resource = - static_cast(get_variable()->get_constraint(i)->get_id()); + Resource* resource = static_cast(get_variable()->get_constraint(i)->get_id()); LinkImpl* link = dynamic_cast(resource); if (link != nullptr) retlist.push_back(link); @@ -222,6 +225,7 @@ namespace simgrid { return retlist; } } + } // namespace kernel } #endif /* NETWORK_INTERFACE_CPP_ */ diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 0717913fb2..82981510c3 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -21,7 +21,8 @@ ***********/ namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { /********* * Model * *********/ @@ -30,12 +31,12 @@ namespace surf { * @brief SURF network model interface class * @details A model is an object which handles the interactions between its Resources and its Actions */ -class NetworkModel : public kernel::resource::Model { +class NetworkModel : public Model { public: static simgrid::config::Flag cfg_tcp_gamma; static simgrid::config::Flag cfg_crosstraffic; - explicit NetworkModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {} + explicit NetworkModel(Model::UpdateAlgo algo) : Model(algo) {} ~NetworkModel() override; /** @@ -61,7 +62,7 @@ public: * unlimited. * @return The action representing the communication */ - virtual kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) = 0; + virtual Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) = 0; /** * @brief Get the right multiplicative factor for the latency. @@ -109,9 +110,9 @@ public: * @brief SURF network link interface class * @details A Link represents the link between two [hosts](\ref simgrid::surf::HostImpl) */ -class LinkImpl : public simgrid::kernel::resource::Resource, public simgrid::surf::PropertyHolder { +class LinkImpl : public Resource, public simgrid::surf::PropertyHolder { protected: - LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, kernel::lmm::Constraint* constraint); + LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint* constraint); ~LinkImpl() override; public: @@ -182,7 +183,7 @@ public: * @brief SURF network action interface class * @details A NetworkAction represents a communication between two [hosts](\ref HostImpl) */ -class NetworkAction : public simgrid::kernel::resource::Action { +class NetworkAction : public Action { public: /** @brief Constructor * @@ -190,23 +191,19 @@ public: * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] */ - NetworkAction(simgrid::kernel::resource::Model* model, double cost, bool failed) - : simgrid::kernel::resource::Action(model, cost, failed) - { - } + NetworkAction(Model* model, double cost, bool failed) : Action(model, cost, failed) {} /** * @brief NetworkAction constructor * * @param model The NetworkModel associated to this NetworkAction - * @param cost The cost of this NetworkAction in [TODO] - * @param failed [description] + * @param cost The cost of this NetworkAction in bytes + * @param failed Actions can be created in a failed state * @param var The lmm variable associated to this Action if it is part of a LMM component */ - NetworkAction(simgrid::kernel::resource::Model* model, double cost, bool failed, kernel::lmm::Variable* var) - : simgrid::kernel::resource::Action(model, cost, failed, var){}; + NetworkAction(Model* model, double cost, bool failed, lmm::Variable* var) : Action(model, cost, failed, var){}; - void set_state(simgrid::kernel::resource::Action::State state) override; + void set_state(Action::State state) override; virtual std::list links(); double latency_ = {}; @@ -216,11 +213,11 @@ public: }; } } - +} // namespace simgrid /** \ingroup SURF_models * \brief The network model */ -XBT_PUBLIC_DATA simgrid::surf::NetworkModel* surf_network_model; +XBT_PUBLIC_DATA simgrid::kernel::resource::NetworkModel* surf_network_model; #endif /* SURF_NETWORK_INTERFACE_HPP_ */ diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index d377157df0..13642d0a51 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -89,10 +89,10 @@ static void clusterCreation_cb(simgrid::kernel::routing::ClusterCreationArgs* cl 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& link_list) + std::vector& link_list) { if (link_list.size() == 1) { - simgrid::surf::LinkNS3* link = static_cast(link_list[0]); + simgrid::kernel::resource::LinkNS3* link = static_cast(link_list[0]); XBT_DEBUG("Route from '%s' to '%s' with link '%s' %s", src->get_cname(), dst->get_cname(), link->get_cname(), (symmetrical ? "(symmetrical)" : "(not symmetrical)")); @@ -139,7 +139,7 @@ void surf_network_model_init_NS3() if (surf_network_model) return; - surf_network_model = new simgrid::surf::NetworkNS3Model(); + surf_network_model = new simgrid::kernel::resource::NetworkNS3Model(); all_existing_models->push_back(surf_network_model); } @@ -147,7 +147,8 @@ static simgrid::config::Flag ns3_tcp_model("ns3/TcpModel", "The ns3 tcp model can be : NewReno or Reno or Tahoe", "default"); namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { NetworkNS3Model::NetworkNS3Model() : NetworkModel(Model::UpdateAlgo::Full) { @@ -347,6 +348,7 @@ void NetworkNS3Action::update_remains_lazy(double /*now*/) THROW_IMPOSSIBLE; } +} // namespace resource } } diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index aa8ab6bde4..27e8058e11 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -11,7 +11,8 @@ #include "network_interface.hpp" namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { class NetworkNS3Model : public NetworkModel { public: @@ -58,6 +59,7 @@ public: s4u::Host* dst_; }; +} // namespace resource } } diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 2b1c21d102..4189c00eb6 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -33,14 +33,15 @@ void surf_network_model_init_SMPI() { if (surf_network_model) return; - surf_network_model = new simgrid::surf::NetworkSmpiModel(); + surf_network_model = new simgrid::kernel::resource::NetworkSmpiModel(); all_existing_models->push_back(surf_network_model); xbt_cfg_setdefault_double("network/weight-S", 8775); } namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model() { @@ -98,3 +99,4 @@ double NetworkSmpiModel::bandwidthConstraint(double rate, double bound, double s **********/ } } +} // namespace simgrid diff --git a/src/surf/network_smpi.hpp b/src/surf/network_smpi.hpp index 8a91cb852f..01ff44d025 100644 --- a/src/surf/network_smpi.hpp +++ b/src/surf/network_smpi.hpp @@ -9,16 +9,18 @@ #include "network_cm02.hpp" namespace simgrid { - namespace surf { +namespace kernel { +namespace resource { - class XBT_PRIVATE NetworkSmpiModel : public NetworkCm02Model { - public: - NetworkSmpiModel(); - ~NetworkSmpiModel(); +class XBT_PRIVATE NetworkSmpiModel : public NetworkCm02Model { +public: + NetworkSmpiModel(); + ~NetworkSmpiModel(); - double latencyFactor(double size); - double bandwidthFactor(double size); - double bandwidthConstraint(double rate, double bound, double size); - }; - } + double latencyFactor(double size); + double bandwidthFactor(double size); + double bandwidthConstraint(double rate, double bound, double size); +}; +} // namespace resource +} // namespace kernel } diff --git a/src/surf/ns3/ns3_simulator.cpp b/src/surf/ns3/ns3_simulator.cpp index 1ced7bc051..825e555f2f 100644 --- a/src/surf/ns3/ns3_simulator.cpp +++ b/src/surf/ns3/ns3_simulator.cpp @@ -19,7 +19,7 @@ static void datasent_cb(ns3::Ptr socket, uint32_t dataSent); XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3); -SgFlow::SgFlow(uint32_t totalBytes, simgrid::surf::NetworkNS3Action* action) +SgFlow::SgFlow(uint32_t totalBytes, simgrid::kernel::resource::NetworkNS3Action* action) { totalBytes_ = totalBytes; remaining_ = totalBytes; diff --git a/src/surf/ns3/ns3_simulator.hpp b/src/surf/ns3/ns3_simulator.hpp index edb6fc7c8b..db1236a9b6 100644 --- a/src/surf/ns3/ns3_simulator.hpp +++ b/src/surf/ns3/ns3_simulator.hpp @@ -7,18 +7,13 @@ #define NS3_SIMULATOR_HPP #include "simgrid/s4u/Host.hpp" +#include "src/surf/network_ns3.hpp" #include #include #include -namespace simgrid { -namespace surf { -class NetworkNS3Action; -} -} // namespace simgrid - class NetPointNs3 { public: static simgrid::xbt::Extension EXTENSION_ID; @@ -37,7 +32,7 @@ XBT_PUBLIC void ns3_add_cluster(const char* id, double bw, double lat); class XBT_PRIVATE SgFlow { public: - SgFlow(uint32_t totalBytes, simgrid::surf::NetworkNS3Action* action); + SgFlow(uint32_t totalBytes, simgrid::kernel::resource::NetworkNS3Action* action); // private: std::uint32_t bufferedBytes_ = 0; @@ -45,7 +40,7 @@ public: std::uint32_t remaining_; std::uint32_t totalBytes_; bool finished_ = false; - simgrid::surf::NetworkNS3Action* action_; + simgrid::kernel::resource::NetworkNS3Action* action_; }; void StartFlow(ns3::Ptr sock, const char* to, uint16_t port_number); diff --git a/src/surf/plugins/link_energy.cpp b/src/surf/plugins/link_energy.cpp index dbe5c8fe9b..f8ec4bac5e 100644 --- a/src/surf/plugins/link_energy.cpp +++ b/src/surf/plugins/link_energy.cpp @@ -145,10 +145,11 @@ double LinkEnergy::getConsumedEnergy() using simgrid::plugin::LinkEnergy; /* **************************** events callback *************************** */ -static void onCommunicate(simgrid::surf::NetworkAction* action, simgrid::s4u::Host* src, simgrid::s4u::Host* dst) +static void onCommunicate(simgrid::kernel::resource::NetworkAction* action, simgrid::s4u::Host* src, + simgrid::s4u::Host* dst) { XBT_DEBUG("onCommunicate is called"); - for (simgrid::surf::LinkImpl* link : action->links()) { + for (simgrid::kernel::resource::LinkImpl* link : action->links()) { if (link == nullptr) continue; @@ -206,8 +207,8 @@ void sg_link_energy_plugin_init() link.extension()->getConsumedEnergy()); }); - simgrid::s4u::Link::onCommunicationStateChange.connect([](simgrid::surf::NetworkAction* action) { - for (simgrid::surf::LinkImpl* link : action->links()) { + simgrid::s4u::Link::onCommunicationStateChange.connect([](simgrid::kernel::resource::NetworkAction* action) { + for (simgrid::kernel::resource::LinkImpl* link : action->links()) { if (link != nullptr) link->piface_.extension()->update(); } diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 9e2bfe1fb1..f2edb251ef 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -163,7 +163,7 @@ L07Action::L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* hos if (bytes_amount[i * host_nb + j] > 0) { double lat=0.0; - std::vector route; + std::vector route; hostList_->at(i)->routeTo(hostList_->at(j), route, &lat); latency = std::max(latency, lat); @@ -191,7 +191,7 @@ L07Action::L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* hos for (int i = 0; i < host_nb; i++) { for (int j = 0; j < host_nb; j++) { if (bytes_amount[i * host_nb + j] > 0.0) { - std::vector route; + std::vector route; hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr); for (auto const& link : route) @@ -227,8 +227,8 @@ Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, std::vector *spee return new CpuL07(this, host, speedPerPstate, core); } -LinkImpl* NetworkL07Model::createLink(const std::string& name, double bandwidth, double latency, - e_surf_link_sharing_policy_t policy) +kernel::resource::LinkImpl* NetworkL07Model::createLink(const std::string& name, double bandwidth, double latency, + e_surf_link_sharing_policy_t policy) { return new LinkL07(this, name, bandwidth, latency, policy); } @@ -388,7 +388,7 @@ void L07Action::updateBound() if (communicationAmount_[i * hostNb + j] > 0) { double lat = 0.0; - std::vector route; + std::vector route; hostList_->at(i)->routeTo(hostList_->at(j), route, &lat); lat_current = std::max(lat_current, lat * communicationAmount_[i * hostNb + j]); @@ -396,7 +396,7 @@ void L07Action::updateBound() } } } - double lat_bound = NetworkModel::cfg_tcp_gamma / (2.0 * lat_current); + double lat_bound = kernel::resource::NetworkModel::cfg_tcp_gamma / (2.0 * lat_current); XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound); if ((latency_ <= 0.0) && (suspended_ == Action::SuspendStates::not_suspended)) { if (rate_ < 0) diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 25364a291c..e0a8ae9b4c 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -53,12 +53,12 @@ public: HostL07Model *hostModel_; }; -class NetworkL07Model : public NetworkModel { +class NetworkL07Model : public kernel::resource::NetworkModel { public: NetworkL07Model(HostL07Model* hmodel, kernel::lmm::System* sys); ~NetworkL07Model(); - LinkImpl* createLink(const std::string& name, double bandwidth, double latency, - e_surf_link_sharing_policy_t policy) override; + kernel::resource::LinkImpl* createLink(const std::string& name, double bandwidth, double latency, + e_surf_link_sharing_policy_t policy) override; kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; @@ -87,7 +87,7 @@ protected: void onSpeedChange() override; }; -class LinkL07 : public LinkImpl { +class LinkL07 : public kernel::resource::LinkImpl { public: LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy); diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 4c2161a5f6..c8057adcbb 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -120,7 +120,7 @@ void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link) names.push_back(link->id); } for (auto const& link_name : names) { - simgrid::surf::LinkImpl* l = + simgrid::kernel::resource::LinkImpl* l = surf_network_model->createLink(link_name, link->bandwidth, link->latency, link->policy); if (link->properties) { @@ -209,8 +209,8 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster // other columns are to store one or more link for the node //add a loopback link - simgrid::surf::LinkImpl* linkUp = nullptr; - simgrid::surf::LinkImpl* linkDown = nullptr; + simgrid::kernel::resource::LinkImpl* linkUp = nullptr; + simgrid::kernel::resource::LinkImpl* linkDown = nullptr; if(cluster->loopback_bw > 0 || cluster->loopback_lat > 0){ std::string tmp_link = link_id + "_loopback"; XBT_DEBUG("", tmp_link.c_str(), cluster->loopback_bw); @@ -221,8 +221,8 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster link.latency = cluster->loopback_lat; link.policy = SURF_LINK_FATPIPE; sg_platf_new_link(&link); - linkUp = simgrid::surf::LinkImpl::byName(tmp_link); - linkDown = simgrid::surf::LinkImpl::byName(tmp_link); + linkUp = simgrid::kernel::resource::LinkImpl::byName(tmp_link); + linkDown = simgrid::kernel::resource::LinkImpl::byName(tmp_link); auto* as_cluster = static_cast(current_as); as_cluster->private_links_.insert({as_cluster->node_pos(rankId), {linkUp, linkDown}}); @@ -241,7 +241,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster link.latency = 0; link.policy = SURF_LINK_SHARED; sg_platf_new_link(&link); - linkDown = simgrid::surf::LinkImpl::byName(tmp_link); + linkDown = simgrid::kernel::resource::LinkImpl::byName(tmp_link); linkUp = linkDown; current_as->private_links_.insert({current_as->node_pos_with_loopback(rankId), {linkUp, linkDown}}); } @@ -278,7 +278,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster XBT_DEBUG("", link.id.c_str(), cluster->bb_bw, cluster->bb_lat); sg_platf_new_link(&link); - routing_cluster_add_backbone(simgrid::surf::LinkImpl::byName(link.id)); + routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl::byName(link.id)); } XBT_DEBUG(""); @@ -288,7 +288,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster delete cluster->radicals; } -void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb) +void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb) { simgrid::kernel::routing::ClusterZone* cluster = dynamic_cast(current_routing); @@ -644,8 +644,8 @@ void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostl xbt_assert(dynamic_cast(current_routing), "Only hosts from Cluster and Vivaldi ASes can get an host_link."); - simgrid::surf::LinkImpl* linkUp = simgrid::surf::LinkImpl::byName(hostlink->link_up); - simgrid::surf::LinkImpl* linkDown = simgrid::surf::LinkImpl::byName(hostlink->link_down); + simgrid::kernel::resource::LinkImpl* linkUp = simgrid::kernel::resource::LinkImpl::byName(hostlink->link_up); + simgrid::kernel::resource::LinkImpl* linkDown = simgrid::kernel::resource::LinkImpl::byName(hostlink->link_down); xbt_assert(linkUp, "Link '%s' not found!", hostlink->link_up.c_str()); xbt_assert(linkDown, "Link '%s' not found!", hostlink->link_down.c_str()); diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index 2004447b91..1b0f9357ac 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -78,7 +78,7 @@ public: NetPoint* dst = nullptr; NetPoint* gw_src = nullptr; NetPoint* gw_dst = nullptr; - std::vector link_list; + std::vector link_list; }; enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 }; @@ -182,7 +182,7 @@ public: extern "C" { /********** Routing **********/ -void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb); +void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb); /*** END of the parsing cruft ***/ XBT_PUBLIC void sg_platf_begin(); // Start a new platform diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 34ac5204aa..db18b6343f 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -25,7 +25,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf, "Logging specific to the SURF #include "simgrid_dtd.c" static const char* surf_parsed_filename; // Currently parsed file (for the error messages) -std::vector parsed_link_list; /* temporary store of current list link of a route */ +std::vector + parsed_link_list; /* temporary store of current list link of a route */ /* * Helping functions @@ -608,17 +609,17 @@ void ETag_surfxml_link(){ void STag_surfxml_link___ctn() { - simgrid::surf::LinkImpl* link = nullptr; + simgrid::kernel::resource::LinkImpl* link = nullptr; switch (A_surfxml_link___ctn_direction) { case AU_surfxml_link___ctn_direction: case A_surfxml_link___ctn_direction_NONE: - link = simgrid::surf::LinkImpl::byName(A_surfxml_link___ctn_id); + link = simgrid::kernel::resource::LinkImpl::byName(A_surfxml_link___ctn_id); break; case A_surfxml_link___ctn_direction_UP: - link = simgrid::surf::LinkImpl::byName(std::string(A_surfxml_link___ctn_id) + "_UP"); + link = simgrid::kernel::resource::LinkImpl::byName(std::string(A_surfxml_link___ctn_id) + "_UP"); break; case A_surfxml_link___ctn_direction_DOWN: - link = simgrid::surf::LinkImpl::byName(std::string(A_surfxml_link___ctn_id) + "_DOWN"); + link = simgrid::kernel::resource::LinkImpl::byName(std::string(A_surfxml_link___ctn_id) + "_DOWN"); break; default: surf_parse_error(std::string("Invalid direction for link ") + A_surfxml_link___ctn_id); @@ -650,7 +651,7 @@ void ETag_surfxml_backbone(){ link.policy = SURF_LINK_SHARED; sg_platf_new_link(&link); - routing_cluster_add_backbone(simgrid::surf::LinkImpl::byName(A_surfxml_backbone_id)); + routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl::byName(A_surfxml_backbone_id)); } void STag_surfxml_route(){ diff --git a/teshsuite/simdag/flatifier/flatifier.cpp b/teshsuite/simdag/flatifier/flatifier.cpp index a43c039394..d21cf4d8cd 100644 --- a/teshsuite/simdag/flatifier/flatifier.cpp +++ b/teshsuite/simdag/flatifier/flatifier.cpp @@ -127,7 +127,7 @@ static void dump_routes() simgrid::kernel::routing::NetPoint* netcardSrc = host1->pimpl_netpoint; for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host simgrid::s4u::Host* host2 = hosts[it_dst]; - std::vector route; + std::vector route; simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint; simgrid::kernel::routing::NetZoneImpl::get_global_route(netcardSrc, netcardDst, route, nullptr); if (not route.empty()) { @@ -141,7 +141,7 @@ static void dump_routes() for (auto const& netcardDst : netcardList) { // to router if (netcardDst->is_router()) { std::printf(" \n ", host1->get_cname(), netcardDst->get_cname()); - std::vector route; + std::vector route; simgrid::kernel::routing::NetZoneImpl::get_global_route(netcardSrc, netcardDst, route, nullptr); for (auto const& link : route) std::printf("", link->get_cname()); @@ -155,7 +155,7 @@ static void dump_routes() for (auto const& value2 : netcardList) { // to router if (value2->is_router()) { std::printf(" \n ", value1->get_cname(), value2->get_cname()); - std::vector route; + std::vector route; simgrid::kernel::routing::NetZoneImpl::get_global_route(value1, value2, route, nullptr); for (auto const& link : route) std::printf("", link->get_cname()); @@ -165,7 +165,7 @@ static void dump_routes() for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host simgrid::s4u::Host* host2 = hosts[it_dst]; std::printf(" \n ", value1->get_cname(), host2->get_cname()); - std::vector route; + std::vector route; simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint; simgrid::kernel::routing::NetZoneImpl::get_global_route(value1, netcardDst, route, nullptr); for (auto const& link : route) -- 2.20.1