Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / surf / ptask_L07.hpp
1 /* Copyright (c) 2013-2017. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <cstdlib>
8 #include <vector>
9 #include <xbt/base.h>
10 #include "src/surf/HostImpl.hpp"
11
12 #ifndef HOST_L07_HPP_
13 #define HOST_L07_HPP_
14
15 namespace simgrid {
16 namespace surf {
17
18 /***********
19  * Classes *
20  ***********/
21
22 class XBT_PRIVATE HostL07Model;
23 class XBT_PRIVATE CpuL07Model;
24 class XBT_PRIVATE NetworkL07Model;
25
26 class XBT_PRIVATE CpuL07;
27 class XBT_PRIVATE LinkL07;
28
29 class XBT_PRIVATE L07Action;
30 /*********
31  * Tools *
32  *********/
33
34 /*********
35  * Model *
36  *********/
37 class HostL07Model : public HostModel {
38 public:
39   HostL07Model();
40   ~HostL07Model();
41
42   double nextOccuringEvent(double now) override;
43   void updateActionsState(double now, double delta) override;
44   Action *executeParallelTask(int host_nb, sg_host_t *host_list,
45                               double *flops_amount, double *bytes_amount, double rate) override;
46 };
47
48 class CpuL07Model : public CpuModel {
49 public:
50   CpuL07Model(HostL07Model* hmodel, lmm_system_t sys);
51   ~CpuL07Model();
52
53   Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
54   HostL07Model *hostModel_;
55 };
56
57 class NetworkL07Model : public NetworkModel {
58 public:
59   NetworkL07Model(HostL07Model* hmodel, lmm_system_t sys);
60   ~NetworkL07Model();
61   LinkImpl* createLink(const std::string& name, double bandwidth, double latency,
62                        e_surf_link_sharing_policy_t policy) override;
63
64   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
65
66   HostL07Model *hostModel_;
67 };
68
69 /************
70  * Resource *
71  ************/
72
73 class CpuL07 : public Cpu {
74 public:
75   CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector<double> * speedPerPstate, int core);
76   ~CpuL07() override;
77   bool isUsed() override;
78   void apply_event(tmgr_trace_event_t event, double value) override;
79   Action* execution_start(double size) override;
80   Action* sleep(double duration) override;
81
82 protected:
83   void onSpeedChange() override;
84 };
85
86 class LinkL07 : public LinkImpl {
87 public:
88   LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency,
89           e_surf_link_sharing_policy_t policy);
90   ~LinkL07() override;
91   bool isUsed() override;
92   void apply_event(tmgr_trace_event_t event, double value) override;
93   void setBandwidth(double value) override;
94   void setLatency(double value) override;
95 };
96
97 /**********
98  * Action *
99  **********/
100 class L07Action : public CpuAction {
101   friend Action *CpuL07::execution_start(double size);
102   friend Action *CpuL07::sleep(double duration);
103   friend Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t*host_list,
104                                                    double *flops_amount, double *bytes_amount, double rate);
105 public:
106   L07Action(Model *model, int host_nb, sg_host_t *host_list, double *flops_amount, 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_ */