Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Initial support MC record/replay
[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   WorkstationPtr createWorkstation(const char *name);
52   ActionPtr executeParallelTask(int workstation_nb,
53                                         void **workstation_list,
54                                         double *computation_amount,
55                                         double *communication_amount,
56                                         double rate);
57   xbt_dynar_t getRoute(WorkstationPtr src, WorkstationPtr dst);
58   ActionPtr communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate);
59   void addTraces();
60   NetworkModelPtr p_networkModel;
61 };
62
63 class CpuL07Model : public CpuModel {
64 public:
65   CpuL07Model() : CpuModel("cpuL07") {};
66   ~CpuL07Model() {surf_cpu_model_pm = NULL;};
67   CpuPtr createCpu(const char *name,  xbt_dynar_t powerPeak,
68                           int pstate, double power_scale,
69                           tmgr_trace_t power_trace, int core,
70                           e_surf_resource_state_t state_initial,
71                           tmgr_trace_t state_trace,
72                           xbt_dict_t cpu_properties);
73   void addTraces() {DIE_IMPOSSIBLE;};
74
75   WorkstationL07ModelPtr p_workstationModel;
76 };
77
78 class NetworkL07Model : public NetworkModel {
79 public:
80   NetworkL07Model() : NetworkModel() {};
81   ~NetworkL07Model() {surf_network_model = NULL;};
82   NetworkLinkPtr createNetworkLink(const char *name,
83                                                    double bw_initial,
84                                                    tmgr_trace_t bw_trace,
85                                                    double lat_initial,
86                                                    tmgr_trace_t lat_trace,
87                                                    e_surf_resource_state_t
88                                                    state_initial,
89                                                    tmgr_trace_t state_trace,
90                                                    e_surf_link_sharing_policy_t
91                                                    policy, xbt_dict_t properties);
92
93   ActionPtr communicate(RoutingEdgePtr /*src*/, RoutingEdgePtr /*dst*/, double /*size*/, double /*rate*/) {DIE_IMPOSSIBLE;};
94   void addTraces() {DIE_IMPOSSIBLE;};
95   WorkstationL07ModelPtr p_workstationModel;
96 };
97
98 /************
99  * Resource *
100  ************/
101
102 class WorkstationL07 : public Workstation {
103 public:
104   WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu);
105   //bool isUsed();
106   bool isUsed() {DIE_IMPOSSIBLE;};
107   void updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/) {DIE_IMPOSSIBLE;};
108   ActionPtr execute(double size);
109   ActionPtr sleep(double duration);
110   e_surf_resource_state_t getState();
111   double getPowerPeakAt(int pstate_index);
112   int getNbPstates();
113   void setPowerPeakAt(int pstate_index);
114   double getConsumedEnergy();
115 };
116
117 class CpuL07 : public Cpu {
118   friend void WorkstationL07Model::addTraces();
119   tmgr_trace_event_t p_stateEvent;
120   tmgr_trace_event_t p_powerEvent;
121 public:
122   CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties,
123                  double power_scale, double power_initial, tmgr_trace_t power_trace,
124      int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
125   bool isUsed();
126   //bool isUsed() {DIE_IMPOSSIBLE;};
127   void updateState(tmgr_trace_event_t event_type, double value, double date);
128   CpuActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};
129   CpuActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
130
131   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
132   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
133   int getNbPstates() {THROW_UNIMPLEMENTED;};
134   void setPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
135   double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
136 };
137
138 class LinkL07 : public NetworkLink {
139 public:
140   LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
141                   double bw_initial,
142           tmgr_trace_t bw_trace,
143           double lat_initial,
144           tmgr_trace_t lat_trace,
145           e_surf_resource_state_t
146           state_initial,
147           tmgr_trace_t state_trace,
148           e_surf_link_sharing_policy_t policy);
149   ~LinkL07(){
150   };
151   bool isUsed();
152   void updateState(tmgr_trace_event_t event_type, double value, double date);
153   double getBandwidth();
154   double getLatency();
155   bool isShared();
156   void updateBandwidth(double value, double date=surf_get_clock());
157   void updateLatency(double value, double date=surf_get_clock());
158
159   double m_latCurrent;
160   tmgr_trace_event_t p_latEvent;
161   double m_bwCurrent;
162   tmgr_trace_event_t p_bwEvent;
163 };
164
165 /**********
166  * Action *
167  **********/
168 class WorkstationL07Action : public WorkstationAction {
169   friend ActionPtr WorkstationL07::execute(double size);
170   friend ActionPtr WorkstationL07::sleep(double duration);
171   friend ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
172                                                      void **workstation_list,
173                                                    double
174                                                    *computation_amount, double
175                                                    *communication_amount,
176                                                    double rate);
177 public:
178   WorkstationL07Action(ModelPtr model, double cost, bool failed)
179   : WorkstationAction(model, cost, failed) {};
180  ~WorkstationL07Action();
181
182   void updateBound();
183
184   int unref();
185   void cancel();
186   void suspend();
187   void resume();
188   bool isSuspended();
189   void setMaxDuration(double duration);
190   void setPriority(double priority);
191   double getRemains();
192
193   int m_workstationNb;
194   WorkstationPtr *p_workstationList;
195   double *p_computationAmount;
196   double *p_communicationAmount;
197   double m_latency;
198   double m_rate;
199 };
200
201 #endif /* WORKSTATION_L07_HPP_ */