1 /* Copyright (c) 2014-2022. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef SURF_NETWORK_IB_HPP_
8 #define SURF_NETWORK_IB_HPP_
10 #include "src/surf/network_smpi.hpp"
16 namespace simgrid::kernel::resource {
18 class XBT_PRIVATE IBNode;
20 struct XBT_PRIVATE ActiveComm {
21 IBNode* destination = nullptr;
22 NetworkAction* action = nullptr;
23 double init_rate = -1;
29 // store related links, to ease computation of the penalties
30 std::vector<ActiveComm*> active_comms_up_;
31 // store the number of comms received from each node
32 std::map<IBNode*, int> active_comms_down_;
33 // number of comms the node is receiving
34 int nb_active_comms_down_ = 0;
35 explicit IBNode(int id) : id_(id){};
38 class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
39 std::unordered_map<std::string, IBNode> active_nodes;
40 std::unordered_map<NetworkAction*, std::pair<IBNode*, IBNode*>> active_comms;
45 void update_IB_factors_rec(IBNode* root, std::vector<bool>& updatedlist) const;
46 void compute_IB_factors(IBNode* root) const;
49 explicit NetworkIBModel(const std::string& name);
50 NetworkIBModel(const NetworkIBModel&) = delete;
51 NetworkIBModel& operator=(const NetworkIBModel&) = delete;
52 void update_IB_factors(NetworkAction* action, IBNode* from, IBNode* to, int remove) const;
54 static void IB_create_host_callback(s4u::Host const& host);
55 static void IB_action_state_changed_callback(NetworkAction& action, Action::State /*previous*/);
56 static void IB_comm_start_callback(const activity::CommImpl& comm);
58 } // namespace simgrid::kernel::resource