1 /* Copyright (c) 2013-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_MODEL_NETWORK_CM02_HPP_
7 #define SIMGRID_MODEL_NETWORK_CM02_HPP_
9 #include "src/kernel/resource/NetworkModel.hpp"
10 #include "src/kernel/resource/StandardLinkImpl.hpp"
17 namespace simgrid::kernel::resource {
19 class XBT_PRIVATE NetworkCm02Model;
20 class XBT_PRIVATE NetworkCm02Action;
21 class XBT_PRIVATE NetworkSmpiModel;
27 class NetworkCm02Model : public NetworkModel {
28 /** @brief Get route information (2-way) */
29 bool comm_get_route_info(const s4u::Host* src, const s4u::Host* dst, /* OUT */ double& latency,
30 std::vector<StandardLinkImpl*>& route, std::vector<StandardLinkImpl*>& back_route,
31 std::unordered_set<kernel::routing::NetZoneImpl*>& netzones) const;
32 /** @brief Create network action for this communication */
33 NetworkCm02Action* comm_action_create(s4u::Host* src, s4u::Host* dst, double size,
34 const std::vector<StandardLinkImpl*>& route, bool failed);
35 /** @brief Expand link contraint considering this new communication action */
36 void comm_action_expand_constraints(const s4u::Host* src, const s4u::Host* dst, const NetworkCm02Action* action,
37 const std::vector<StandardLinkImpl*>& route,
38 const std::vector<StandardLinkImpl*>& back_route) const;
39 /** @brief Set communication bounds for latency and bandwidth */
40 void comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size, NetworkCm02Action* action,
41 const std::vector<StandardLinkImpl*>& route,
42 const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones, double rate) const;
43 /** @brief Create maxmin variable in communication action */
44 void comm_action_set_variable(NetworkCm02Action* action, const std::vector<StandardLinkImpl*>& route,
45 const std::vector<StandardLinkImpl*>& back_route, bool streamed);
48 explicit NetworkCm02Model(const std::string& name);
49 StandardLinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths) final;
50 StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths) override;
51 void update_actions_state_lazy(double now, double delta) override;
52 void update_actions_state_full(double now, double delta) override;
53 Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate, bool streamed) override;
60 class NetworkCm02Link : public StandardLinkImpl {
62 NetworkCm02Link(const std::string& name, double bandwidth, lmm::System* system);
63 void apply_event(kernel::profile::Event* event, double value) override;
64 void set_bandwidth(double value) override;
65 void set_latency(double value) override;
71 class NetworkCm02Action : public NetworkAction {
72 friend Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate, bool streamed);
75 using NetworkAction::NetworkAction;
76 void update_remains_lazy(double now) override;
78 } // namespace simgrid::kernel::resource
79 #endif /* SIMGRID_MODEL_NETWORK_CM02_HPP_ */