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,
44 double size) override;
47 class DiskS22Model : public DiskModel {
49 DiskS22Model(const std::string& name, HostS22Model* hmodel, lmm::System* sys);
50 DiskS22Model(const DiskS22Model&) = delete;
51 DiskS22Model& operator=(const DiskS22Model&) = delete;
52 ~DiskS22Model() override;
53 void update_actions_state(double /*now*/, double /*delta*/) override{
54 /* this action is done by HostS22Model which shares the LMM system with the Disk model
55 * Overriding to an empty function here allows us to handle the DiskS22Model as a regular
56 * method in EngineImpl::presolve */
59 DiskImpl* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth) override;
60 HostS22Model* hostModel_;
63 class NetworkS22Model : public NetworkModel {
65 NetworkS22Model(const std::string& name, HostS22Model* hmodel, lmm::System* sys);
66 NetworkS22Model(const NetworkS22Model&) = delete;
67 NetworkS22Model& operator=(const NetworkS22Model&) = delete;
68 ~NetworkS22Model() override;
69 StandardLinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths) final;
70 StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths) override;
72 Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
73 void update_actions_state(double /*now*/, double /*delta*/) override{
74 /* this action is done by HostS22Model which shares the LMM system with the Network model
75 * Overriding to an empty function here allows us to handle the NetworkS22Model as a regular
76 * method in EngineImpl::presolve */
79 HostS22Model* hostModel_;
86 class DiskS22 : public DiskImpl {
88 using DiskImpl::DiskImpl;
89 DiskS22(const DiskS22&) = delete;
90 DiskS22& operator=(const DiskS22&) = delete;
92 void apply_event(profile::Event* event, double value) override;
93 DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) override;
96 class LinkS22 : public StandardLinkImpl {
98 LinkS22(const std::string& name, double bandwidth, lmm::System* system);
99 LinkS22(const LinkS22&) = delete;
100 LinkS22& operator=(const LinkS22&) = delete;
101 ~LinkS22() = default;
103 void apply_event(profile::Event* event, double value) override;
104 void set_bandwidth(double value) override;
105 void set_latency(double value) override;
112 class S22Action : public DiskAction {
113 const s4u::Host* src_host_;
114 const DiskImpl* src_disk_;
115 const s4u::Host* dst_host_;
116 const DiskImpl* dst_disk_;
122 friend DiskAction* DiskS22::io_start(sg_size_t size, s4u::Io::OpType type);
123 friend Action* NetworkS22Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
125 double calculate_io_read_bound() const;
126 double calculate_io_write_bound() const;
129 * @brief Calculate the network bound for the parallel task
131 * The network bound depends on the largest latency between the communication in the ptask.
132 * Return MAX_DOUBLE if latency is 0 (or ptask doesn't have any communication)
134 double calculate_network_bound() const;
137 S22Action() = delete;
138 S22Action(Model* model, s4u::Host* src_host, DiskImpl* src_disk, s4u::Host* dst_host, DiskImpl* dst_disk, double size);
139 S22Action(const S22Action&) = delete;
140 S22Action& operator=(const S22Action&) = delete;
141 ~S22Action() = default;
143 void update_bound() const;
144 double get_latency() const { return latency_; }
145 void set_latency(double latency) { latency_ = latency; }
146 void update_latency(double delta, double precision) { double_update(&latency_, delta, precision); }
149 } // namespace simgrid::kernel::resource
151 #endif /* SIO_S22_HPP_ */