Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'fluidio' into 'master'
[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) const;
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
59 /************
60  * Resource *
61  ************/
62
63 class NetworkCm02Link : public StandardLinkImpl {
64 public:
65   NetworkCm02Link(const std::string& name, double bandwidth, lmm::System* system);
66   void apply_event(kernel::profile::Event* event, double value) override;
67   void set_bandwidth(double value) override;
68   void set_latency(double value) override;
69 };
70
71 /**********
72  * Action *
73  **********/
74 class NetworkCm02Action : public NetworkAction {
75   friend Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
76
77 public:
78   using NetworkAction::NetworkAction;
79   void update_remains_lazy(double now) override;
80 };
81 } // namespace simgrid::kernel::resource
82 #endif /* SURF_NETWORK_CM02_HPP_ */