Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / surf / network_cm02.hpp
1 /* Copyright (c) 2013-2022. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SURF_NETWORK_CM02_HPP_
7 #define SURF_NETWORK_CM02_HPP_
8
9 #include <xbt/base.h>
10
11 #include "simgrid/kernel/resource/NetworkModelIntf.hpp"
12 #include "src/kernel/resource/LinkImpl.hpp"
13 #include "src/kernel/resource/StandardLinkImpl.hpp"
14 #include "xbt/graph.h"
15 #include "xbt/string.hpp"
16
17 /***********
18  * Classes *
19  ***********/
20
21 namespace simgrid {
22 namespace kernel {
23 namespace resource {
24
25 class XBT_PRIVATE NetworkCm02Model;
26 class XBT_PRIVATE NetworkCm02Action;
27 class XBT_PRIVATE NetworkSmpiModel;
28
29 /*********
30  * Model *
31  *********/
32
33 class NetworkCm02Model : public NetworkModel {
34   /** @brief Get route information (2-way) */
35   bool comm_get_route_info(const s4u::Host* src, const s4u::Host* dst, /* OUT */ double& latency,
36                            std::vector<StandardLinkImpl*>& route, std::vector<StandardLinkImpl*>& back_route,
37                            std::unordered_set<kernel::routing::NetZoneImpl*>& netzones) const;
38   /** @brief Create network action for this communication */
39   NetworkCm02Action* comm_action_create(s4u::Host* src, s4u::Host* dst, double size,
40                                         const std::vector<StandardLinkImpl*>& route, bool failed);
41   /** @brief Expand link contraint considering this new communication action */
42   void comm_action_expand_constraints(const s4u::Host* src, const s4u::Host* dst, const NetworkCm02Action* action,
43                                       const std::vector<StandardLinkImpl*>& route,
44                                       const std::vector<StandardLinkImpl*>& back_route) const;
45   /** @brief Set communication bounds for latency and bandwidth */
46   void comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size, NetworkCm02Action* action,
47                               const std::vector<StandardLinkImpl*>& route,
48                               const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones, double rate);
49   /** @brief Create maxmin variable in communication action */
50   void comm_action_set_variable(NetworkCm02Action* action, const std::vector<StandardLinkImpl*>& route,
51                                 const std::vector<StandardLinkImpl*>& back_route);
52
53 public:
54   explicit NetworkCm02Model(const std::string& name);
55   StandardLinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths) final;
56   StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths) override;
57   void update_actions_state_lazy(double now, double delta) override;
58   void update_actions_state_full(double now, double delta) override;
59   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
60   void set_lat_factor_cb(const std::function<NetworkFactorCb>& cb) override;
61   void set_bw_factor_cb(const std::function<NetworkFactorCb>& cb) override;
62
63 protected:
64   virtual void check_lat_factor_cb();
65   virtual void check_bw_factor_cb();
66
67 private:
68   std::function<NetworkFactorCb> lat_factor_cb_;
69   std::function<NetworkFactorCb> bw_factor_cb_;
70 };
71
72 /************
73  * Resource *
74  ************/
75
76 class NetworkCm02Link : public StandardLinkImpl {
77 public:
78   NetworkCm02Link(const std::string& name, double bandwidth, lmm::System* system);
79   void apply_event(kernel::profile::Event* event, double value) override;
80   void set_bandwidth(double value) override;
81   void set_latency(double value) override;
82 };
83
84 /**********
85  * Action *
86  **********/
87 class NetworkCm02Action : public NetworkAction {
88   friend Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
89
90 public:
91   using NetworkAction::NetworkAction;
92   void update_remains_lazy(double now) override;
93 };
94 } // namespace resource
95 } // namespace kernel
96 } // namespace simgrid
97 #endif /* SURF_NETWORK_CM02_HPP_ */