Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add more callbacks
[simgrid.git] / src / surf / workstation_ptask_L07.hpp
1 #include "workstation_interface.hpp"
2
3 #ifndef WORKSTATION_L07_HPP_
4 #define WORKSTATION_L07_HPP_
5
6 /***********
7  * Classes *
8  ***********/
9
10 class WorkstationL07Model;
11 typedef WorkstationL07Model *WorkstationL07ModelPtr;
12
13 class CpuL07Model;
14 typedef CpuL07Model *CpuL07ModelPtr;
15
16 class NetworkL07Model;
17 typedef NetworkL07Model *NetworkL07ModelPtr;
18
19 class WorkstationL07;
20 typedef WorkstationL07 *WorkstationL07Ptr;
21
22 class CpuL07;
23 typedef CpuL07 *CpuL07Ptr;
24
25 class LinkL07;
26 typedef LinkL07 *LinkL07Ptr;
27
28 class WorkstationL07Action;
29 typedef WorkstationL07Action *WorkstationL07ActionPtr;
30
31 /*********
32  * Tools *
33  *********/
34
35 /*********
36  * Model *
37  *********/
38 class WorkstationL07Model : public WorkstationModel {
39 public:
40   WorkstationL07Model();
41   ~WorkstationL07Model();
42
43   double shareResources(double now);
44   void updateActionsState(double now, double delta);
45   ResourcePtr createResource(const char *name, double power_scale,
46                                  double power_initial,
47                                  tmgr_trace_t power_trace,
48                                  e_surf_resource_state_t state_initial,
49                                  tmgr_trace_t state_trace,
50                                  xbt_dict_t cpu_properties);
51   ActionPtr executeParallelTask(int workstation_nb,
52                                         void **workstation_list,
53                                         double *computation_amount,
54                                         double *communication_amount,
55                                         double rate);
56   xbt_dynar_t getRoute(WorkstationPtr src, WorkstationPtr dst);
57   ActionPtr communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate);
58   void addTraces();
59   NetworkModelPtr p_networkModel;
60 };
61
62 class CpuL07Model : public CpuModel {
63 public:
64   CpuL07Model() : CpuModel("cpuL07") {};
65   ~CpuL07Model() {surf_cpu_model_pm = NULL;};
66   ResourcePtr createResource(const char *name, double power_scale,
67                                  double power_initial,
68                                  tmgr_trace_t power_trace,
69                                  e_surf_resource_state_t state_initial,
70                                  tmgr_trace_t state_trace,
71                                  xbt_dict_t cpu_properties);
72   void addTraces() {DIE_IMPOSSIBLE;};
73
74   WorkstationL07ModelPtr p_workstationModel;
75 };
76
77 class NetworkL07Model : public NetworkModel {
78 public:
79   NetworkL07Model() : NetworkModel() {};
80   ~NetworkL07Model() {surf_network_model = NULL;};
81   NetworkLinkPtr createResource(const char *name,
82                                                    double bw_initial,
83                                                    tmgr_trace_t bw_trace,
84                                                    double lat_initial,
85                                                    tmgr_trace_t lat_trace,
86                                                    e_surf_resource_state_t
87                                                    state_initial,
88                                                    tmgr_trace_t state_trace,
89                                                    e_surf_link_sharing_policy_t
90                                                    policy, xbt_dict_t properties);
91
92   ActionPtr communicate(RoutingEdgePtr /*src*/, RoutingEdgePtr /*dst*/, double /*size*/, double /*rate*/) {DIE_IMPOSSIBLE;};
93   void addTraces() {DIE_IMPOSSIBLE;};
94   WorkstationL07ModelPtr p_workstationModel;
95 };
96
97 /************
98  * Resource *
99  ************/
100
101 class WorkstationL07 : public Workstation {
102 public:
103   WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu);
104   //bool isUsed();
105   bool isUsed() {DIE_IMPOSSIBLE;};
106   void updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/) {DIE_IMPOSSIBLE;};
107   ActionPtr execute(double size);
108   ActionPtr sleep(double duration);
109   e_surf_resource_state_t getState();
110   double getPowerPeakAt(int pstate_index);
111   int getNbPstates();
112   void setPowerPeakAt(int pstate_index);
113   double getConsumedEnergy();
114 };
115
116 class CpuL07 : public Cpu {
117 public:
118   s_surf_metric_t p_power;
119   tmgr_trace_event_t p_stateEvent;
120
121 public:
122   CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties,
123                  double power_scale,
124                  double power_initial, tmgr_trace_t power_trace,
125                  e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
126   bool isUsed();
127   //bool isUsed() {DIE_IMPOSSIBLE;};
128   void updateState(tmgr_trace_event_t event_type, double value, double date);
129   double getSpeed(double load);
130   double getAvailableSpeed();
131   CpuActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};
132   CpuActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
133
134   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
135   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
136   int getNbPstates() {THROW_UNIMPLEMENTED;};
137   void setPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
138   double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
139
140   double m_powerCurrent;
141 };
142
143 class LinkL07 : public NetworkLink {
144 public:
145   LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
146                   double bw_initial,
147           tmgr_trace_t bw_trace,
148           double lat_initial,
149           tmgr_trace_t lat_trace,
150           e_surf_resource_state_t
151           state_initial,
152           tmgr_trace_t state_trace,
153           e_surf_link_sharing_policy_t policy);
154   ~LinkL07(){
155   };
156   bool isUsed();
157   void updateState(tmgr_trace_event_t event_type, double value, double date);
158   double getBandwidth();
159   double getLatency();
160   bool isShared();
161
162   double m_latCurrent;
163   tmgr_trace_event_t p_latEvent;
164   double m_bwCurrent;
165   tmgr_trace_event_t p_bwEvent;
166 };
167
168 /**********
169  * Action *
170  **********/
171 class WorkstationL07Action : public WorkstationAction {
172   friend ActionPtr WorkstationL07::execute(double size);
173   friend ActionPtr WorkstationL07::sleep(double duration);
174   friend ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
175                                                      void **workstation_list,
176                                                    double
177                                                    *computation_amount, double
178                                                    *communication_amount,
179                                                    double rate);
180 public:
181   WorkstationL07Action(ModelPtr model, double cost, bool failed)
182   : WorkstationAction(model, cost, failed) {};
183  ~WorkstationL07Action();
184
185   void updateBound();
186
187   int unref();
188   void cancel();
189   void suspend();
190   void resume();
191   bool isSuspended();
192   void setMaxDuration(double duration);
193   void setPriority(double priority);
194   double getRemains();
195
196   int m_workstationNb;
197   WorkstationPtr *p_workstationList;
198   double *p_computationAmount;
199   double *p_communicationAmount;
200   double m_latency;
201   double m_rate;
202 };
203
204 #endif /* WORKSTATION_L07_HPP_ */