1 /* Copyright (c) 2022. 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. */
7 #include "src/kernel/resource/NetworkModel.hpp"
8 #include "src/surf/HostImpl.hpp"
14 namespace simgrid::kernel::resource {
20 class XBT_PRIVATE HostS22Model;
21 class XBT_PRIVATE DiskS22Model;
22 class XBT_PRIVATE NetworkS22Model;
24 class XBT_PRIVATE DiskS22;
25 class XBT_PRIVATE LinkS22;
27 class XBT_PRIVATE S22Action;
32 class HostS22Model : public HostModel {
34 HostS22Model(const std::string& name, lmm::System* sys);
35 HostS22Model(const HostS22Model&) = delete;
36 HostS22Model& operator=(const HostS22Model&) = delete;
38 double next_occurring_event(double now) override;
39 void update_actions_state(double now, double delta) override;
40 Action* execute_thread(const s4u::Host* host, double flops_amount, int thread_count) override { return nullptr; }
41 CpuAction* execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
42 const double* bytes_amount, double rate) override { return nullptr; }
43 DiskAction* io_stream(s4u::Host* src_host, DiskImpl* src_disk, s4u::Host* dst_host, DiskImpl* dst_disk, double size);
46 class DiskS22Model : public DiskModel {
48 DiskS22Model(const std::string& name, HostS22Model* hmodel, lmm::System* sys);
49 DiskS22Model(const DiskS22Model&) = delete;
50 DiskS22Model& operator=(const DiskS22Model&) = delete;
51 ~DiskS22Model() override;
52 void update_actions_state(double /*now*/, double /*delta*/) override{
53 /* this action is done by HostS22Model which shares the LMM system with the Disk model
54 * Overriding to an empty function here allows us to handle the DiskS22Model as a regular
55 * method in EngineImpl::presolve */
58 DiskImpl* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth) override;
59 HostS22Model* hostModel_;
62 class NetworkS22Model : public NetworkModel {
64 NetworkS22Model(const std::string& name, HostS22Model* hmodel, lmm::System* sys);
65 NetworkS22Model(const NetworkS22Model&) = delete;
66 NetworkS22Model& operator=(const NetworkS22Model&) = delete;
67 ~NetworkS22Model() override;
68 StandardLinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths) final;
69 StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths) override;
71 Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
72 void update_actions_state(double /*now*/, double /*delta*/) override{
73 /* this action is done by HostS22Model which shares the LMM system with the Network model
74 * Overriding to an empty function here allows us to handle the NetworkS22Model as a regular
75 * method in EngineImpl::presolve */
78 HostS22Model* hostModel_;
85 class DiskS22 : public DiskImpl {
87 using DiskImpl::DiskImpl;
88 DiskS22(const DiskS22&) = delete;
89 DiskS22& operator=(const DiskS22&) = delete;
91 void apply_event(profile::Event* event, double value) override;
92 DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) override;
95 class LinkS22 : public StandardLinkImpl {
97 LinkS22(const std::string& name, double bandwidth, lmm::System* system);
98 LinkS22(const LinkS22&) = delete;
99 LinkS22& operator=(const LinkS22&) = delete;
100 ~LinkS22() = default;
102 void apply_event(profile::Event* event, double value) override;
103 void set_bandwidth(double value) override;
104 void set_latency(double value) override;
110 class S22Action : public DiskAction {
111 const s4u::Host* src_host_;
112 const DiskImpl* src_disk_;
113 const s4u::Host* dst_host_;
114 const DiskImpl* dst_disk_;
121 friend DiskAction* DiskS22::io_start(sg_size_t size, s4u::Io::OpType type);
122 friend Action* NetworkS22Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
124 double calculate_io_read_bound() const;
125 double calculate_io_write_bound() const;
128 * @brief Calculate the network bound for the parallel task
130 * The network bound depends on the largest latency between the communication in the ptask.
131 * Return MAX_DOUBLE if latency is 0 (or ptask doesn't have any communication)
133 double calculate_network_bound() const;
136 S22Action() = delete;
137 S22Action(Model* model, s4u::Host* src_host, DiskImpl* src_disk, s4u::Host* dst_host, DiskImpl* dst_disk, double size);
138 S22Action(const S22Action&) = delete;
139 S22Action& operator=(const S22Action&) = delete;
140 ~S22Action() = default;
142 void update_bound() const;
143 double get_latency() const { return latency_; }
144 void set_latency(double latency) { latency_ = latency; }
145 void update_latency(double delta, double precision) { double_update(&latency_, delta, precision); }
148 } // namespace simgrid::kernel::resource
150 #endif /* SIO_S22_HPP_ */