From: SUTER Frederic Date: Wed, 5 Jan 2022 14:56:37 +0000 (+0100) Subject: reorganize *LinkImpl stuff X-Git-Tag: v3.30~129 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/76d4849864c227687e17bdd93c5b1338e9b4cb50 reorganize *LinkImpl stuff --- diff --git a/MANIFEST.in b/MANIFEST.in index 29c5e334f6..583e1ab64b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2284,11 +2284,20 @@ include src/kernel/resource/CpuImpl.cpp include src/kernel/resource/CpuImpl.hpp include src/kernel/resource/DiskImpl.cpp include src/kernel/resource/DiskImpl.hpp +include src/kernel/resource/LinkImpl.cpp +include src/kernel/resource/LinkImpl.hpp include src/kernel/resource/Model.cpp include src/kernel/resource/NetworkModelIntf_test.cpp include src/kernel/resource/Resource.hpp +include src/kernel/resource/SplitDuplexLinkImpl.cpp +include src/kernel/resource/SplitDuplexLinkImpl.hpp +include src/kernel/resource/SplitDuplexLinkImpl_test.cpp +include src/kernel/resource/StandardLinkImpl.cpp +include src/kernel/resource/StandardLinkImpl.hpp include src/kernel/resource/VirtualMachineImpl.cpp include src/kernel/resource/VirtualMachineImpl.hpp +include src/kernel/resource/WifiLinkImpl.cpp +include src/kernel/resource/WifiLinkImpl.hpp include src/kernel/resource/profile/DatedValue.cpp include src/kernel/resource/profile/DatedValue.hpp include src/kernel/resource/profile/Event.hpp @@ -2641,12 +2650,6 @@ include src/smpi/smpirun.in include src/smpi/smpitools.sh include src/surf/HostImpl.cpp include src/surf/HostImpl.hpp -include src/surf/LinkImpl.cpp -include src/surf/LinkImpl.hpp -include src/surf/LinkImplIntf.hpp -include src/surf/SplitDuplexLinkImpl.cpp -include src/surf/SplitDuplexLinkImpl.hpp -include src/surf/SplitDuplexLinkImpl_test.cpp include src/surf/cpu_cas01.cpp include src/surf/cpu_cas01.hpp include src/surf/cpu_ti.cpp @@ -2661,14 +2664,10 @@ include src/surf/network_constant.cpp include src/surf/network_constant.hpp include src/surf/network_ib.cpp include src/surf/network_ib.hpp -include src/surf/network_interface.cpp -include src/surf/network_interface.hpp include src/surf/network_ns3.cpp include src/surf/network_ns3.hpp include src/surf/network_smpi.cpp include src/surf/network_smpi.hpp -include src/surf/network_wifi.cpp -include src/surf/network_wifi.hpp include src/surf/ns3/ns3_simulator.cpp include src/surf/ns3/ns3_simulator.hpp include src/surf/ptask_L07.cpp diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index f5f5c6a664..ab25b7f985 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -173,8 +173,8 @@ class HostModel; class NetworkModel; class NetworkModelIntf; class LinkImpl; +class StandardLinkImpl; class SplitDuplexLinkImpl; -class LinkImplIntf; class NetworkAction; class DiskImpl; class DiskModel; diff --git a/include/simgrid/kernel/routing/ClusterZone.hpp b/include/simgrid/kernel/routing/ClusterZone.hpp index 8ed8894319..4efbe49260 100644 --- a/include/simgrid/kernel/routing/ClusterZone.hpp +++ b/include/simgrid/kernel/routing/ClusterZone.hpp @@ -88,9 +88,9 @@ protected: class XBT_PRIVATE ClusterBase : public ClusterZone { /* We use a map instead of a std::vector here because that's a sparse vector. Some values may not exist */ /* The pair is {link_up, link_down} */ - std::unordered_map> private_links_; + std::unordered_map> private_links_; std::unordered_map gateways_; //!< list of gateways for leafs (if they're netzones) - resource::LinkImpl* backbone_ = nullptr; + resource::StandardLinkImpl* backbone_ = nullptr; NetPoint* router_ = nullptr; bool has_limiter_ = false; bool has_loopback_ = false; @@ -104,8 +104,14 @@ class XBT_PRIVATE ClusterBase : public ClusterZone { protected: using ClusterZone::ClusterZone; void set_num_links_per_node(unsigned long num) { num_links_per_node_ = num; } - resource::LinkImpl* get_uplink_from(unsigned long position) const { return private_links_.at(position).first; } - resource::LinkImpl* get_downlink_to(unsigned long position) const { return private_links_.at(position).second; } + resource::StandardLinkImpl* get_uplink_from(unsigned long position) const + { + return private_links_.at(position).first; + } + resource::StandardLinkImpl* get_downlink_to(unsigned long position) const + { + return private_links_.at(position).second; + } double get_link_latency() const { return link_lat_; } double get_link_bandwidth() const { return link_bw_; } @@ -115,14 +121,15 @@ protected: bool has_loopback() const { return has_loopback_; } void set_limiter(); bool has_limiter() const { return has_limiter_; } - void set_backbone(resource::LinkImpl* bb) { backbone_ = bb; } + void set_backbone(resource::StandardLinkImpl* bb) { backbone_ = bb; } bool has_backbone() const { return backbone_ != nullptr; } void set_router(NetPoint* router) { router_ = router; } /** @brief Sets gateway for the leaf */ void set_gateway(unsigned long position, NetPoint* gateway); /** @brief Gets gateway for the leaf or nullptr */ NetPoint* get_gateway(unsigned long position); - void add_private_link_at(unsigned long position, std::pair link); + void add_private_link_at(unsigned long position, + std::pair link); bool private_link_exists_at(unsigned long position) const { return private_links_.find(position) != private_links_.end(); diff --git a/include/simgrid/kernel/routing/DragonflyZone.hpp b/include/simgrid/kernel/routing/DragonflyZone.hpp index bfbc897573..e0f0c4fd0c 100644 --- a/include/simgrid/kernel/routing/DragonflyZone.hpp +++ b/include/simgrid/kernel/routing/DragonflyZone.hpp @@ -18,12 +18,12 @@ public: unsigned int group_; unsigned int chassis_; unsigned int blade_; - resource::LinkImpl* blue_link_ = nullptr; - resource::LinkImpl* limiter_ = nullptr; - std::vector black_links_; - std::vector green_links_; - std::vector my_nodes_; - DragonflyRouter(unsigned group, unsigned chassis, unsigned blade, resource::LinkImpl* limiter) + resource::StandardLinkImpl* blue_link_ = nullptr; + resource::StandardLinkImpl* limiter_ = nullptr; + std::vector black_links_; + std::vector green_links_; + std::vector my_nodes_; + DragonflyRouter(unsigned group, unsigned chassis, unsigned blade, resource::StandardLinkImpl* limiter) : group_(group), chassis_(chassis), blade_(blade), limiter_(limiter) { } @@ -96,7 +96,8 @@ public: private: void generate_routers(const s4u::ClusterCallbacks& set_callbacks); void generate_links(); - void generate_link(const std::string& id, int numlinks, resource::LinkImpl** linkup, resource::LinkImpl** linkdown); + void generate_link(const std::string& id, int numlinks, resource::StandardLinkImpl** linkup, + resource::StandardLinkImpl** linkdown); unsigned int num_nodes_per_blade_ = 0; unsigned int num_blades_per_chassis_ = 0; diff --git a/include/simgrid/kernel/routing/FatTreeZone.hpp b/include/simgrid/kernel/routing/FatTreeZone.hpp index a493182be1..2f45948f8a 100644 --- a/include/simgrid/kernel/routing/FatTreeZone.hpp +++ b/include/simgrid/kernel/routing/FatTreeZone.hpp @@ -46,12 +46,13 @@ public: /** Virtual link standing for the node global capacity. */ - resource::LinkImpl* limiter_link_; + resource::StandardLinkImpl* limiter_link_; /** If present, communications from this node to this node will pass through it * instead of passing by an upper level switch. */ - resource::LinkImpl* loopback_; - FatTreeNode(int id, int level, int position, resource::LinkImpl* limiter, resource::LinkImpl* loopback) + resource::StandardLinkImpl* loopback_; + FatTreeNode(int id, int level, int position, resource::StandardLinkImpl* limiter, + resource::StandardLinkImpl* loopback) : id(id), level(level), position(position), limiter_link_(limiter), loopback_(loopback) { } @@ -64,7 +65,8 @@ public: */ class FatTreeLink { public: - FatTreeLink(FatTreeNode* src, FatTreeNode* dst, resource::LinkImpl* linkup, resource::LinkImpl* linkdown) + FatTreeLink(FatTreeNode* src, FatTreeNode* dst, resource::StandardLinkImpl* linkup, + resource::StandardLinkImpl* linkdown) : up_node_(dst), down_node_(src), up_link_(linkup), down_link_(linkdown) { } @@ -73,9 +75,9 @@ public: /** Lower end of the link */ FatTreeNode* down_node_; /** Link going up in the tree */ - resource::LinkImpl* up_link_; + resource::StandardLinkImpl* up_link_; /** Link going down in the tree */ - resource::LinkImpl* down_link_; + resource::StandardLinkImpl* down_link_; }; /** @ingroup ROUTING_API @@ -148,7 +150,7 @@ public: /** @brief Set FatTree topology */ void set_topology(unsigned int n_levels, const std::vector& down_links, const std::vector& up_links, const std::vector& link_count); - void add_processing_node(int id, resource::LinkImpl* limiter, resource::LinkImpl* loopback); + void add_processing_node(int id, resource::StandardLinkImpl* limiter, resource::StandardLinkImpl* loopback); /** * @brief Build upper levels (switches) in Fat-Tree * diff --git a/include/simgrid/kernel/routing/NetZoneImpl.hpp b/include/simgrid/kernel/routing/NetZoneImpl.hpp index 4ca03861e5..733d7b4857 100644 --- a/include/simgrid/kernel/routing/NetZoneImpl.hpp +++ b/include/simgrid/kernel/routing/NetZoneImpl.hpp @@ -31,7 +31,7 @@ public: NetPoint* dst_ = nullptr; NetPoint* gw_src_ = nullptr; NetPoint* gw_dst_ = nullptr; - std::vector link_list_; + std::vector link_list_; }; class BypassRoute { @@ -39,7 +39,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; }; /** @ingroup ROUTING_API @@ -104,15 +104,15 @@ 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(const routing::NetPoint* src, const routing::NetPoint* dst, - /* OUT */ std::vector& links, double* latency, + /* OUT */ std::vector& links, double* latency, std::unordered_set& netzones); /** @brief Get the NetZone that is represented by the netpoint */ const NetZoneImpl* get_netzone_recursive(const NetPoint* netpoint) const; /** @brief Get the list of LinkImpl* to add in a route, considering split-duplex links and the direction */ - std::vector get_link_list_impl(const std::vector& link_list, - bool backroute) const; + std::vector get_link_list_impl(const std::vector& link_list, + bool backroute) const; public: enum class RoutingMode { @@ -191,11 +191,11 @@ public: * @param latency Accumulator in which the latencies should be added (caller must set it to 0) */ static void get_global_route(const NetPoint* src, const NetPoint* dst, - /* OUT */ std::vector& links, double* latency); + /* OUT */ std::vector& links, double* latency); /** @brief Similar to get_global_route but get the NetZones traversed by route */ static void get_global_route_with_netzones(const NetPoint* src, const NetPoint* dst, - /* OUT */ std::vector& links, double* latency, + /* OUT */ std::vector& links, double* latency, std::unordered_set& netzones); virtual void get_graph(const s_xbt_graph_t* graph, std::map>* nodes, @@ -203,7 +203,7 @@ public: /*** Called on each newly created regular route (not on bypass routes) */ static xbt::signal const& link_list)> + std::vector const& link_list)> on_route_creation; // XBT_ATTRIB_DEPRECATED_v332 : should be an internal signal used by NS3.. if necessary, // callback shouldn't use LinkImpl* diff --git a/include/simgrid/kernel/routing/RoutedZone.hpp b/include/simgrid/kernel/routing/RoutedZone.hpp index 8b69c7c132..a8fe0d8ebc 100644 --- a/include/simgrid/kernel/routing/RoutedZone.hpp +++ b/include/simgrid/kernel/routing/RoutedZone.hpp @@ -57,7 +57,7 @@ public: protected: Route* new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, NetPoint* gw_dst, - const std::vector& link_list, bool preserve_order); + const std::vector& link_list, bool preserve_order); void get_route_check_params(const NetPoint* src, const NetPoint* dst) const; void add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, const std::vector& link_list, bool symmetrical) const; diff --git a/include/simgrid/kernel/routing/StarZone.hpp b/include/simgrid/kernel/routing/StarZone.hpp index 9327c3b8ac..f000d6f308 100644 --- a/include/simgrid/kernel/routing/StarZone.hpp +++ b/include/simgrid/kernel/routing/StarZone.hpp @@ -75,9 +75,9 @@ public: private: class StarRoute { public: - std::vector links_up; //!< list of links UP for route (can be empty) - std::vector links_down; //!< list of links DOWN for route (can be empty) - std::vector loopback; //!< loopback links, cannot be empty if configured + std::vector links_up; //!< list of links UP for route (can be empty) + std::vector links_down; //!< list of links DOWN for route (can be empty) + std::vector loopback; //!< loopback links, cannot be empty if configured bool links_up_set = false; //!< bool to indicate that links_up was configured (empty or not) bool links_down_set = false; //!< same for links_down NetPoint* gateway = nullptr; @@ -86,8 +86,8 @@ private: bool has_links_down() const { return links_down_set; } }; /** @brief Auxiliary method to add links to a route */ - void add_links_to_route(const std::vector& links, Route* route, double* latency, - std::unordered_set& added_links) const; + void add_links_to_route(const std::vector& links, Route* route, double* latency, + std::unordered_set& added_links) const; /** @brief Auxiliary methods to check params received in add_route method */ void check_add_route_param(const NetPoint* src, const NetPoint* dst, const NetPoint* gw_src, const NetPoint* gw_dst, bool symmetrical) const; diff --git a/include/simgrid/kernel/routing/WifiZone.hpp b/include/simgrid/kernel/routing/WifiZone.hpp index 830779a793..e8d221465e 100644 --- a/include/simgrid/kernel/routing/WifiZone.hpp +++ b/include/simgrid/kernel/routing/WifiZone.hpp @@ -19,7 +19,7 @@ namespace routing { * That link is used for all communications within the zone. */ class XBT_PRIVATE WifiZone : public RoutedZone { - resource::LinkImpl* wifi_link_ = nullptr; // Representing the air media (there is no such thing in NS-3) + resource::StandardLinkImpl* wifi_link_ = nullptr; // Representing the air media (there is no such thing in NS-3) NetPoint* access_point_ = nullptr; // Zone's gateway to the external world void do_seal() override; diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index db838013cc..e51f4780de 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -98,7 +98,7 @@ protected: friend kernel::routing::NetPoint; friend kernel::routing::NetZoneImpl; friend kernel::resource::HostImpl; - friend kernel::resource::LinkImpl; + friend kernel::resource::StandardLinkImpl; void host_register(const std::string& name, Host* host); void host_unregister(const std::string& name); void link_register(const std::string& name, const Link* link); diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index b59ec85d10..74d0f43a5a 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -222,7 +222,7 @@ public: VirtualMachine* create_vm(const std::string& name, int core_amount, size_t ramsize); void route_to(const Host* dest, std::vector& links, double* latency) const; - void route_to(const Host* dest, std::vector& links, double* latency) const; + void route_to(const Host* dest, std::vector& links, double* latency) const; /** * @brief Seal this host diff --git a/include/simgrid/s4u/Link.hpp b/include/simgrid/s4u/Link.hpp index c473b1063e..5924c0f893 100644 --- a/include/simgrid/s4u/Link.hpp +++ b/include/simgrid/s4u/Link.hpp @@ -31,15 +31,15 @@ namespace s4u { */ class XBT_PUBLIC Link : public xbt::Extendable { #ifndef DOXYGEN - friend kernel::resource::LinkImpl; + friend kernel::resource::StandardLinkImpl; #endif protected: // Links are created from the NetZone, and destroyed by their private implementation when the simulation ends - explicit Link(kernel::resource::LinkImplIntf* pimpl) : pimpl_(pimpl) {} + explicit Link(kernel::resource::LinkImpl* pimpl) : pimpl_(pimpl) {} virtual ~Link() = default; // The implementation that never changes - kernel::resource::LinkImplIntf* const pimpl_; + kernel::resource::LinkImpl* const pimpl_; #ifndef DOXYGEN friend kernel::resource::NetworkAction; // signal comm_state_changed #endif @@ -47,7 +47,7 @@ protected: public: enum class SharingPolicy { NONLINEAR = 4, WIFI = 3, SPLITDUPLEX = 2, SHARED = 1, FATPIPE = 0 }; - kernel::resource::LinkImpl* get_impl() const; + kernel::resource::StandardLinkImpl* get_impl() const; /** @brief Retrieve a link from its name */ static Link* by_name(const std::string& name); @@ -177,7 +177,7 @@ public: */ class XBT_PUBLIC SplitDuplexLink : public Link { public: - explicit SplitDuplexLink(kernel::resource::LinkImplIntf* pimpl) : Link(pimpl) {} + explicit SplitDuplexLink(kernel::resource::LinkImpl* pimpl) : Link(pimpl) {} /** @brief Get the link direction up*/ Link* get_link_up() const; /** @brief Get the link direction down */ diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index 4d37853bb7..004f46c2cd 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -89,20 +89,18 @@ public: kernel::routing::NetPoint* gw_dst, const std::vector& link_list, bool symmetrical = true); #ifndef DOXYGEN - XBT_ATTRIB_DEPRECATED_v332("Please use add_route() method which uses s4u::LinkInRoute instead of " - "LinkImpl") void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, - kernel::routing::NetPoint* gw_src, - kernel::routing::NetPoint* gw_dst, - const std::vector& link_list, - bool symmetrical); - - XBT_ATTRIB_DEPRECATED_v332("Please use add_bypass_route() method which uses s4u::LinkInRoute instead of " - "LinkImpl") 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*/); + XBT_ATTRIB_DEPRECATED_v332( + "Please use add_route() method which uses s4u::LinkInRoute instead of " + "LinkImpl") void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, + kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, + const std::vector& link_list, bool symmetrical); + + XBT_ATTRIB_DEPRECATED_v332( + "Please use add_bypass_route() method which uses s4u::LinkInRoute instead of " + "LinkImpl") 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*/); #endif void add_bypass_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, @@ -113,7 +111,7 @@ public: /*** Called on each newly created regular route (not on bypass routes) */ static xbt::signal const& link_list)> + std::vector const& link_list)> on_route_creation; // XBT_ATTRIB_DEPRECATED_v332 : should not be used by users, used by ns3.. if necessary, // signal shouldn't use LinkImpl* @@ -186,7 +184,8 @@ public: private: #ifndef DOXYGEN /** @brief XBT_ATTRIB_DEPRECATED_v332 Auxiliary function to convert types */ - static std::vector convert_to_linkInRoute(const std::vector& link_list); + static std::vector + convert_to_linkInRoute(const std::vector& link_list); #endif }; diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index 2cc7d1f9a0..6c35bea77d 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -8,7 +8,7 @@ #include #include "src/instr/instr_private.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include #include @@ -301,7 +301,7 @@ static void instr_user_srcdst_variable(double time, const char* src, const char* const simgrid::kernel::routing::NetPoint* dst_elm = sg_netpoint_by_name_or_null(dst); xbt_assert(dst_elm, "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, parent_type, value, what, nullptr, &user_link_variables); diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index c47e87966c..619cafe07a 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -15,7 +15,7 @@ #include "src/instr/instr_private.hpp" #include "src/kernel/resource/CpuImpl.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "src/surf/surf_interface.hpp" #include @@ -344,7 +344,7 @@ static void on_action_state_change(kernel::resource::Action const& action, resource_set_utilization("HOST", "speed_used", cpu->get_cname(), action.get_category(), value, action.get_last_update(), simgrid_get_clock() - action.get_last_update()); - const kernel::resource::LinkImpl* link = dynamic_cast(resource); + const kernel::resource::StandardLinkImpl* link = dynamic_cast(resource); if (link != nullptr) resource_set_utilization("LINK", "bandwidth_used", link->get_cname(), action.get_category(), value, diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index c9f6f41678..be693d6f5e 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -12,13 +12,13 @@ #include "mc/mc.h" #include "src/kernel/EngineImpl.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "src/kernel/resource/profile/Profile.hpp" #include "src/mc/mc_record.hpp" #include "src/mc/mc_replay.hpp" #include "src/smpi/include/smpi_actor.hpp" -#include "src/surf/network_interface.hpp" #include "src/surf/xml/platf.hpp" -#include "xbt/xbt_modinter.h" /* whether initialization was already done */ +#include "xbt/xbt_modinter.h" /* whether initialization was already done */ #include #ifndef _WIN32 diff --git a/src/kernel/EngineImpl.hpp b/src/kernel/EngineImpl.hpp index 2fcab66f61..458bcbad02 100644 --- a/src/kernel/EngineImpl.hpp +++ b/src/kernel/EngineImpl.hpp @@ -19,7 +19,7 @@ #include "src/kernel/activity/SleepImpl.hpp" #include "src/kernel/activity/SynchroRaw.hpp" #include "src/kernel/actor/ActorImpl.hpp" -#include "src/surf/SplitDuplexLinkImpl.hpp" +#include "src/kernel/resource/SplitDuplexLinkImpl.hpp" #include #include @@ -37,7 +37,7 @@ xbt_dynar_t get_dead_actors_addr(); class EngineImpl { std::map> hosts_; - std::map> links_; + std::map> links_; /* save split-duplex links separately, keep links_ with only LinkImpl* seen by the user * members of a split-duplex are saved in the links_ */ std::map, std::less<>> split_duplex_links_; diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index be78f3b225..d94b872dee 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -12,8 +12,9 @@ #include "src/kernel/activity/MailboxImpl.hpp" #include "src/kernel/context/Context.hpp" #include "src/kernel/resource/CpuImpl.hpp" +#include "src/kernel/resource/LinkImpl.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "src/mc/mc_replay.hpp" -#include "src/surf/network_interface.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related synchronization"); diff --git a/src/surf/network_interface.cpp b/src/kernel/resource/LinkImpl.cpp similarity index 79% rename from src/surf/network_interface.cpp rename to src/kernel/resource/LinkImpl.cpp index c18d8d759b..c0312c2fb6 100644 --- a/src/surf/network_interface.cpp +++ b/src/kernel/resource/LinkImpl.cpp @@ -6,8 +6,9 @@ #include #include "simgrid/sg_config.hpp" +#include "src/kernel/resource/LinkImpl.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "src/kernel/resource/profile/Profile.hpp" -#include "src/surf/network_interface.hpp" #include "src/surf/surf_interface.hpp" #include @@ -68,41 +69,43 @@ void NetworkAction::set_state(Action::State state) } /** @brief returns a list of all Links that this action is using */ -std::list NetworkAction::get_links() const +std::list NetworkAction::get_links() const { - std::list retlist; + std::list retlist; int llen = get_variable()->get_number_of_constraint(); for (int i = 0; i < llen; i++) { /* Beware of composite actions: ptasks put links and cpus together */ - if (auto* link = dynamic_cast(get_variable()->get_constraint(i)->get_id())) + if (auto* link = dynamic_cast(get_variable()->get_constraint(i)->get_id())) retlist.push_back(link); } return retlist; } -static void add_latency(const std::vector& links, double* latency) +static void add_latency(const std::vector& links, double* latency) { if (latency) *latency = std::accumulate(begin(links), end(links), *latency, [](double lat, const auto* link) { return lat + link->get_latency(); }); } -void add_link_latency(std::vector& result, LinkImpl* link, double* latency) +void add_link_latency(std::vector& result, StandardLinkImpl* link, double* latency) { result.push_back(link); if (latency) *latency += link->get_latency(); } -void add_link_latency(std::vector& result, const std::vector& links, double* latency) +void add_link_latency(std::vector& result, const std::vector& links, + double* latency) { result.insert(result.end(), begin(links), end(links)); add_latency(links, latency); } -void insert_link_latency(std::vector& result, const std::vector& links, double* latency) +void insert_link_latency(std::vector& result, const std::vector& links, + double* latency) { result.insert(result.begin(), rbegin(links), rend(links)); add_latency(links, latency); diff --git a/src/surf/network_interface.hpp b/src/kernel/resource/LinkImpl.hpp similarity index 68% rename from src/surf/network_interface.hpp rename to src/kernel/resource/LinkImpl.hpp index 039af7fbd5..5022907c07 100644 --- a/src/surf/network_interface.hpp +++ b/src/kernel/resource/LinkImpl.hpp @@ -3,15 +3,14 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef SURF_NETWORK_INTERFACE_HPP_ -#define SURF_NETWORK_INTERFACE_HPP_ +#ifndef SIMGRID_KERNEL_RESOURCE_LINKIMPL_HPP +#define SIMGRID_KERNEL_RESOURCE_LINKIMPL_HPP #include "simgrid/kernel/resource/Model.hpp" #include "simgrid/kernel/resource/NetworkModelIntf.hpp" #include "simgrid/s4u/Link.hpp" #include "src/kernel/lmm/maxmin.hpp" #include "src/kernel/resource/Resource.hpp" -#include "src/surf/LinkImpl.hpp" #include "xbt/PropertyHolder.hpp" #include @@ -20,10 +19,12 @@ /*********** * Classes * ***********/ +class StandardLinkImpl; namespace simgrid { namespace kernel { namespace resource { + /********* * Model * *********/ @@ -48,9 +49,9 @@ public: * @param name The name of the Link * @param bandwidths The vector of bandwidths of the Link in bytes per second */ - virtual LinkImpl* create_link(const std::string& name, const std::vector& bandwidths) = 0; + virtual StandardLinkImpl* create_link(const std::string& name, const std::vector& bandwidths) = 0; - virtual LinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidths) = 0; + virtual StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidths) = 0; /** * @brief Create a communication between two hosts. @@ -91,7 +92,37 @@ public: void set_lat_factor_cb(const std::function& cb) override { THROW_UNIMPLEMENTED; } void set_bw_factor_cb(const std::function& cb) override { THROW_UNIMPLEMENTED; } - LinkImpl* loopback_ = nullptr; + StandardLinkImpl* loopback_ = nullptr; +}; + +/************ + * Resource * + ************/ +class LinkImpl : public Resource_T, public xbt::PropertyHolder { +public: + using Resource_T::Resource_T; + /** @brief Get the bandwidth in bytes per second of current Link */ + virtual double get_bandwidth() const = 0; + /** @brief Update the bandwidth in bytes per second of current Link */ + virtual void set_bandwidth(double value) = 0; + + /** @brief Get the latency in seconds of current Link */ + virtual double get_latency() const = 0; + /** @brief Update the latency in seconds of current Link */ + virtual void set_latency(double value) = 0; + + /** @brief The sharing policy */ + virtual void set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) = 0; + virtual s4u::Link::SharingPolicy get_sharing_policy() const = 0; + + /* setup the profile file with bandwidth events (peak speed changes due to external load). + * Profile must contain percentages (value between 0 and 1). */ + virtual void set_bandwidth_profile(kernel::profile::Profile* profile) = 0; + /* setup the profile file with latency events (peak latency changes due to external load). + * Profile must contain absolute values */ + virtual void set_latency_profile(kernel::profile::Profile* profile) = 0; + /** @brief Set the concurrency limit for this link */ + virtual void set_concurrency_limit(int limit) const = 0; }; /********** @@ -129,7 +160,7 @@ public: : Action(model, cost, failed, var), src_(src), dst_(dst){}; void set_state(Action::State state) override; - virtual std::list get_links() const; + virtual std::list get_links() const; double latency_ = 0.; // Delay before the action starts double lat_current_ = 0.; // Used to compute the communication RTT, and accordingly limit the communication rate @@ -142,12 +173,14 @@ public: /* Insert link(s) at the end of vector `result' (at the beginning, and reversed, for insert_link_latency()), and add * link->get_latency() to *latency when latency is not null */ -void add_link_latency(std::vector& result, LinkImpl* link, double* latency); -void add_link_latency(std::vector& result, const std::vector& links, double* latency); -void insert_link_latency(std::vector& result, const std::vector& links, double* latency); +void add_link_latency(std::vector& result, StandardLinkImpl* link, double* latency); +void add_link_latency(std::vector& result, const std::vector& links, + double* latency); +void insert_link_latency(std::vector& result, const std::vector& links, + double* latency); } // namespace resource } // namespace kernel } // namespace simgrid -#endif /* SURF_NETWORK_INTERFACE_HPP_ */ +#endif /* SIMGRID_KERNEL_RESOURCE_LINKIMPL_HPP */ diff --git a/src/surf/SplitDuplexLinkImpl.cpp b/src/kernel/resource/SplitDuplexLinkImpl.cpp similarity index 90% rename from src/surf/SplitDuplexLinkImpl.cpp rename to src/kernel/resource/SplitDuplexLinkImpl.cpp index 48cd097a7c..0b02ce4fba 100644 --- a/src/surf/SplitDuplexLinkImpl.cpp +++ b/src/kernel/resource/SplitDuplexLinkImpl.cpp @@ -3,7 +3,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "src/surf/SplitDuplexLinkImpl.hpp" +#include "src/kernel/resource/SplitDuplexLinkImpl.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network); @@ -15,8 +15,9 @@ namespace simgrid { namespace kernel { namespace resource { -SplitDuplexLinkImpl::SplitDuplexLinkImpl(const std::string& name, LinkImpl* link_up, LinkImpl* link_down) - : LinkImplIntf(name), piface_(this), link_up_(link_up), link_down_(link_down) +SplitDuplexLinkImpl::SplitDuplexLinkImpl(const std::string& name, StandardLinkImpl* link_up, + StandardLinkImpl* link_down) + : LinkImpl(name), piface_(this), link_up_(link_up), link_down_(link_down) { } diff --git a/src/surf/SplitDuplexLinkImpl.hpp b/src/kernel/resource/SplitDuplexLinkImpl.hpp similarity index 85% rename from src/surf/SplitDuplexLinkImpl.hpp rename to src/kernel/resource/SplitDuplexLinkImpl.hpp index 231e130028..244c08a554 100644 --- a/src/surf/SplitDuplexLinkImpl.hpp +++ b/src/kernel/resource/SplitDuplexLinkImpl.hpp @@ -6,16 +6,13 @@ #ifndef SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP #define SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP -#include "src/surf/LinkImpl.hpp" -#include "src/surf/LinkImplIntf.hpp" - -/*********** - * Classes * - ***********/ +#include "src/kernel/resource/LinkImpl.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" namespace simgrid { namespace kernel { namespace resource { + /************ * Resource * ************/ @@ -23,17 +20,17 @@ namespace resource { * @brief SURF network link interface class * @details A Link represents the link between two [hosts](@ref HostImpl) */ -class SplitDuplexLinkImpl : public LinkImplIntf { +class SplitDuplexLinkImpl : public LinkImpl { s4u::SplitDuplexLink piface_; - LinkImpl* link_up_; - LinkImpl* link_down_; + StandardLinkImpl* link_up_; + StandardLinkImpl* link_down_; protected: - SplitDuplexLinkImpl(const LinkImpl&) = delete; - SplitDuplexLinkImpl& operator=(const LinkImpl&) = delete; + SplitDuplexLinkImpl(const StandardLinkImpl&) = delete; + SplitDuplexLinkImpl& operator=(const StandardLinkImpl&) = delete; public: - SplitDuplexLinkImpl(const std::string& name, LinkImpl* link_up, LinkImpl* link_down); + SplitDuplexLinkImpl(const std::string& name, StandardLinkImpl* link_up, StandardLinkImpl* link_down); /** @brief Public interface */ const s4u::SplitDuplexLink* get_iface() const { return &piface_; } s4u::SplitDuplexLink* get_iface() { return &piface_; } diff --git a/src/surf/SplitDuplexLinkImpl_test.cpp b/src/kernel/resource/SplitDuplexLinkImpl_test.cpp similarity index 96% rename from src/surf/SplitDuplexLinkImpl_test.cpp rename to src/kernel/resource/SplitDuplexLinkImpl_test.cpp index b36ea8aad2..629bbb1f2e 100644 --- a/src/surf/SplitDuplexLinkImpl_test.cpp +++ b/src/kernel/resource/SplitDuplexLinkImpl_test.cpp @@ -5,9 +5,10 @@ #include "catch.hpp" -#include "simgrid/s4u/Engine.hpp" -#include "simgrid/s4u/Link.hpp" -#include "src/surf/SplitDuplexLinkImpl.hpp" +#include +#include + +#include "src/kernel/resource/SplitDuplexLinkImpl.hpp" TEST_CASE("SplitDuplexLink: create", "") { diff --git a/src/surf/LinkImpl.cpp b/src/kernel/resource/StandardLinkImpl.cpp similarity index 82% rename from src/surf/LinkImpl.cpp rename to src/kernel/resource/StandardLinkImpl.cpp index a5a34ae20e..4ecfa60efd 100644 --- a/src/surf/LinkImpl.cpp +++ b/src/kernel/resource/StandardLinkImpl.cpp @@ -6,8 +6,7 @@ #include #include "src/kernel/EngineImpl.hpp" -#include "src/surf/LinkImpl.hpp" - +#include "src/kernel/resource/StandardLinkImpl.hpp" #include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network); @@ -20,7 +19,7 @@ namespace simgrid { namespace kernel { namespace resource { -LinkImpl::LinkImpl(const std::string& name) : LinkImplIntf(name), piface_(this) +StandardLinkImpl::StandardLinkImpl(const std::string& name) : LinkImpl(name), piface_(this) { if (name != "__loopback__") xbt_assert(not s4u::Link::by_name_or_null(name), "Link '%s' declared several times in the platform.", name.c_str()); @@ -33,7 +32,7 @@ LinkImpl::LinkImpl(const std::string& name) : LinkImplIntf(name), piface_(this) * * Don't delete directly a Link, call l->destroy() instead. */ -void LinkImpl::destroy() +void StandardLinkImpl::destroy() { s4u::Link::on_destruction(piface_); s4u::Engine::get_instance()->link_unregister(get_name()); @@ -52,13 +51,13 @@ constexpr kernel::lmm::Constraint::SharingPolicy to_maxmin_policy(s4u::Link::Sha } } -void LinkImpl::set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) +void StandardLinkImpl::set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) { get_constraint()->set_sharing_policy(to_maxmin_policy(policy), cb); sharing_policy_ = policy; } -void LinkImpl::latency_check(double latency) const +void StandardLinkImpl::latency_check(double latency) const { static double last_warned_latency = sg_surf_precision; if (latency != 0.0 && latency < last_warned_latency) { @@ -69,7 +68,7 @@ void LinkImpl::latency_check(double latency) const } } -void LinkImpl::turn_on() +void StandardLinkImpl::turn_on() { if (not is_on()) { Resource::turn_on(); @@ -77,7 +76,7 @@ void LinkImpl::turn_on() } } -void LinkImpl::turn_off() +void StandardLinkImpl::turn_off() { if (is_on()) { Resource::turn_off(); @@ -95,7 +94,7 @@ void LinkImpl::turn_off() } } -void LinkImpl::seal() +void StandardLinkImpl::seal() { if (is_sealed()) return; @@ -104,12 +103,12 @@ void LinkImpl::seal() Resource::seal(); } -void LinkImpl::on_bandwidth_change() const +void StandardLinkImpl::on_bandwidth_change() const { s4u::Link::on_bandwidth_change(piface_); } -void LinkImpl::set_bandwidth_profile(profile::Profile* profile) +void StandardLinkImpl::set_bandwidth_profile(profile::Profile* profile) { if (profile) { xbt_assert(bandwidth_.event == nullptr, "Cannot set a second bandwidth profile to Link %s", get_cname()); @@ -117,7 +116,7 @@ void LinkImpl::set_bandwidth_profile(profile::Profile* profile) } } -void LinkImpl::set_latency_profile(profile::Profile* profile) +void StandardLinkImpl::set_latency_profile(profile::Profile* profile) { if (profile) { xbt_assert(latency_.event == nullptr, "Cannot set a second latency profile to Link %s", get_cname()); @@ -125,7 +124,7 @@ void LinkImpl::set_latency_profile(profile::Profile* profile) } } -void LinkImpl::set_concurrency_limit(int limit) const +void StandardLinkImpl::set_concurrency_limit(int limit) const { if (limit != -1) { get_constraint()->reset_concurrency_maximum(); diff --git a/src/surf/LinkImpl.hpp b/src/kernel/resource/StandardLinkImpl.hpp similarity index 76% rename from src/surf/LinkImpl.hpp rename to src/kernel/resource/StandardLinkImpl.hpp index e49c884d50..96dc680dba 100644 --- a/src/surf/LinkImpl.hpp +++ b/src/kernel/resource/StandardLinkImpl.hpp @@ -3,10 +3,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef SIMGRID_KERNEL_RESOURCE_LINKIMPL_HPP -#define SIMGRID_KERNEL_RESOURCE_LINKIMPL_HPP +#ifndef SIMGRID_KERNEL_RESOURCE_STANDARDLINKIMPL_HPP +#define SIMGRID_KERNEL_RESOURCE_STANDARDLINKIMPL_HPP -#include "src/surf/LinkImplIntf.hpp" +#include "src/kernel/resource/LinkImpl.hpp" /*********** * Classes * @@ -18,19 +18,15 @@ namespace resource { /************ * Resource * ************/ -/** @ingroup SURF_network_interface - * @brief SURF network link interface class - * @details A Link represents the link between two [hosts](@ref simgrid::kernel::resource::HostImpl) - */ -class LinkImpl : public LinkImplIntf { +class StandardLinkImpl : public LinkImpl { s4u::Link piface_; s4u::Link::SharingPolicy sharing_policy_ = s4u::Link::SharingPolicy::SHARED; protected: - explicit LinkImpl(const std::string& name); - LinkImpl(const LinkImpl&) = delete; - LinkImpl& operator=(const LinkImpl&) = delete; - ~LinkImpl() override = default; // Use destroy() instead of this destructor. + explicit StandardLinkImpl(const std::string& name); + StandardLinkImpl(const StandardLinkImpl&) = delete; + StandardLinkImpl& operator=(const StandardLinkImpl&) = delete; + ~StandardLinkImpl() override = default; // Use destroy() instead of this destructor. Metric latency_ = {0.0, 1, nullptr}; Metric bandwidth_ = {1.0, 1, nullptr}; @@ -75,4 +71,4 @@ public: } // namespace kernel } // namespace simgrid -#endif /* SIMGRID_KERNEL_RESOURCE_LINKIMPL_HPP */ +#endif /* SIMGRID_KERNEL_RESOURCE_STANDARDLINKIMPL_HPP */ diff --git a/src/surf/network_wifi.cpp b/src/kernel/resource/WifiLinkImpl.cpp similarity index 69% rename from src/surf/network_wifi.cpp rename to src/kernel/resource/WifiLinkImpl.cpp index 9f0707baf5..39309a08dd 100644 --- a/src/surf/network_wifi.cpp +++ b/src/kernel/resource/WifiLinkImpl.cpp @@ -3,8 +3,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "network_wifi.hpp" -#include "simgrid/s4u/Host.hpp" +#include + +#include "src/kernel/resource/WifiLinkImpl.hpp" #include "src/surf/surf_interface.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network); @@ -17,15 +18,15 @@ namespace resource { * Resource * ************/ -NetworkWifiLink::NetworkWifiLink(const std::string& name, const std::vector& bandwidths, lmm::System* system) - : LinkImpl(name) +WifiLinkImpl::WifiLinkImpl(const std::string& name, const std::vector& bandwidths, lmm::System* system) + : StandardLinkImpl(name) { this->set_constraint(system->constraint_new(this, 1)); for (auto bandwidth : bandwidths) bandwidths_.push_back({bandwidth, 1.0, nullptr}); } -void NetworkWifiLink::set_host_rate(const s4u::Host* host, int rate_level) +void WifiLinkImpl::set_host_rate(const s4u::Host* host, int rate_level) { auto insert_done = host_rates_.insert(std::make_pair(host->get_name(), rate_level)); if (not insert_done.second) @@ -35,7 +36,7 @@ void NetworkWifiLink::set_host_rate(const s4u::Host* host, int rate_level) refresh_decay_bandwidths(); } -double NetworkWifiLink::get_host_rate(const s4u::Host* host) const +double WifiLinkImpl::get_host_rate(const s4u::Host* host) const { auto host_rates_it = host_rates_.find(host->get_name()); @@ -54,44 +55,46 @@ double NetworkWifiLink::get_host_rate(const s4u::Host* host) const return rate.peak * rate.scale; } -s4u::Link::SharingPolicy NetworkWifiLink::get_sharing_policy() const +s4u::Link::SharingPolicy WifiLinkImpl::get_sharing_policy() const { return s4u::Link::SharingPolicy::WIFI; } -int NetworkWifiLink::get_host_count() const +int WifiLinkImpl::get_host_count() const { return static_cast(host_rates_.size()); } -void NetworkWifiLink::refresh_decay_bandwidths(){ +void WifiLinkImpl::refresh_decay_bandwidths() +{ // Compute number of STAtion on the Access Point int nSTA = get_host_count(); std::vector new_bandwidths; for (auto const& bandwidth : bandwidths_) { // Instantiate decay model relatively to the actual bandwidth - double max_bw=bandwidth.peak; - double min_bw=bandwidth.peak-(wifi_max_rate_-wifi_min_rate_); - double model_rate=bandwidth.peak-(wifi_max_rate_-model_rate_); + double max_bw = bandwidth.peak; + double min_bw = bandwidth.peak - (wifi_max_rate_ - wifi_min_rate_); + double model_rate = bandwidth.peak - (wifi_max_rate_ - model_rate_); xbt_assert(min_bw > 0, "Your WIFI link is using bandwidth(s) which is too low for the decay model."); - double N0=max_bw-min_bw; - double lambda=(-log(model_rate-min_bw)+log(N0))/model_n_; + double N0 = max_bw - min_bw; + double lambda = (-log(model_rate - min_bw) + log(N0)) / model_n_; // Since decay model start at 0 we should use (nSTA-1) - double new_peak=N0*exp(-lambda*(nSTA-1))+min_bw; + double new_peak = N0 * exp(-lambda * (nSTA - 1)) + min_bw; new_bandwidths.push_back({new_peak, 1.0, nullptr}); } - decay_bandwidths_=new_bandwidths; + decay_bandwidths_ = new_bandwidths; } -bool NetworkWifiLink::toggle_decay_model(){ +bool WifiLinkImpl::toggle_decay_model() +{ use_decay_model_ = not use_decay_model_; return use_decay_model_; } -void NetworkWifiLink::set_latency(double value) +void WifiLinkImpl::set_latency(double value) { xbt_assert(value == 0, "Latency cannot be set for WiFi Links."); } diff --git a/src/surf/network_wifi.hpp b/src/kernel/resource/WifiLinkImpl.hpp similarity index 67% rename from src/surf/network_wifi.hpp rename to src/kernel/resource/WifiLinkImpl.hpp index 71850b588e..63e449b1d8 100644 --- a/src/surf/network_wifi.hpp +++ b/src/kernel/resource/WifiLinkImpl.hpp @@ -8,7 +8,7 @@ #include -#include "network_cm02.hpp" +#include "src/surf/network_cm02.hpp" #include "xbt/string.hpp" /*********** @@ -19,9 +19,9 @@ namespace simgrid { namespace kernel { namespace resource { -class XBT_PRIVATE NetworkWifiAction; +class XBT_PRIVATE WifiLinkAction; -class NetworkWifiLink : public LinkImpl { +class WifiLinkImpl : public StandardLinkImpl { /** @brief Hold every rates association between host and links (host name, rates id) */ std::map host_rates_; @@ -29,20 +29,20 @@ class NetworkWifiLink : public LinkImpl { std::vector bandwidths_; /** @brief Should we use the decay model ? */ - bool use_decay_model_=false; + bool use_decay_model_ = false; /** @brief Wifi maximal bit rate according to the ns-3 802.11n standard */ const double wifi_max_rate_ = 54 * 1e6 / 8; /** @brief minimum bit rate observed with ns3 during our calibration experiments */ const double wifi_min_rate_ = 41.70837 * 1e6 / 8; /** @brief Amount of stations used in the reference point to rescale SimGrid predictions to fit ns-3 ones */ - const int model_n_=5; + const int model_n_ = 5; /** @brief Bit rate observed on ns3 at the reference point used for rescaling */ - const double model_rate_=42.61438*1e6 / 8; + const double model_rate_ = 42.61438 * 1e6 / 8; /** @brief The bandwidth to use for each SNR level, corrected with the decay rescale mechanism */ std::vector decay_bandwidths_; public: - NetworkWifiLink(const std::string& name, const std::vector& bandwidths, lmm::System* system); + WifiLinkImpl(const std::string& name, const std::vector& bandwidths, lmm::System* system); void set_host_rate(const s4u::Host* host, int rate_level); /** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */ @@ -57,24 +57,23 @@ public: int get_host_count() const; }; -class NetworkWifiAction : public NetworkCm02Action { - NetworkWifiLink* src_wifi_link_; - NetworkWifiLink* dst_wifi_link_; +class WifiLinkAction : public NetworkCm02Action { + WifiLinkImpl* src_wifi_link_; + WifiLinkImpl* dst_wifi_link_; public: - NetworkWifiAction() = delete; - NetworkWifiAction(Model* model, s4u::Host& src, s4u::Host& dst, double cost, bool failed, - NetworkWifiLink* src_wifi_link, NetworkWifiLink* dst_wifi_link) - : NetworkCm02Action(model, src, dst, cost, failed) - , src_wifi_link_(src_wifi_link) - , dst_wifi_link_(dst_wifi_link) - {} - - NetworkWifiLink* get_src_link() const { return src_wifi_link_; } - NetworkWifiLink* get_dst_link() const { return dst_wifi_link_; } + WifiLinkAction() = delete; + WifiLinkAction(Model* model, s4u::Host& src, s4u::Host& dst, double cost, bool failed, WifiLinkImpl* src_wifi_link, + WifiLinkImpl* dst_wifi_link) + : NetworkCm02Action(model, src, dst, cost, failed), src_wifi_link_(src_wifi_link), dst_wifi_link_(dst_wifi_link) + { + } + + WifiLinkImpl* get_src_link() const { return src_wifi_link_; } + WifiLinkImpl* get_dst_link() const { return dst_wifi_link_; } }; } // namespace resource } // namespace kernel } // namespace simgrid -#endif /* SURF_NETWORK_WIFI_HPP_ */ +#endif diff --git a/src/kernel/routing/ClusterZone.cpp b/src/kernel/routing/ClusterZone.cpp index 84052939e9..9b3c0d32cf 100644 --- a/src/kernel/routing/ClusterZone.cpp +++ b/src/kernel/routing/ClusterZone.cpp @@ -6,7 +6,7 @@ #include "simgrid/kernel/routing/ClusterZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/kernel/routing/RoutedZone.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"); @@ -40,7 +40,8 @@ void ClusterBase::set_link_characteristics(double bw, double lat, s4u::Link::Sha link_lat_ = lat; } -void ClusterBase::add_private_link_at(unsigned long position, std::pair link) +void ClusterBase::add_private_link_at(unsigned long position, + std::pair link) { private_links_.insert({position, link}); } diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index 5381c38f84..65580e9bf8 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -7,7 +7,7 @@ #include #include -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include #include @@ -184,7 +184,7 @@ void DijkstraZone::get_local_route(const NetPoint* src, const NetPoint* dst, Rou if (get_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; const NetPoint* gw_dst_net_elm = nullptr; const NetPoint* prev_gw_src_net_elm = nullptr; diff --git a/src/kernel/routing/DijkstraZone_test.cpp b/src/kernel/routing/DijkstraZone_test.cpp index 6fbbd30f5a..eb64fb0464 100644 --- a/src/kernel/routing/DijkstraZone_test.cpp +++ b/src/kernel/routing/DijkstraZone_test.cpp @@ -10,7 +10,7 @@ #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/NetZone.hpp" -#include "src/surf/network_interface.hpp" //LinkImpl +#include "src/kernel/resource/LinkImpl.hpp" TEST_CASE("kernel::routing::DijkstraZone: Creating Zone", "") { diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index 6511c5cb96..49b5a7454e 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -5,7 +5,7 @@ #include "simgrid/kernel/routing/DragonflyZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include #include @@ -144,8 +144,8 @@ void DragonflyZone::generate_routers(const s4u::ClusterCallbacks& set_callbacks) unsigned long id = 2UL * num_groups_ * num_chassis_per_group_ * num_blades_per_chassis_ * num_nodes_per_blade_; /* get limiter for this router */ auto get_limiter = [this, &id, &set_callbacks](unsigned int i, unsigned int j, - unsigned int k) -> resource::LinkImpl* { - kernel::resource::LinkImpl* limiter = nullptr; + unsigned int k) -> resource::StandardLinkImpl* { + kernel::resource::StandardLinkImpl* limiter = nullptr; if (set_callbacks.limiter) { id--; const auto* s4u_link = @@ -167,8 +167,8 @@ void DragonflyZone::generate_routers(const s4u::ClusterCallbacks& set_callbacks) } } -void DragonflyZone::generate_link(const std::string& id, int numlinks, resource::LinkImpl** linkup, - resource::LinkImpl** linkdown) +void DragonflyZone::generate_link(const std::string& id, int numlinks, resource::StandardLinkImpl** linkup, + resource::StandardLinkImpl** linkdown) { XBT_DEBUG("Generating link %s", id.c_str()); *linkup = nullptr; @@ -189,8 +189,8 @@ void DragonflyZone::generate_link(const std::string& id, int numlinks, resource: void DragonflyZone::generate_links() { static int uniqueId = 0; - resource::LinkImpl* linkup; - resource::LinkImpl* linkdown; + resource::StandardLinkImpl* linkup; + resource::StandardLinkImpl* linkdown; unsigned int numRouters = num_groups_ * num_chassis_per_group_ * num_blades_per_chassis_; @@ -279,7 +279,7 @@ void DragonflyZone::get_local_route(const NetPoint* src, const NetPoint* dst, Ro dst->id()); if ((src->id() == dst->id()) && has_loopback()) { - resource::LinkImpl* uplink = get_uplink_from(node_pos(src->id())); + resource::StandardLinkImpl* uplink = get_uplink_from(node_pos(src->id())); add_link_latency(route->link_list_, uplink, latency); return; diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index 04cc4bbede..a22566ac7a 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -6,7 +6,7 @@ #include #include -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "src/surf/xml/platf.hpp" // surf_parse_error() and surf_parse_assert() #include @@ -249,8 +249,8 @@ void FatTreeZone::generate_switches(const s4u::ClusterCallbacks& set_callbacks) } /* get limiter for this router */ - auto get_limiter = [this, &set_callbacks](unsigned long i, unsigned long j, long id) -> resource::LinkImpl* { - kernel::resource::LinkImpl* limiter = nullptr; + auto get_limiter = [this, &set_callbacks](unsigned long i, unsigned long j, long id) -> resource::StandardLinkImpl* { + kernel::resource::StandardLinkImpl* limiter = nullptr; if (set_callbacks.limiter) { const auto* s4u_link = set_callbacks.limiter(get_iface(), {i + 1, j}, id); if (s4u_link) { @@ -333,7 +333,7 @@ int FatTreeZone::get_level_position(const unsigned int level) return tempPosition; } -void FatTreeZone::add_processing_node(int id, resource::LinkImpl* limiter, resource::LinkImpl* loopback) +void FatTreeZone::add_processing_node(int id, resource::StandardLinkImpl* limiter, resource::StandardLinkImpl* loopback) { using std::make_pair; static int position = 0; diff --git a/src/kernel/routing/FloydZone.cpp b/src/kernel/routing/FloydZone.cpp index 7a134c5747..fb7c67d4a7 100644 --- a/src/kernel/routing/FloydZone.cpp +++ b/src/kernel/routing/FloydZone.cpp @@ -7,7 +7,7 @@ #include #include -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include diff --git a/src/kernel/routing/FloydZone_test.cpp b/src/kernel/routing/FloydZone_test.cpp index 0d363282bd..dfadb4decd 100644 --- a/src/kernel/routing/FloydZone_test.cpp +++ b/src/kernel/routing/FloydZone_test.cpp @@ -10,7 +10,7 @@ #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/NetZone.hpp" -#include "src/surf/network_interface.hpp" //LinkImpl +#include "src/kernel/resource/LinkImpl.hpp" TEST_CASE("kernel::routing::FloydZone: Creating Zone", "") { diff --git a/src/kernel/routing/FullZone.cpp b/src/kernel/routing/FullZone.cpp index 132dc8746f..19b5afd21e 100644 --- a/src/kernel/routing/FullZone.cpp +++ b/src/kernel/routing/FullZone.cpp @@ -6,7 +6,7 @@ #include #include -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf"); diff --git a/src/kernel/routing/FullZone_test.cpp b/src/kernel/routing/FullZone_test.cpp index ef1407f023..c7a1f0c84c 100644 --- a/src/kernel/routing/FullZone_test.cpp +++ b/src/kernel/routing/FullZone_test.cpp @@ -10,7 +10,7 @@ #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/NetZone.hpp" -#include "src/surf/network_interface.hpp" //LinkImpl +#include "src/kernel/resource/LinkImpl.hpp" TEST_CASE("kernel::routing::FullZone: Creating Zone", "") { diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 07cfb6e8f6..64f0fab98d 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -12,10 +12,10 @@ #include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/CpuImpl.hpp" #include "src/kernel/resource/DiskImpl.hpp" +#include "src/kernel/resource/SplitDuplexLinkImpl.hpp" #include "src/surf/HostImpl.hpp" -#include "src/surf/SplitDuplexLinkImpl.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_route); namespace simgrid { @@ -67,7 +67,7 @@ static void surf_config_models_setup() xbt::signal const& link_list)> + std::vector const& link_list)> NetZoneImpl::on_route_creation; NetZoneImpl::NetZoneImpl(const std::string& name) : piface_(this), name_(name) @@ -213,10 +213,10 @@ unsigned long NetZoneImpl::add_component(NetPoint* elm) return vertices_.size() - 1; // The rank of the newly created object } -std::vector NetZoneImpl::get_link_list_impl(const std::vector& link_list, - bool backroute) const +std::vector NetZoneImpl::get_link_list_impl(const std::vector& link_list, + bool backroute) const { - std::vector links; + std::vector links; for (const auto& link : link_list) { if (link.get_link()->get_sharing_policy() != s4u::Link::SharingPolicy::SPLITDUPLEX) { @@ -227,7 +227,7 @@ std::vector NetZoneImpl::get_link_list_impl(const std::vect const auto* sd_link = dynamic_cast(link.get_link()); xbt_assert(sd_link, "Add_route: cast to SpliDuplexLink impossible. This should not happen, please contact SimGrid team"); - resource::LinkImpl* link_impl; + resource::StandardLinkImpl* link_impl; switch (link.get_direction()) { case s4u::LinkInRoute::Direction::UP: if (backroute) @@ -396,7 +396,7 @@ static void find_common_ancestors(const NetPoint* src, const NetPoint* dst, /* PRECONDITION: this is the common ancestor of src and dst */ bool NetZoneImpl::get_bypass_route(const NetPoint* src, const NetPoint* dst, - /* OUT */ std::vector& links, double* latency, + /* OUT */ std::vector& links, double* latency, std::unordered_set& netzones) { // If never set a bypass route return nullptr without any further computations @@ -480,15 +480,15 @@ bool NetZoneImpl::get_bypass_route(const NetPoint* src, const NetPoint* dst, } void NetZoneImpl::get_global_route(const NetPoint* src, const NetPoint* dst, - /* OUT */ std::vector& links, double* latency) + /* OUT */ std::vector& links, double* latency) { std::unordered_set netzones; get_global_route_with_netzones(src, dst, links, latency, netzones); } void NetZoneImpl::get_global_route_with_netzones(const NetPoint* src, const NetPoint* dst, - /* OUT */ std::vector& links, double* latency, - std::unordered_set& netzones) + /* OUT */ std::vector& links, + double* latency, std::unordered_set& netzones) { Route route; diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index 7bbddf9848..308c81e52a 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -5,7 +5,7 @@ #include "simgrid/kernel/routing/RoutedZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "xbt/dict.h" #include "xbt/graph.h" #include "xbt/log.h" @@ -111,7 +111,7 @@ void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::map& link_list, bool preserve_order) + const std::vector& link_list, bool preserve_order) { auto* result = new Route(); diff --git a/src/kernel/routing/StarZone.cpp b/src/kernel/routing/StarZone.cpp index c30a6388d2..f3bebd8127 100644 --- a/src/kernel/routing/StarZone.cpp +++ b/src/kernel/routing/StarZone.cpp @@ -6,7 +6,7 @@ #include "simgrid/kernel/routing/StarZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/kernel/routing/RoutedZone.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "xbt/string.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_star, surf, "Routing part of surf"); @@ -16,8 +16,8 @@ namespace kernel { namespace routing { StarZone::StarZone(const std::string& name) : ClusterZone(name) {} -void StarZone::add_links_to_route(const std::vector& links, Route* route, double* latency, - std::unordered_set& added_links) const +void StarZone::add_links_to_route(const std::vector& links, Route* route, double* latency, + std::unordered_set& added_links) const { for (auto* link : links) { /* do not add duplicated links in route->link_list_ */ @@ -34,7 +34,7 @@ void StarZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* const auto& src_route = routes_.at(src->id()); const auto& dst_route = routes_.at(dst->id()); - std::unordered_set added_links; + std::unordered_set added_links; /* loopback */ if (src == dst && src_route.has_loopback()) { add_links_to_route(src_route.loopback, route, latency, added_links); diff --git a/src/kernel/routing/StarZone_test.cpp b/src/kernel/routing/StarZone_test.cpp index afc79b61cf..4a81b27ead 100644 --- a/src/kernel/routing/StarZone_test.cpp +++ b/src/kernel/routing/StarZone_test.cpp @@ -10,7 +10,7 @@ #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/NetZone.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" TEST_CASE("kernel::routing::StarZone: Creating Zone", "[creation]") { diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index ce897b4171..ccc9fdf6dc 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -6,7 +6,7 @@ #include "simgrid/kernel/routing/TorusZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/s4u/Host.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/LinkImpl.hpp" #include #include @@ -86,7 +86,7 @@ void TorusZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* return; if (src->id() == dst->id() && has_loopback()) { - resource::LinkImpl* uplink = get_uplink_from(node_pos(src->id())); + resource::StandardLinkImpl* uplink = get_uplink_from(node_pos(src->id())); add_link_latency(route->link_list_, uplink, lat); return; @@ -162,7 +162,7 @@ void TorusZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route->link_list_.push_back(get_uplink_from(node_pos_with_loopback(current_node))); } - resource::LinkImpl* lnk; + resource::StandardLinkImpl* lnk; if (use_lnk_up) lnk = get_uplink_from(linkOffset); else diff --git a/src/kernel/routing/VivaldiZone.cpp b/src/kernel/routing/VivaldiZone.cpp index c68526d9f7..aa68d48b99 100644 --- a/src/kernel/routing/VivaldiZone.cpp +++ b/src/kernel/routing/VivaldiZone.cpp @@ -8,7 +8,7 @@ #include #include -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include diff --git a/src/kernel/routing/WifiZone.cpp b/src/kernel/routing/WifiZone.cpp index 1e16ca11bc..5fe8489dea 100644 --- a/src/kernel/routing/WifiZone.cpp +++ b/src/kernel/routing/WifiZone.cpp @@ -6,7 +6,7 @@ #include #include -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_wifi, surf, "Routing part of surf"); diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index b0677f6174..c9cf1ac6be 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -13,7 +13,7 @@ #include "src/internal_config.h" // HAVE_SMPI #include "src/kernel/activity/CommImpl.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #if HAVE_SMPI #include "src/smpi/include/smpi_request.hpp" #include "src/smpi/plugins/ampi/ampi.hpp" diff --git a/src/plugins/link_energy_wifi.cpp b/src/plugins/link_energy_wifi.cpp index bee75ade7b..5080f41195 100644 --- a/src/plugins/link_energy_wifi.cpp +++ b/src/plugins/link_energy_wifi.cpp @@ -8,8 +8,8 @@ #include #include "src/kernel/activity/CommImpl.hpp" -#include "src/surf/network_interface.hpp" -#include "src/surf/network_wifi.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" +#include "src/kernel/resource/WifiLinkImpl.hpp" #include #include @@ -27,7 +27,7 @@ namespace plugin { class XBT_PRIVATE LinkEnergyWifi { // associative array keeping size of data already sent for a given flow (required for interleaved actions) - std::map> flowTmp{}; + std::map> flowTmp{}; // WiFi link the plugin instance is attached to s4u::Link* link_{}; @@ -98,7 +98,7 @@ xbt::Extension LinkEnergyWifi::EXTENSION_ID; void LinkEnergyWifi::update_destroy() { - auto const* wifi_link = static_cast(link_->get_impl()); + auto const* wifi_link = static_cast(link_->get_impl()); double duration = simgrid::s4u::Engine::get_clock() - prev_update_; prev_update_ = simgrid::s4u::Engine::get_clock(); @@ -122,7 +122,7 @@ void LinkEnergyWifi::update() if(duration < 1e-6) return; - auto const* wifi_link = static_cast(link_->get_impl()); + auto const* wifi_link = static_cast(link_->get_impl()); const kernel::lmm::Element* elem = nullptr; @@ -137,7 +137,7 @@ void LinkEnergyWifi::update() */ double durUsage = 0; while (const auto* var = wifi_link->get_constraint()->get_variable(&elem)) { - auto* action = static_cast(var->get_id()); + auto* action = static_cast(var->get_id()); XBT_DEBUG("cost: %f action value: %f link rate 1: %f link rate 2: %f", action->get_cost(), action->get_rate(), wifi_link->get_host_rate(&action->get_src()), wifi_link->get_host_rate(&action->get_dst())); diff --git a/src/plugins/link_load.cpp b/src/plugins/link_load.cpp index 69b4397d38..e2e0581530 100644 --- a/src/plugins/link_load.cpp +++ b/src/plugins/link_load.cpp @@ -7,7 +7,7 @@ #include #include "src/kernel/activity/CommImpl.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index be5c558d5e..a2bd5f290c 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -13,6 +13,7 @@ #include #include +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "src/kernel/resource/VirtualMachineImpl.hpp" #include "src/surf/HostImpl.hpp" @@ -160,14 +161,14 @@ size_t Host::get_actor_count() const */ void Host::route_to(const Host* dest, std::vector& links, double* latency) const { - std::vector linkImpls; + std::vector linkImpls; this->route_to(dest, linkImpls, latency); for (auto* l : linkImpls) links.push_back(l->get_iface()); } /** @brief Just like Host::routeTo, but filling an array of link implementations */ -void Host::route_to(const Host* dest, std::vector& links, double* latency) const +void Host::route_to(const Host* dest, std::vector& links, double* latency) const { kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint_, dest->get_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 83919625a3..a949b72b9f 100644 --- a/src/s4u/s4u_Link.cpp +++ b/src/s4u/s4u_Link.cpp @@ -10,9 +10,9 @@ #include #include -#include "src/surf/SplitDuplexLinkImpl.hpp" -#include "src/surf/network_interface.hpp" -#include "src/surf/network_wifi.hpp" +#include "src/kernel/resource/LinkImpl.hpp" +#include "src/kernel/resource/SplitDuplexLinkImpl.hpp" +#include "src/kernel/resource/WifiLinkImpl.hpp" namespace simgrid { @@ -32,9 +32,9 @@ Link* Link::by_name(const std::string& name) return Engine::get_instance()->link_by_name(name); } -kernel::resource::LinkImpl* Link::get_impl() const +kernel::resource::StandardLinkImpl* Link::get_impl() const { - auto* link_impl = dynamic_cast(pimpl_); + auto* link_impl = dynamic_cast(pimpl_); xbt_assert(link_impl != nullptr, "Impossible to get a LinkImpl* from link. %s.", (get_sharing_policy() == SharingPolicy::SPLITDUPLEX ? "For a Split-Duplex link, you should call this method to each UP/DOWN member" @@ -115,7 +115,7 @@ Link::SharingPolicy Link::get_sharing_policy() const void Link::set_host_wifi_rate(const s4u::Host* host, int level) const { - auto* wlink = dynamic_cast(pimpl_); + auto* wlink = dynamic_cast(pimpl_); xbt_assert(wlink != nullptr, "Link %s does not seem to be a wifi link.", get_cname()); wlink->set_host_rate(host, level); } diff --git a/src/s4u/s4u_Netzone.cpp b/src/s4u/s4u_Netzone.cpp index 31df149a4b..4f10cc7987 100644 --- a/src/s4u/s4u_Netzone.cpp +++ b/src/s4u/s4u_Netzone.cpp @@ -12,14 +12,15 @@ #include #include -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/LinkImpl.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" namespace simgrid { namespace s4u { xbt::signal const& link_list)> + std::vector const& link_list)> NetZone::on_route_creation; xbt::signal NetZone::on_creation; xbt::signal NetZone::on_seal; @@ -102,7 +103,8 @@ unsigned long NetZone::add_component(kernel::routing::NetPoint* elm) } // XBT_ATTRIB_DEPRECATED_v332 -std::vector NetZone::convert_to_linkInRoute(const std::vector& link_list) +std::vector +NetZone::convert_to_linkInRoute(const std::vector& link_list) { std::vector links; for (const auto* link : link_list) { @@ -121,7 +123,7 @@ void NetZone::add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoin // XBT_ATTRIB_DEPRECATED_v332 void NetZone::add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, - const std::vector& link_list, bool symmetrical) + const std::vector& link_list, bool symmetrical) { pimpl_->add_route(src, dst, gw_src, gw_dst, convert_to_linkInRoute(link_list), symmetrical); } @@ -129,7 +131,7 @@ void NetZone::add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoin // XBT_ATTRIB_DEPRECATED_v332 void NetZone::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*/) + std::vector& link_list, bool /*symmetrical*/) { pimpl_->add_bypass_route(src, dst, gw_src, gw_dst, convert_to_linkInRoute(link_list)); } diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 0dcc24d81f..99b22da8d2 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -9,7 +9,7 @@ #include "src/kernel/actor/ActorImpl.hpp" #include "src/kernel/resource/CpuImpl.hpp" #include "src/kernel/resource/DiskImpl.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/LinkImpl.hpp" #include #include diff --git a/src/surf/LinkImplIntf.hpp b/src/surf/LinkImplIntf.hpp deleted file mode 100644 index 6845de041b..0000000000 --- a/src/surf/LinkImplIntf.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2004-2021. The SimGrid Team. All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#ifndef SIMGRID_KERNEL_RESOURCE_LINKIMPLINTF_HPP -#define SIMGRID_KERNEL_RESOURCE_LINKIMPLINTF_HPP - -#include "simgrid/s4u/Link.hpp" -#include "src/kernel/resource/Resource.hpp" -#include "xbt/PropertyHolder.hpp" - -/*********** - * Classes * - ***********/ - -namespace simgrid { -namespace kernel { -namespace resource { -/************ - * Resource * - ************/ -/** @ingroup SURF_interface - * @brief SURF network link interface class - * @details A Link represents the link between two [hosts](@ref HostImpl) - */ -class LinkImplIntf : public Resource_T, public xbt::PropertyHolder { -public: - using Resource_T::Resource_T; - /** @brief Get the bandwidth in bytes per second of current Link */ - virtual double get_bandwidth() const = 0; - /** @brief Update the bandwidth in bytes per second of current Link */ - virtual void set_bandwidth(double value) = 0; - - /** @brief Get the latency in seconds of current Link */ - virtual double get_latency() const = 0; - /** @brief Update the latency in seconds of current Link */ - virtual void set_latency(double value) = 0; - - /** @brief The sharing policy */ - virtual void set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) = 0; - virtual s4u::Link::SharingPolicy get_sharing_policy() const = 0; - - /* setup the profile file with bandwidth events (peak speed changes due to external load). - * Profile must contain percentages (value between 0 and 1). */ - virtual void set_bandwidth_profile(kernel::profile::Profile* profile) = 0; - /* setup the profile file with latency events (peak latency changes due to external load). - * Profile must contain absolute values */ - virtual void set_latency_profile(kernel::profile::Profile* profile) = 0; - /** @brief Set the concurrency limit for this link */ - virtual void set_concurrency_limit(int limit) const = 0; -}; - -} // namespace resource -} // namespace kernel -} // namespace simgrid - -#endif /* SIMGRID_KERNEL_RESOURCE_LINKIMPLINTF_HPP */ diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 3dc1bd7d3d..5037e6aad1 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -9,8 +9,9 @@ #include "simgrid/s4u/Host.hpp" #include "simgrid/sg_config.hpp" #include "src/kernel/EngineImpl.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" +#include "src/kernel/resource/WifiLinkImpl.hpp" #include "src/kernel/resource/profile/Event.hpp" -#include "src/surf/network_wifi.hpp" #include "src/surf/surf_interface.hpp" #include @@ -128,7 +129,7 @@ void NetworkCm02Model::set_bw_factor_cb(const std::function& cb bw_factor_cb_ = cb; } -LinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vector& bandwidths) +StandardLinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vector& bandwidths) { xbt_assert(bandwidths.size() == 1, "Non-WIFI links must use only 1 bandwidth."); auto link = new NetworkCm02Link(name, bandwidths[0], get_maxmin_system()); @@ -136,9 +137,9 @@ LinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vect return link; } -LinkImpl* NetworkCm02Model::create_wifi_link(const std::string& name, const std::vector& bandwidths) +StandardLinkImpl* NetworkCm02Model::create_wifi_link(const std::string& name, const std::vector& bandwidths) { - auto link = new NetworkWifiLink(name, bandwidths, get_maxmin_system()); + auto link = new WifiLinkImpl(name, bandwidths, get_maxmin_system()); link->set_model(this); return link; } @@ -206,17 +207,17 @@ void NetworkCm02Model::update_actions_state_full(double /*now*/, double delta) void NetworkCm02Model::comm_action_expand_constraints(const s4u::Host* src, const s4u::Host* dst, const NetworkCm02Action* action, - const std::vector& route, - const std::vector& back_route) const + const std::vector& route, + const std::vector& back_route) const { /* expand route links constraints for route and back_route */ - const NetworkWifiLink* src_wifi_link = nullptr; - const NetworkWifiLink* dst_wifi_link = nullptr; + const WifiLinkImpl* src_wifi_link = nullptr; + const WifiLinkImpl* dst_wifi_link = nullptr; if (not route.empty() && route.front()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) { - src_wifi_link = static_cast(route.front()); + src_wifi_link = static_cast(route.front()); } if (route.size() > 1 && route.back()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) { - dst_wifi_link = static_cast(route.back()); + dst_wifi_link = static_cast(route.back()); } /* WI-FI links needs special treatment, do it here */ @@ -252,20 +253,20 @@ void NetworkCm02Model::comm_action_expand_constraints(const s4u::Host* src, cons } NetworkCm02Action* NetworkCm02Model::comm_action_create(s4u::Host* src, s4u::Host* dst, double size, - const std::vector& route, bool failed) + const std::vector& route, bool failed) { - NetworkWifiLink* src_wifi_link = nullptr; - NetworkWifiLink* dst_wifi_link = nullptr; + WifiLinkImpl* src_wifi_link = nullptr; + WifiLinkImpl* dst_wifi_link = nullptr; /* many checks related to Wi-Fi links */ if (not route.empty() && route.front()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) { - src_wifi_link = static_cast(route.front()); + src_wifi_link = static_cast(route.front()); xbt_assert(src_wifi_link->get_host_rate(src) != -1, "The route from %s to %s begins with the WIFI link %s, but the host %s does not seem attached to that " "WIFI link. Did you call link->set_host_rate()?", src->get_cname(), dst->get_cname(), src_wifi_link->get_cname(), src->get_cname()); } if (route.size() > 1 && route.back()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) { - dst_wifi_link = static_cast(route.back()); + dst_wifi_link = static_cast(route.back()); xbt_assert(dst_wifi_link->get_host_rate(dst) != -1, "The route from %s to %s ends with the WIFI link %s, but the host %s does not seem attached to that " "WIFI link. Did you call link->set_host_rate()?", @@ -292,7 +293,7 @@ NetworkCm02Action* NetworkCm02Model::comm_action_create(s4u::Host* src, s4u::Hos if (src_wifi_link == nullptr && dst_wifi_link == nullptr) action = new NetworkCm02Action(this, *src, *dst, size, failed); else - action = new NetworkWifiAction(this, *src, *dst, size, failed, src_wifi_link, dst_wifi_link); + action = new WifiLinkAction(this, *src, *dst, size, failed, src_wifi_link, dst_wifi_link); if (is_update_lazy()) { action->set_last_update(); @@ -302,7 +303,8 @@ NetworkCm02Action* NetworkCm02Model::comm_action_create(s4u::Host* src, s4u::Hos } bool NetworkCm02Model::comm_get_route_info(const s4u::Host* src, const s4u::Host* dst, double& latency, - std::vector& route, std::vector& back_route, + std::vector& route, + std::vector& back_route, std::unordered_set& netzones) const { kernel::routing::NetZoneImpl::get_global_route_with_netzones(src->get_netpoint(), dst->get_netpoint(), route, @@ -312,19 +314,19 @@ bool NetworkCm02Model::comm_get_route_info(const s4u::Host* src, const s4u::Host "You're trying to send data from %s to %s but there is no connecting path between these two hosts.", src->get_cname(), dst->get_cname()); - bool failed = std::any_of(route.begin(), route.end(), [](const LinkImpl* link) { return not link->is_on(); }); + bool failed = std::any_of(route.begin(), route.end(), [](const StandardLinkImpl* link) { return not link->is_on(); }); if (cfg_crosstraffic) { dst->route_to(src, back_route, nullptr); if (not failed) - failed = - std::any_of(back_route.begin(), back_route.end(), [](const LinkImpl* link) { return not link->is_on(); }); + failed = std::any_of(back_route.begin(), back_route.end(), + [](const StandardLinkImpl* link) { return not link->is_on(); }); } return failed; } void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size, - NetworkCm02Action* action, const std::vector& route, + NetworkCm02Action* action, const std::vector& route, const std::unordered_set& netzones, double rate) { @@ -333,7 +335,8 @@ void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::H /* transform data to user structures if necessary */ if (lat_factor_cb_ || bw_factor_cb_) { - std::for_each(route.begin(), route.end(), [&s4u_route](LinkImpl* l) { s4u_route.push_back(l->get_iface()); }); + std::for_each(route.begin(), route.end(), + [&s4u_route](StandardLinkImpl* l) { s4u_route.push_back(l->get_iface()); }); std::for_each(netzones.begin(), netzones.end(), [&s4u_netzones](kernel::routing::NetZoneImpl* n) { s4u_netzones.insert(n->get_iface()); }); } @@ -373,8 +376,8 @@ void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::H } } -void NetworkCm02Model::comm_action_set_variable(NetworkCm02Action* action, const std::vector& route, - const std::vector& back_route) +void NetworkCm02Model::comm_action_set_variable(NetworkCm02Action* action, const std::vector& route, + const std::vector& back_route) { size_t constraints_per_variable = route.size(); constraints_per_variable += back_route.size(); @@ -408,8 +411,8 @@ void NetworkCm02Model::comm_action_set_variable(NetworkCm02Action* action, const Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) { double latency = 0.0; - std::vector back_route; - std::vector route; + std::vector back_route; + std::vector route; std::unordered_set netzones; XBT_IN("(%s,%s,%g,%g)", src->get_cname(), dst->get_cname(), size, rate); @@ -421,10 +424,10 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz action->latency_ = latency; if (sg_weight_S_parameter > 0) { - action->sharing_penalty_ = - std::accumulate(route.begin(), route.end(), action->sharing_penalty_, [](double total, LinkImpl* const& link) { - return total + sg_weight_S_parameter / link->get_bandwidth(); - }); + action->sharing_penalty_ = std::accumulate(route.begin(), route.end(), action->sharing_penalty_, + [](double total, StandardLinkImpl* const& link) { + return total + sg_weight_S_parameter / link->get_bandwidth(); + }); } /* setting bandwidth and latency bounds considering route and configured bw/lat factors */ @@ -444,7 +447,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz * Resource * ************/ NetworkCm02Link::NetworkCm02Link(const std::string& name, double bandwidth, kernel::lmm::System* system) - : LinkImpl(name) + : StandardLinkImpl(name) { bandwidth_.scale = 1.0; bandwidth_.peak = bandwidth; @@ -483,7 +486,7 @@ void NetworkCm02Link::set_bandwidth(double value) get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), (bandwidth_.peak * bandwidth_.scale)); - LinkImpl::on_bandwidth_change(); + StandardLinkImpl::on_bandwidth_change(); if (sg_weight_S_parameter > 0) { double delta = sg_weight_S_parameter / (bandwidth_.peak * bandwidth_.scale) - diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index c962616e35..c6b709f446 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -8,8 +8,9 @@ #include -#include "network_interface.hpp" #include "simgrid/kernel/resource/NetworkModelIntf.hpp" +#include "src/kernel/resource/LinkImpl.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "xbt/graph.h" #include "xbt/string.hpp" @@ -32,27 +33,27 @@ class XBT_PRIVATE NetworkSmpiModel; class NetworkCm02Model : public NetworkModel { /** @brief Get route information (2-way) */ bool comm_get_route_info(const s4u::Host* src, const s4u::Host* dst, /* OUT */ double& latency, - std::vector& route, std::vector& back_route, + std::vector& route, std::vector& back_route, std::unordered_set& netzones) const; /** @brief Create network action for this communication */ NetworkCm02Action* comm_action_create(s4u::Host* src, s4u::Host* dst, double size, - const std::vector& route, bool failed); + const std::vector& route, bool failed); /** @brief Expand link contraint considering this new communication action */ void comm_action_expand_constraints(const s4u::Host* src, const s4u::Host* dst, const NetworkCm02Action* action, - const std::vector& route, - const std::vector& back_route) const; + const std::vector& route, + const std::vector& back_route) const; /** @brief Set communication bounds for latency and bandwidth */ void comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size, NetworkCm02Action* action, - const std::vector& route, + const std::vector& route, const std::unordered_set& netzones, double rate); /** @brief Create maxmin variable in communication action */ - void comm_action_set_variable(NetworkCm02Action* action, const std::vector& route, - const std::vector& back_route); + void comm_action_set_variable(NetworkCm02Action* action, const std::vector& route, + const std::vector& back_route); public: explicit NetworkCm02Model(const std::string& name); - LinkImpl* create_link(const std::string& name, const std::vector& bandwidths) final; - LinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidths) override; + StandardLinkImpl* create_link(const std::string& name, const std::vector& bandwidths) final; + StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidths) override; void update_actions_state_lazy(double now, double delta) override; void update_actions_state_full(double now, double delta) override; Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; @@ -72,7 +73,7 @@ private: * Resource * ************/ -class NetworkCm02Link : public LinkImpl { +class NetworkCm02Link : public StandardLinkImpl { public: NetworkCm02Link(const std::string& name, double bandwidth, lmm::System* system); void apply_event(kernel::profile::Event* event, double value) override; diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index b786a20b97..b8e9606fcd 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -27,7 +27,7 @@ namespace simgrid { namespace kernel { namespace resource { -LinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::vector& /*bandwidth*/) +StandardLinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::vector& /*bandwidth*/) { xbt_die("Refusing to create the link %s: there is no link in the Constant network model. " "Please remove any link from your platform (and switch to routing='None')", @@ -35,7 +35,7 @@ LinkImpl* NetworkConstantModel::create_link(const std::string& name, const std:: return nullptr; } -LinkImpl* NetworkConstantModel::create_wifi_link(const std::string& name, const std::vector& bandwidths) +StandardLinkImpl* NetworkConstantModel::create_wifi_link(const std::string& name, const std::vector& bandwidths) { return create_link(name, bandwidths); } diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index d0f733eda3..713c91594b 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -6,7 +6,7 @@ #ifndef NETWORK_CONSTANT_HPP_ #define NETWORK_CONSTANT_HPP_ -#include "network_interface.hpp" +#include "src/kernel/resource/LinkImpl.hpp" namespace simgrid { namespace kernel { @@ -19,8 +19,8 @@ public: double next_occurring_event(double now) override; void update_actions_state(double now, double delta) override; - LinkImpl* create_link(const std::string& name, const std::vector& bws) override; - LinkImpl* create_wifi_link(const std::string& name, const std::vector& bws) override; + StandardLinkImpl* create_link(const std::string& name, const std::vector& bws) override; + StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector& bws) override; }; class NetworkConstantAction final : public NetworkAction { diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 900518a179..f9c66af07b 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -241,7 +241,7 @@ static void clusterCreation_cb(simgrid::kernel::routing::ClusterCreationArgs con 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 const& link_list) + std::vector const& link_list) { /* ignoring routes from StarZone, not supported */ if (not src || not dst) @@ -346,7 +346,7 @@ NetworkNS3Model::NetworkNS3Model(const std::string& name) : NetworkModel(name) s4u::NetZone::on_seal_cb(&zoneCreation_cb); } -LinkImpl* NetworkNS3Model::create_link(const std::string& name, const std::vector& bandwidths) +StandardLinkImpl* NetworkNS3Model::create_link(const std::string& name, const std::vector& bandwidths) { xbt_assert(bandwidths.size() == 1, "ns-3 links must use only 1 bandwidth."); auto* link = new LinkNS3(name, bandwidths[0]); @@ -354,7 +354,7 @@ LinkImpl* NetworkNS3Model::create_link(const std::string& name, const std::vecto return link; } -LinkImpl* NetworkNS3Model::create_wifi_link(const std::string& name, const std::vector& bandwidths) +StandardLinkImpl* NetworkNS3Model::create_wifi_link(const std::string& name, const std::vector& bandwidths) { auto* link = create_link(name, bandwidths); link->set_sharing_policy(s4u::Link::SharingPolicy::WIFI, {}); @@ -420,7 +420,7 @@ void NetworkNS3Model::update_actions_state(double now, double delta) if (TRACE_is_enabled() && action->get_state() == kernel::resource::Action::State::STARTED) { double data_delta_sent = sgFlow->sent_bytes_ - action->last_sent_; - std::vector route = std::vector(); + std::vector route = std::vector(); action->get_src().route_to(&action->get_dst(), route, nullptr); for (auto const& link : route) @@ -459,7 +459,7 @@ void NetworkNS3Model::update_actions_state(double now, double delta) * Resource * ************/ -LinkNS3::LinkNS3(const std::string& name, double bandwidth) : LinkImpl(name) +LinkNS3::LinkNS3(const std::string& name, double bandwidth) : StandardLinkImpl(name) { bandwidth_.peak = bandwidth; } @@ -558,7 +558,7 @@ void NetworkNS3Action::resume() THROW_UNIMPLEMENTED; } -std::list NetworkNS3Action::get_links() const +std::list NetworkNS3Action::get_links() const { THROW_UNIMPLEMENTED; } diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index 398de6e2d5..e7a9f0a561 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -8,7 +8,7 @@ #include "xbt/base.h" -#include "network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" namespace simgrid { namespace kernel { @@ -17,8 +17,8 @@ namespace resource { class NetworkNS3Model : public NetworkModel { public: explicit NetworkNS3Model(const std::string& name); - LinkImpl* create_link(const std::string& name, const std::vector& bandwidth) override; - LinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidth) override; + StandardLinkImpl* create_link(const std::string& name, const std::vector& bandwidth) override; + StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidth) override; Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; double next_occurring_event(double now) override; bool next_occurring_event_is_idempotent() override { return false; } @@ -28,7 +28,7 @@ public: /************ * Resource * ************/ -class LinkNS3 : public LinkImpl { +class LinkNS3 : public StandardLinkImpl { public: explicit LinkNS3(const std::string& name, double bandwidth); ~LinkNS3() override; @@ -52,7 +52,7 @@ public: void suspend() override; void resume() override; - std::list get_links() const override; + std::list get_links() const override; void update_remains_lazy(double now) override; // private: diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index b6c4e5db89..6d63a2af5d 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -169,7 +169,7 @@ L07Action::L07Action(Model* model, const std::vector& host_list, con continue; double lat = 0.0; - std::vector route; + std::vector route; hostList_[k / host_list.size()]->route_to(hostList_[k % host_list.size()], route, &lat); latency = std::max(latency, lat); @@ -200,7 +200,7 @@ L07Action::L07Action(Model* model, const std::vector& host_list, con for (size_t k = 0; k < host_list.size() * host_list.size(); k++) { if (bytes_amount[k] <= 0.0) continue; - std::vector route; + std::vector route; hostList_[k / host_list.size()]->route_to(hostList_[k % host_list.size()], route, nullptr); for (auto const& link : route) @@ -234,7 +234,7 @@ CpuImpl* CpuL07Model::create_cpu(s4u::Host* host, const std::vector& spe return (new CpuL07(host, speed_per_pstate))->set_model(this); } -LinkImpl* NetworkL07Model::create_link(const std::string& name, const std::vector& bandwidths) +StandardLinkImpl* NetworkL07Model::create_link(const std::string& name, const std::vector& bandwidths) { xbt_assert(bandwidths.size() == 1, "Non WIFI link must have only 1 bandwidth."); auto link = new LinkL07(name, bandwidths[0], get_maxmin_system()); @@ -242,7 +242,7 @@ LinkImpl* NetworkL07Model::create_link(const std::string& name, const std::vecto return link; } -LinkImpl* NetworkL07Model::create_wifi_link(const std::string& name, const std::vector& bandwidths) +StandardLinkImpl* NetworkL07Model::create_wifi_link(const std::string& name, const std::vector& bandwidths) { THROW_UNIMPLEMENTED; } @@ -290,7 +290,7 @@ void CpuL07::on_speed_change() CpuImpl::on_speed_change(); } -LinkL07::LinkL07(const std::string& name, double bandwidth, lmm::System* system) : LinkImpl(name) +LinkL07::LinkL07(const std::string& name, double bandwidth, lmm::System* system) : StandardLinkImpl(name) { this->set_constraint(system->constraint_new(this, bandwidth)); bandwidth_.peak = bandwidth; @@ -344,7 +344,7 @@ void LinkL07::apply_event(profile::Event* triggered, double value) void LinkL07::set_bandwidth(double value) { bandwidth_.peak = value; - LinkImpl::on_bandwidth_change(); + StandardLinkImpl::on_bandwidth_change(); get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), bandwidth_.peak * bandwidth_.scale); } @@ -389,7 +389,7 @@ double L07Action::calculateNetworkBound() for (size_t j = 0; j < host_count; j++) { if (communicationAmount_[i * host_count + j] > 0) { double lat = 0.0; - std::vector route; + std::vector route; hostList_.at(i)->route_to(hostList_.at(j), route, &lat); lat_current = std::max(lat_current, lat * communicationAmount_[i * host_count + j]); diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 7e398624e2..b6639585e4 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -65,8 +65,8 @@ public: NetworkL07Model(const NetworkL07Model&) = delete; NetworkL07Model& operator=(const NetworkL07Model&) = delete; ~NetworkL07Model() override; - LinkImpl* create_link(const std::string& name, const std::vector& bandwidths) final; - LinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidths) override; + StandardLinkImpl* create_link(const std::string& name, const std::vector& bandwidths) final; + StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidths) override; Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; void update_actions_state(double /*now*/, double /*delta*/) override{ @@ -101,7 +101,7 @@ protected: void on_speed_change() override; }; -class LinkL07 : public LinkImpl { +class LinkL07 : public StandardLinkImpl { public: LinkL07(const std::string& name, double bandwidth, lmm::System* system); LinkL07(const LinkL07&) = delete; diff --git a/src/surf/xml/surfxml_parseplatf.cpp b/src/surf/xml/surfxml_parseplatf.cpp index a7b5c95b5f..526815a037 100644 --- a/src/surf/xml/surfxml_parseplatf.cpp +++ b/src/surf/xml/surfxml_parseplatf.cpp @@ -6,7 +6,7 @@ #include #include "src/kernel/resource/CpuImpl.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/LinkImpl.hpp" #include "src/surf/surf_interface.hpp" #include "src/surf/xml/platf.hpp" #include "src/surf/xml/platf_private.hpp" diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index aabf032dc0..e6608e84c8 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -10,9 +10,9 @@ #include #include "simgrid/sg_config.hpp" +#include "src/kernel/resource/LinkImpl.hpp" #include "src/kernel/resource/profile/FutureEvtSet.hpp" #include "src/kernel/resource/profile/Profile.hpp" -#include "src/surf/network_interface.hpp" #include "src/surf/surf_interface.hpp" #include "src/surf/xml/platf.hpp" #include "src/surf/xml/platf_private.hpp" diff --git a/teshsuite/models/wifi_usage/wifi_usage.cpp b/teshsuite/models/wifi_usage/wifi_usage.cpp index 04f093ab97..814cca6f43 100644 --- a/teshsuite/models/wifi_usage/wifi_usage.cpp +++ b/teshsuite/models/wifi_usage/wifi_usage.cpp @@ -7,7 +7,7 @@ #include "xbt/config.hpp" #include "xbt/log.h" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/WifiLinkImpl.hpp" XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[usage] wifi_usage "); diff --git a/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp b/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp index 8abfa03c1a..ea39344486 100644 --- a/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp +++ b/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp @@ -7,7 +7,7 @@ #include "xbt/config.hpp" #include "xbt/log.h" -#include "src/surf/network_wifi.hpp" +#include "src/kernel/resource/WifiLinkImpl.hpp" XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[usage] wifi_usage "); @@ -77,7 +77,7 @@ void run_ping_test(const char* src, const char* dest, int data_size) }); simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name(dest), [mailbox]() { mailbox->get(); }); - auto* l = (simgrid::kernel::resource::NetworkWifiLink*)simgrid::s4u::Link::by_name("AP1")->get_impl(); + auto* l = (simgrid::kernel::resource::WifiLinkImpl*)simgrid::s4u::Link::by_name("AP1")->get_impl(); if (not l->toggle_decay_model()) l->toggle_decay_model(); l->set_host_rate(simgrid::s4u::Host::by_name("Station 1"), 0); diff --git a/teshsuite/platforms/flatifier.cpp b/teshsuite/platforms/flatifier.cpp index 2ab089a7f3..85c2aa3027 100644 --- a/teshsuite/platforms/flatifier.cpp +++ b/teshsuite/platforms/flatifier.cpp @@ -9,7 +9,7 @@ #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/Link.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include #include @@ -119,7 +119,7 @@ static void dump_routes() for (auto src_host : hosts) { // Routes from host const simgrid::kernel::routing::NetPoint* src = src_host->get_netpoint(); for (auto dst_host : hosts) { // Routes to host - std::vector route; + std::vector route; const simgrid::kernel::routing::NetPoint* dst = dst_host->get_netpoint(); simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr); if (route.empty()) @@ -134,7 +134,7 @@ static void dump_routes() if (not dst->is_router()) continue; std::printf(" \n ", src_host->get_cname(), dst->get_cname()); - std::vector route; + std::vector route; simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr); for (auto const& link : route) std::printf("", link->get_cname()); @@ -148,7 +148,7 @@ static void dump_routes() for (auto const& value2 : netpoints) { // to router if (not value2->is_router()) continue; - std::vector route; + std::vector route; simgrid::kernel::routing::NetZoneImpl::get_global_route(value1, value2, route, nullptr); if (route.empty()) continue; @@ -159,7 +159,7 @@ static void dump_routes() } for (auto dst_host : hosts) { // Routes to host std::printf(" \n ", value1->get_cname(), dst_host->get_cname()); - std::vector route; + std::vector route; const simgrid::kernel::routing::NetPoint* netcardDst = dst_host->get_netpoint(); simgrid::kernel::routing::NetZoneImpl::get_global_route(value1, netcardDst, route, nullptr); for (auto const& link : route) diff --git a/teshsuite/surf/surf_usage/surf_usage.cpp b/teshsuite/surf/surf_usage/surf_usage.cpp index 32f8006850..30b66399f8 100644 --- a/teshsuite/surf/surf_usage/surf_usage.cpp +++ b/teshsuite/surf/surf_usage/surf_usage.cpp @@ -11,7 +11,7 @@ #include "simgrid/zone.h" #include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/CpuImpl.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/LinkImpl.hpp" #include "xbt/config.hpp" XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example"); diff --git a/teshsuite/surf/surf_usage2/surf_usage2.cpp b/teshsuite/surf/surf_usage2/surf_usage2.cpp index 846a2d754d..74bdf88392 100644 --- a/teshsuite/surf/surf_usage2/surf_usage2.cpp +++ b/teshsuite/surf/surf_usage2/surf_usage2.cpp @@ -11,7 +11,7 @@ #include "simgrid/zone.h" #include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/CpuImpl.hpp" -#include "src/surf/network_interface.hpp" +#include "src/kernel/resource/LinkImpl.hpp" #include "src/surf/surf_interface.hpp" #include "xbt/config.hpp" diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 26965c6073..caf746ef18 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -12,6 +12,10 @@ set(EXTRA_DIST src/include/xbt/xbt_modinter.h src/include/catch.hpp src/include/xxhash.hpp + src/kernel/resource/LinkImpl.hpp + src/kernel/resource/SplitDuplexLinkImpl.hpp + src/kernel/resource/StandardLinkImpl.hpp + src/kernel/resource/WifiLinkImpl.hpp src/mc/mc_mmu.hpp src/mc/mc_record.hpp src/msg/msg_private.hpp @@ -36,14 +40,9 @@ set(EXTRA_DIST src/surf/cpu_ti.hpp src/surf/network_cm02.hpp src/surf/network_constant.hpp - src/surf/network_interface.hpp - src/surf/LinkImpl.hpp - src/surf/LinkImplIntf.hpp - src/surf/SplitDuplexLinkImpl.hpp src/surf/network_ns3.hpp src/surf/network_smpi.hpp src/surf/network_ib.hpp - src/surf/network_wifi.hpp src/surf/ns3/ns3_simulator.hpp src/surf/xml/simgrid.dtd src/surf/xml/simgrid_dtd.h @@ -312,8 +311,12 @@ set(SURF_SRC src/kernel/resource/DiskImpl.hpp src/kernel/resource/Model.cpp src/kernel/resource/Resource.hpp + src/kernel/resource/LinkImpl.cpp + src/kernel/resource/SplitDuplexLinkImpl.cpp + src/kernel/resource/StandardLinkImpl.cpp src/kernel/resource/VirtualMachineImpl.hpp src/kernel/resource/VirtualMachineImpl.cpp + src/kernel/resource/WifiLinkImpl.cpp src/kernel/resource/profile/DatedValue.cpp src/kernel/resource/profile/DatedValue.hpp @@ -351,10 +354,6 @@ set(SURF_SRC src/surf/disk_s19.cpp src/surf/network_cm02.cpp src/surf/network_constant.cpp - src/surf/network_interface.cpp - src/surf/LinkImpl.cpp - src/surf/SplitDuplexLinkImpl.cpp - src/surf/network_wifi.cpp src/surf/sg_platf.cpp src/surf/surf_interface.cpp src/surf/xml/platf.hpp diff --git a/tools/cmake/Tests.cmake b/tools/cmake/Tests.cmake index c7857828f0..a7a6558f62 100644 --- a/tools/cmake/Tests.cmake +++ b/tools/cmake/Tests.cmake @@ -124,6 +124,7 @@ ENDIF() # New tests should use the Catch Framework set(UNIT_TESTS src/xbt/unit-tests_main.cpp src/kernel/resource/NetworkModelIntf_test.cpp + src/kernel/resource/SplitDuplexLinkImpl_test.cpp src/kernel/resource/profile/Profile_test.cpp src/kernel/routing/DijkstraZone_test.cpp src/kernel/routing/DragonflyZone_test.cpp @@ -132,7 +133,6 @@ set(UNIT_TESTS src/xbt/unit-tests_main.cpp src/kernel/routing/FullZone_test.cpp src/kernel/routing/StarZone_test.cpp src/kernel/routing/TorusZone_test.cpp - src/surf/SplitDuplexLinkImpl_test.cpp src/xbt/config_test.cpp src/xbt/dict_test.cpp src/xbt/dynar_test.cpp