Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
snake_casing the dirty page tracking plugin
[simgrid.git] / src / surf / ptask_L07.hpp
1 /* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include <cstdlib>
7 #include <vector>
8 #include <xbt/base.h>
9 #include "src/surf/HostImpl.hpp"
10
11 #ifndef HOST_L07_HPP_
12 #define HOST_L07_HPP_
13
14 namespace simgrid {
15 namespace surf {
16
17 /***********
18  * Classes *
19  ***********/
20
21 class XBT_PRIVATE HostL07Model;
22 class XBT_PRIVATE CpuL07Model;
23 class XBT_PRIVATE NetworkL07Model;
24
25 class XBT_PRIVATE CpuL07;
26 class XBT_PRIVATE LinkL07;
27
28 class XBT_PRIVATE L07Action;
29 /*********
30  * Tools *
31  *********/
32
33 /*********
34  * Model *
35  *********/
36 class HostL07Model : public HostModel {
37 public:
38   HostL07Model();
39   ~HostL07Model();
40
41   double next_occuring_event(double now) override;
42   void update_actions_state(double now, double delta) override;
43   kernel::resource::Action* execute_parallel(int host_nb, sg_host_t* host_list, double* flops_amount,
44                                              double* bytes_amount, double rate) override;
45 };
46
47 class CpuL07Model : public CpuModel {
48 public:
49   CpuL07Model(HostL07Model* hmodel, kernel::lmm::System* sys);
50   ~CpuL07Model();
51
52   Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
53   HostL07Model *hostModel_;
54 };
55
56 class NetworkL07Model : public kernel::resource::NetworkModel {
57 public:
58   NetworkL07Model(HostL07Model* hmodel, kernel::lmm::System* sys);
59   ~NetworkL07Model();
60   kernel::resource::LinkImpl* createLink(const std::string& name, double bandwidth, double latency,
61                                          s4u::Link::SharingPolicy policy) override;
62
63   kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
64
65   HostL07Model *hostModel_;
66 };
67
68 /************
69  * Resource *
70  ************/
71
72 class CpuL07 : public Cpu {
73 public:
74   CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector<double> * speedPerPstate, int core);
75   ~CpuL07() override;
76   bool is_used() override;
77   void apply_event(tmgr_trace_event_t event, double value) override;
78   kernel::resource::Action* execution_start(double size) override;
79   simgrid::kernel::resource::Action* execution_start(double size, int requestedCores) override
80   {
81     THROW_UNIMPLEMENTED;
82     return nullptr;
83   }
84   kernel::resource::Action* sleep(double duration) override;
85
86 protected:
87   void onSpeedChange() override;
88 };
89
90 class LinkL07 : public kernel::resource::LinkImpl {
91 public:
92   LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency,
93           s4u::Link::SharingPolicy policy);
94   ~LinkL07() override;
95   bool is_used() override;
96   void apply_event(tmgr_trace_event_t event, double value) override;
97   void setBandwidth(double value) override;
98   void setLatency(double value) override;
99 };
100
101 /**********
102  * Action *
103  **********/
104 class L07Action : public CpuAction {
105   friend Action *CpuL07::execution_start(double size);
106   friend Action *CpuL07::sleep(double duration);
107   friend Action* HostL07Model::execute_parallel(int host_nb, sg_host_t* host_list, double* flops_amount,
108                                                 double* bytes_amount, double rate);
109
110 public:
111   L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* host_list, double* flops_amount,
112             double* bytes_amount, double rate);
113   ~L07Action();
114
115   void updateBound();
116
117   std::vector<s4u::Host*>* hostList_ = new std::vector<s4u::Host*>();
118   double *computationAmount_;
119   double *communicationAmount_;
120   double latency_;
121   double rate_;
122 };
123
124 }
125 }
126
127 #endif /* HOST_L07_HPP_ */