Logo AND Algorithmique Numérique Distribuée

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