Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
also change the namespace of kernel/resource/{Action,Model}
[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 nextOccuringEvent(double now) override;
42   void updateActionsState(double now, double delta) override;
43   kernel::resource::Action* executeParallelTask(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, lmm_system_t 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 NetworkModel {
57 public:
58   NetworkL07Model(HostL07Model* hmodel, lmm_system_t sys);
59   ~NetworkL07Model();
60   LinkImpl* createLink(const std::string& name, double bandwidth, double latency,
61                        e_surf_link_sharing_policy_t 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 isUsed() override;
77   void apply_event(tmgr_trace_event_t event, double value) override;
78   kernel::resource::Action* execution_start(double size) override;
79   kernel::resource::Action* sleep(double duration) override;
80
81 protected:
82   void onSpeedChange() override;
83 };
84
85 class LinkL07 : public LinkImpl {
86 public:
87   LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency,
88           e_surf_link_sharing_policy_t policy);
89   ~LinkL07() override;
90   bool isUsed() override;
91   void apply_event(tmgr_trace_event_t event, double value) override;
92   void setBandwidth(double value) override;
93   void setLatency(double value) override;
94 };
95
96 /**********
97  * Action *
98  **********/
99 class L07Action : public CpuAction {
100   friend Action *CpuL07::execution_start(double size);
101   friend Action *CpuL07::sleep(double duration);
102   friend Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t*host_list,
103                                                    double *flops_amount, double *bytes_amount, double rate);
104 public:
105   L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* host_list, double* flops_amount,
106             double* bytes_amount, double rate);
107   ~L07Action();
108
109   void updateBound();
110
111   int unref() override;
112
113   std::vector<s4u::Host*>* hostList_ = new std::vector<s4u::Host*>();
114   double *computationAmount_;
115   double *communicationAmount_;
116   double latency_;
117   double rate_;
118 };
119
120 }
121 }
122
123 #endif /* HOST_L07_HPP_ */