1 /* Copyright (c) 2014-2023. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_MODEL_NETWORK_IB_HPP_
7 #define SIMGRID_MODEL_NETWORK_IB_HPP_
9 #include "src/kernel/resource/models/network_cm02.hpp"
14 namespace simgrid::kernel::resource {
16 class XBT_PRIVATE IBNode;
18 struct XBT_PRIVATE ActiveComm {
19 IBNode* destination = nullptr;
20 NetworkAction* action = nullptr;
21 double init_rate = -1;
27 // store related links, to ease computation of the penalties
28 std::vector<ActiveComm*> active_comms_up_;
29 // store the number of comms received from each node
30 std::map<IBNode*, int> active_comms_down_;
31 // number of comms the node is receiving
32 int nb_active_comms_down_ = 0;
33 explicit IBNode(int id) : id_(id){};
36 class XBT_PRIVATE NetworkIBModel : public NetworkCm02Model {
37 std::unordered_map<std::string, IBNode> active_nodes;
38 std::unordered_map<NetworkAction*, std::pair<IBNode*, IBNode*>> active_comms;
43 void update_IB_factors_rec(IBNode* root, std::vector<bool>& updatedlist) const;
44 void compute_IB_factors(IBNode* root) const;
47 explicit NetworkIBModel(const std::string& name);
48 NetworkIBModel(const NetworkIBModel&) = delete;
49 NetworkIBModel& operator=(const NetworkIBModel&) = delete;
50 void update_IB_factors(NetworkAction* action, IBNode* from, IBNode* to, bool remove) const;
52 static void IB_create_host_callback(s4u::Host const& host);
53 static void IB_action_state_changed_callback(NetworkAction& action, Action::State /*previous*/);
54 static void IB_comm_start_callback(const s4u::Comm& comm);
56 } // namespace simgrid::kernel::resource