Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix lua compilation
[simgrid.git] / src / surf / network_ib.hpp
1 /* Copyright (c) 2014-2021. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SURF_NETWORK_IB_HPP_
8 #define SURF_NETWORK_IB_HPP_
9
10 #include "src/surf/network_smpi.hpp"
11 #include "xbt/base.h"
12
13 #include <map>
14 #include <vector>
15
16 namespace simgrid {
17 namespace kernel {
18 namespace resource {
19
20 class XBT_PRIVATE IBNode;
21
22 struct XBT_PRIVATE ActiveComm {
23   IBNode* destination   = nullptr;
24   NetworkAction* action = nullptr;
25   double init_rate      = -1;
26 };
27
28 class IBNode {
29 public:
30   int id_;
31   // store related links, to ease computation of the penalties
32   std::vector<ActiveComm*> active_comms_up_;
33   // store the number of comms received from each node
34   std::map<IBNode*, int> active_comms_down_;
35   // number of comms the node is receiving
36   int nb_active_comms_down_ = 0;
37   explicit IBNode(int id) : id_(id){};
38 };
39
40 class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
41   std::unordered_map<std::string, IBNode> active_nodes;
42   std::unordered_map<NetworkAction*, std::pair<IBNode*, IBNode*>> active_comms;
43
44   double Bs_;
45   double Be_;
46   double ys_;
47   void update_IB_factors_rec(IBNode* root, std::vector<bool>& updatedlist) const;
48   void compute_IB_factors(IBNode* root) const;
49
50 public:
51   explicit NetworkIBModel(const std::string& name);
52   NetworkIBModel(const NetworkIBModel&) = delete;
53   NetworkIBModel& operator=(const NetworkIBModel&) = delete;
54   void update_IB_factors(NetworkAction* action, IBNode* from, IBNode* to, int remove) const;
55
56   static void IB_create_host_callback(s4u::Host const& host);
57   static void IB_action_state_changed_callback(NetworkAction& action, Action::State /*previous*/);
58   static void IB_action_init_callback(NetworkAction& action);
59 };
60 } // namespace resource
61 } // namespace kernel
62 } // namespace simgrid
63 #endif