Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove XBT_INFO call
[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   void addTraces() {DIE_IMPOSSIBLE;};
79
80   WorkstationL07ModelPtr p_workstationModel;
81 };
82
83 class NetworkL07Model : public NetworkModel {
84 public:
85   NetworkL07Model() : NetworkModel() {};
86   ~NetworkL07Model() {surf_network_model = NULL;};
87   NetworkLinkPtr createResource(const char *name,
88                                                    double bw_initial,
89                                                    tmgr_trace_t bw_trace,
90                                                    double lat_initial,
91                                                    tmgr_trace_t lat_trace,
92                                                    e_surf_resource_state_t
93                                                    state_initial,
94                                                    tmgr_trace_t state_trace,
95                                                    e_surf_link_sharing_policy_t
96                                                    policy, xbt_dict_t properties);
97
98   ActionPtr communicate(RoutingEdgePtr /*src*/, RoutingEdgePtr /*dst*/, double /*size*/, double /*rate*/) {DIE_IMPOSSIBLE;};
99   void addTraces() {DIE_IMPOSSIBLE;};
100   WorkstationL07ModelPtr p_workstationModel;
101 };
102
103 /************
104  * Resource *
105  ************/
106
107 class WorkstationL07 : public Workstation {
108 public:
109   WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu);
110   //bool isUsed();
111   bool isUsed() {DIE_IMPOSSIBLE;};
112   void updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/) {DIE_IMPOSSIBLE;};
113   ActionPtr execute(double size);
114   ActionPtr sleep(double duration);
115   e_surf_resource_state_t getState();
116   double getPowerPeakAt(int pstate_index);
117   int getNbPstates();
118   void setPowerPeakAt(int pstate_index);
119   double getConsumedEnergy();
120 };
121
122 class CpuL07 : public Cpu {
123 public:
124   s_surf_metric_t p_power;
125   tmgr_trace_event_t p_stateEvent;
126
127 public:
128   CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties,
129                  double power_scale,
130                  double power_initial, tmgr_trace_t power_trace,
131                  e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
132   bool isUsed();
133   //bool isUsed() {DIE_IMPOSSIBLE;};
134   void updateState(tmgr_trace_event_t event_type, double value, double date);
135   double getSpeed(double load);
136   double getAvailableSpeed();
137   CpuActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};
138   CpuActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
139
140   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
141   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
142   int getNbPstates() {THROW_UNIMPLEMENTED;};
143   void setPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
144   double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
145
146   double m_powerCurrent;
147 };
148
149 class LinkL07 : public NetworkLink {
150 public:
151   LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
152                   double bw_initial,
153           tmgr_trace_t bw_trace,
154           double lat_initial,
155           tmgr_trace_t lat_trace,
156           e_surf_resource_state_t
157           state_initial,
158           tmgr_trace_t state_trace,
159           e_surf_link_sharing_policy_t policy);
160   ~LinkL07(){
161   };
162   bool isUsed();
163   void updateState(tmgr_trace_event_t event_type, double value, double date);
164   double getBandwidth();
165   double getLatency();
166   bool isShared();
167
168   double m_latCurrent;
169   tmgr_trace_event_t p_latEvent;
170   double m_bwCurrent;
171   tmgr_trace_event_t p_bwEvent;
172 };
173
174 /**********
175  * Action *
176  **********/
177 class WorkstationL07Action : public WorkstationAction {
178   friend ActionPtr WorkstationL07::execute(double size);
179   friend ActionPtr WorkstationL07::sleep(double duration);
180   friend ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
181                                                      void **workstation_list,
182                                                    double
183                                                    *computation_amount, double
184                                                    *communication_amount,
185                                                    double rate);
186 public:
187   WorkstationL07Action(ModelPtr model, double cost, bool failed)
188   : WorkstationAction(model, cost, failed) {};
189  ~WorkstationL07Action();
190
191   void updateBound();
192
193   int unref();
194   void cancel();
195   void suspend();
196   void resume();
197   bool isSuspended();
198   void setMaxDuration(double duration);
199   void setPriority(double priority);
200   double getRemains();
201
202   int m_workstationNb;
203   WorkstationPtr *p_workstationList;
204   double *p_computationAmount;
205   double *p_communicationAmount;
206   double m_latency;
207   double m_rate;
208 };
209
210 #endif /* WORKSTATION_L07_HPP_ */