Logo AND Algorithmique Numérique Distribuée

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