Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill LinkPtr type and make Link* explicit
[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 typedef HostL07Model *HostL07ModelPtr;
18
19 class CpuL07Model;
20 typedef CpuL07Model *CpuL07ModelPtr;
21
22 class NetworkL07Model;
23 typedef NetworkL07Model *NetworkL07ModelPtr;
24
25 class HostL07;
26 typedef HostL07 *HostL07Ptr;
27
28 class CpuL07;
29 typedef CpuL07 *CpuL07Ptr;
30
31 class LinkL07;
32 typedef LinkL07 *LinkL07Ptr;
33
34 class HostL07Action;
35 typedef HostL07Action *HostL07ActionPtr;
36
37 /*********
38  * Tools *
39  *********/
40
41 /*********
42  * Model *
43  *********/
44 class HostL07Model : public HostModel {
45 public:
46   HostL07Model();
47   ~HostL07Model();
48
49   double shareResources(double now);
50   void updateActionsState(double now, double delta);
51   HostPtr createHost(const char *name);
52   ActionPtr executeParallelTask(int host_nb,
53                                         void **host_list,
54                                         double *flops_amount,
55                                         double *bytes_amount,
56                                         double rate);
57   xbt_dynar_t getRoute(HostPtr src, HostPtr dst);
58   ActionPtr communicate(HostPtr src, HostPtr 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   HostL07ModelPtr p_hostModel;
76 };
77
78 class NetworkL07Model : public NetworkModel {
79 public:
80   NetworkL07Model() : NetworkModel() {};
81   ~NetworkL07Model() {surf_network_model = NULL;};
82   Link* createLink(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   HostL07ModelPtr p_hostModel;
96 };
97
98 /************
99  * Resource *
100  ************/
101
102 class HostL07 : public Host {
103 public:
104   HostL07(HostModelPtr 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 setPstate(int pstate_index);
114   int  getPstate();
115   double getConsumedEnergy();
116 };
117
118 class CpuL07 : public Cpu {
119   friend void HostL07Model::addTraces();
120   tmgr_trace_event_t p_stateEvent;
121   tmgr_trace_event_t p_powerEvent;
122 public:
123   CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties,
124                  double power_scale, double power_initial, tmgr_trace_t power_trace,
125      int core, 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   CpuActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};
130   CpuActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
131
132   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
133   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
134   int getNbPstates() {THROW_UNIMPLEMENTED;};
135   void setPstate(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
136   int  getPstate() {THROW_UNIMPLEMENTED;};
137   double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
138 };
139
140 class LinkL07 : public Link {
141 public:
142   LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
143                   double bw_initial,
144           tmgr_trace_t bw_trace,
145           double lat_initial,
146           tmgr_trace_t lat_trace,
147           e_surf_resource_state_t
148           state_initial,
149           tmgr_trace_t state_trace,
150           e_surf_link_sharing_policy_t policy);
151   ~LinkL07(){
152   };
153   bool isUsed();
154   void updateState(tmgr_trace_event_t event_type, double value, double date);
155   double getBandwidth();
156   double getLatency();
157   bool isShared();
158   void updateBandwidth(double value, double date=surf_get_clock());
159   void updateLatency(double value, double date=surf_get_clock());
160
161   double m_latCurrent;
162   tmgr_trace_event_t p_latEvent;
163   double m_bwCurrent;
164   tmgr_trace_event_t p_bwEvent;
165 };
166
167 /**********
168  * Action *
169  **********/
170 class HostL07Action : public HostAction {
171   friend ActionPtr HostL07::execute(double size);
172   friend ActionPtr HostL07::sleep(double duration);
173   friend ActionPtr HostL07Model::executeParallelTask(int host_nb,
174                                                      void **host_list,
175                                                    double *flops_amount,
176                                                                                                    double *bytes_amount,
177                                                    double rate);
178 public:
179   HostL07Action(ModelPtr model, double cost, bool failed)
180   : HostAction(model, cost, failed) {};
181  ~HostL07Action();
182
183   void updateBound();
184
185   int unref();
186   void cancel();
187   void suspend();
188   void resume();
189   bool isSuspended();
190   void setMaxDuration(double duration);
191   void setPriority(double priority);
192   double getRemains();
193
194   int m_hostNb;
195   HostPtr *p_hostList;
196   double *p_computationAmount;
197   double *p_communicationAmount;
198   double m_latency;
199   double m_rate;
200 };
201
202 #endif /* HOST_L07_HPP_ */