Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
inline two static functions
[simgrid.git] / src / surf / host_ptask_L07.hpp
1 /* Copyright (c) 2013-2014. 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 "host_interface.hpp"
8
9 #ifndef HOST_L07_HPP_
10 #define HOST_L07_HPP_
11
12 /***********
13  * Classes *
14  ***********/
15
16 class HostL07Model;
17 class CpuL07Model;
18 class NetworkL07Model;
19
20 class HostL07;
21 class CpuL07;
22 class LinkL07;
23
24 class L07Action;
25
26 /*********
27  * Tools *
28  *********/
29
30 /*********
31  * Model *
32  *********/
33 class HostL07Model : public HostModel {
34 public:
35   HostL07Model();
36   ~HostL07Model();
37
38   double shareResources(double now);
39   void updateActionsState(double now, double delta);
40   Host *createHost(const char *name);
41   Action *executeParallelTask(int host_nb,
42                                         void **host_list,
43                                         double *flops_amount,
44                                         double *bytes_amount,
45                                         double rate);
46   xbt_dynar_t getRoute(Host *src, Host *dst);
47   Action *communicate(Host *src, Host *dst, double size, double rate);
48   void addTraces();
49   NetworkModel *p_networkModel;
50 };
51
52 class CpuL07Model : public CpuModel {
53 public:
54   CpuL07Model() : CpuModel("cpuL07") {};
55   ~CpuL07Model() {surf_cpu_model_pm = NULL;};
56   Cpu *createCpu(const char *name,  xbt_dynar_t powerPeak,
57                           int pstate, double power_scale,
58                           tmgr_trace_t power_trace, int core,
59                           e_surf_resource_state_t state_initial,
60                           tmgr_trace_t state_trace,
61                           xbt_dict_t cpu_properties);
62   void addTraces() {DIE_IMPOSSIBLE;};
63
64   HostL07Model *p_hostModel;
65 };
66
67 class NetworkL07Model : public NetworkModel {
68 public:
69   NetworkL07Model() : NetworkModel() {};
70   ~NetworkL07Model() {surf_network_model = NULL;};
71   Link* createLink(const char *name,
72                                                    double bw_initial,
73                                                    tmgr_trace_t bw_trace,
74                                                    double lat_initial,
75                                                    tmgr_trace_t lat_trace,
76                                                    e_surf_resource_state_t
77                                                    state_initial,
78                                                    tmgr_trace_t state_trace,
79                                                    e_surf_link_sharing_policy_t
80                                                    policy, xbt_dict_t properties);
81
82   Action *communicate(RoutingEdge */*src*/, RoutingEdge */*dst*/, double /*size*/, double /*rate*/) {DIE_IMPOSSIBLE;};
83   void addTraces() {DIE_IMPOSSIBLE;};
84   HostL07Model *p_hostModel;
85 };
86
87 /************
88  * Resource *
89  ************/
90
91 class HostL07 : public Host {
92 public:
93   HostL07(HostModel *model, const char* name, xbt_dict_t props, RoutingEdge *netElm, Cpu *cpu);
94   //bool isUsed();
95   bool isUsed() {DIE_IMPOSSIBLE;};
96   void updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/) {DIE_IMPOSSIBLE;};
97   Action *execute(double size);
98   Action *sleep(double duration);
99   e_surf_resource_state_t getState();
100   double getPowerPeakAt(int pstate_index);
101   int getNbPstates();
102   void setPstate(int pstate_index);
103   int  getPstate();
104   double getConsumedEnergy();
105 };
106
107 class CpuL07 : public Cpu {
108   friend void HostL07Model::addTraces();
109   tmgr_trace_event_t p_stateEvent;
110   tmgr_trace_event_t p_powerEvent;
111 public:
112   CpuL07(CpuL07Model *model, const char* name, xbt_dict_t properties,
113                  double power_scale, double power_initial, tmgr_trace_t power_trace,
114      int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
115   bool isUsed();
116   //bool isUsed() {DIE_IMPOSSIBLE;};
117   void updateState(tmgr_trace_event_t event_type, double value, double date);
118   CpuAction *execute(double /*size*/) {DIE_IMPOSSIBLE;};
119   CpuAction *sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
120
121   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
122   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
123   int getNbPstates() {THROW_UNIMPLEMENTED;};
124   void setPstate(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
125   int  getPstate() {THROW_UNIMPLEMENTED;};
126   double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
127 };
128
129 class LinkL07 : public Link {
130 public:
131   LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
132                   double bw_initial,
133           tmgr_trace_t bw_trace,
134           double lat_initial,
135           tmgr_trace_t lat_trace,
136           e_surf_resource_state_t
137           state_initial,
138           tmgr_trace_t state_trace,
139           e_surf_link_sharing_policy_t policy);
140   ~LinkL07(){
141   };
142   bool isUsed();
143   void updateState(tmgr_trace_event_t event_type, double value, double date);
144   double getBandwidth();
145   double getLatency();
146   bool isShared();
147   void updateBandwidth(double value, double date=surf_get_clock());
148   void updateLatency(double value, double date=surf_get_clock());
149
150   double m_latCurrent;
151   tmgr_trace_event_t p_latEvent;
152   double m_bwCurrent;
153   tmgr_trace_event_t p_bwEvent;
154 };
155
156 /**********
157  * Action *
158  **********/
159 class L07Action : public HostAction {
160   friend Action *HostL07::execute(double size);
161   friend Action *HostL07::sleep(double duration);
162   friend Action *HostL07Model::executeParallelTask(int host_nb,
163                                                      void **host_list,
164                                                    double *flops_amount,
165                                                                                                    double *bytes_amount,
166                                                    double rate);
167 public:
168   L07Action(Model *model, double cost, bool failed)
169   : HostAction(model, cost, failed) {};
170  ~L07Action();
171
172   void updateBound();
173
174   int unref();
175   void cancel();
176   void suspend();
177   void resume();
178   bool isSuspended();
179   void setMaxDuration(double duration);
180   void setPriority(double priority);
181   double getRemains();
182
183   vector<RoutingEdge*> * p_edgeList = new vector<RoutingEdge*>();
184   double *p_computationAmount;
185   double *p_communicationAmount;
186   double m_latency;
187   double m_rate;
188 };
189
190 #endif /* HOST_L07_HPP_ */