Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[DVFS] Update HostDvfs class documentation
[simgrid.git] / src / surf / network_ib.hpp
1 /* Copyright (c) 2014-2017. 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 <unordered_map>
14 #include <vector>
15
16 namespace simgrid {
17   namespace surf {
18
19     class XBT_PRIVATE IBNode;
20
21     class XBT_PRIVATE ActiveComm{
22     public :
23       //IBNode* origin;
24       IBNode* destination;
25       NetworkAction *action;
26       double init_rate;
27       ActiveComm() : destination(nullptr),action(nullptr),init_rate(-1){};
28       virtual ~ActiveComm() = default;
29     };
30
31     class IBNode{
32     public :
33       int id;
34       //store related links, to ease computation of the penalties
35       std::vector<ActiveComm*> ActiveCommsUp;
36       //store the number of comms received from each node
37       std::map<IBNode*, int> ActiveCommsDown;
38       //number of comms the node is receiving
39       int nbActiveCommsDown;
40       explicit IBNode(int id) : id(id),nbActiveCommsDown(0){};
41       virtual ~IBNode() = default;
42     };
43
44     class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
45     private:
46       void updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist);
47       void computeIBfactors(IBNode *root);
48     public:
49       NetworkIBModel();
50       explicit NetworkIBModel(const char *name);
51       ~NetworkIBModel() override;
52       void updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove);
53
54       std::unordered_map<std::string, IBNode*> active_nodes;
55       std::unordered_map<NetworkAction*, std::pair<IBNode*, IBNode*>> active_comms;
56
57       double Bs;
58       double Be;
59       double ys;
60
61     };
62
63   }
64 }
65
66 #endif