1 /* Copyright (c) 2013-2021. 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 #include "src/surf/HostImpl.hpp"
21 class XBT_PRIVATE HostL07Model;
22 class XBT_PRIVATE CpuL07Model;
23 class XBT_PRIVATE NetworkL07Model;
25 class XBT_PRIVATE CpuL07;
26 class XBT_PRIVATE LinkL07;
28 class XBT_PRIVATE L07Action;
36 class HostL07Model : public HostModel {
39 HostL07Model(const HostL07Model&) = delete;
40 HostL07Model& operator=(const HostL07Model&) = delete;
41 ~HostL07Model() override;
43 double next_occurring_event(double now) override;
44 void update_actions_state(double now, double delta) override;
45 kernel::resource::CpuAction* execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
46 const double* bytes_amount, double rate) override;
49 class CpuL07Model : public kernel::resource::CpuModel {
51 CpuL07Model(HostL07Model* hmodel, kernel::lmm::System* sys);
52 CpuL07Model(const CpuL07Model&) = delete;
53 CpuL07Model& operator=(const CpuL07Model&) = delete;
54 ~CpuL07Model() override;
55 /* this action is done by HostL07Model which shares the LMM system with the CPU model
56 * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
57 * method in surf_presolve */
58 void update_actions_state(double now, double delta) override{};
60 kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
61 HostL07Model* hostModel_;
64 class NetworkL07Model : public kernel::resource::NetworkModel {
66 NetworkL07Model(HostL07Model* hmodel, kernel::lmm::System* sys);
67 NetworkL07Model(const NetworkL07Model&) = delete;
68 NetworkL07Model& operator=(const NetworkL07Model&) = delete;
69 ~NetworkL07Model() override;
70 kernel::resource::LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths,
71 s4u::Link::SharingPolicy policy) override;
73 kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
74 /* this action is done by HostL07Model which shares the LMM system with the CPU model
75 * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
76 * method in surf_presolve */
77 void update_actions_state(double now, double delta) override{};
79 HostL07Model* hostModel_;
86 class CpuL07 : public kernel::resource::Cpu {
88 CpuL07(s4u::Host* host, const std::vector<double>& speed_per_pstate) : Cpu(host, speed_per_pstate){};
89 CpuL07(const CpuL07&) = delete;
90 CpuL07& operator=(const CpuL07&) = delete;
92 bool is_used() const override;
93 void apply_event(kernel::profile::Event* event, double value) override;
94 kernel::resource::CpuAction* execution_start(double size) override;
95 kernel::resource::CpuAction* execution_start(double, int) override
100 kernel::resource::CpuAction* sleep(double duration) override;
103 void on_speed_change() override;
106 class LinkL07 : public kernel::resource::LinkImpl {
108 LinkL07(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy, kernel::lmm::System* system);
109 LinkL07(const LinkL07&) = delete;
110 LinkL07& operator=(const LinkL07&) = delete;
112 bool is_used() const override;
113 void apply_event(kernel::profile::Event* event, double value) override;
114 void set_bandwidth(double value) override;
115 LinkImpl* set_latency(double value) override;
121 class L07Action : public kernel::resource::CpuAction {
122 std::vector<s4u::Host*> hostList_;
123 bool free_arrays_ = false; // By default, computationAmount_ and friends are freed by caller. But not for sequential
124 // exec and regular comms
125 const double* computationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
127 const double* communicationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
132 friend CpuAction* CpuL07::execution_start(double size);
133 friend CpuAction* CpuL07::sleep(double duration);
134 friend CpuAction* HostL07Model::execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
135 const double* bytes_amount, double rate);
136 friend Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
139 L07Action() = delete;
140 L07Action(kernel::resource::Model* model, const std::vector<s4u::Host*>& host_list, const double* flops_amount,
141 const double* bytes_amount, double rate);
142 L07Action(const L07Action&) = delete;
143 L07Action& operator=(const L07Action&) = delete;
144 ~L07Action() override;
147 double get_latency() const { return latency_; }
148 void set_latency(double latency) { latency_ = latency; }
149 void update_latency(double delta, double precision) { double_update(&latency_, delta, precision); }
153 } // namespace simgrid
155 #endif /* HOST_L07_HPP_ */