Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
51dd683548fc356949f6bb0c95c577f1e3eabf25
[simgrid.git] / src / surf / host_ptask_L07.hpp
1 /* Copyright (c) 2013-2015. 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 <xbt/base.h>
8
9 #include "host_interface.hpp"
10
11 #ifndef HOST_L07_HPP_
12 #define HOST_L07_HPP_
13
14 /***********
15  * Classes *
16  ***********/
17
18 class XBT_PRIVATE HostL07Model;
19 class XBT_PRIVATE CpuL07Model;
20 class XBT_PRIVATE NetworkL07Model;
21
22 class XBT_PRIVATE HostL07;
23 class XBT_PRIVATE CpuL07;
24 class XBT_PRIVATE LinkL07;
25
26 class XBT_PRIVATE L07Action;
27
28 /*********
29  * Tools *
30  *********/
31
32 /*********
33  * Model *
34  *********/
35 class HostL07Model : public HostModel {
36 public:
37   HostL07Model();
38   ~HostL07Model();
39
40   double shareResources(double now);
41   void updateActionsState(double now, double delta);
42   Host *createHost(const char *name);
43   Action *executeParallelTask(int host_nb,
44                               sg_host_t *host_list,
45                                                           double *flops_amount,
46                                                           double *bytes_amount,
47                                                           double rate);
48   xbt_dynar_t getRoute(Host *src, Host *dst);
49   void addTraces();
50   NetworkModel *p_networkModel;
51 };
52
53 class CpuL07Model : public CpuModel {
54 public:
55   CpuL07Model() : CpuModel() {};
56   ~CpuL07Model() {surf_cpu_model_pm = NULL;};
57   Cpu *createCpu(const char *name,  xbt_dynar_t powerPeak,
58                           int pstate, double power_scale,
59                           tmgr_trace_t power_trace, int core,
60                           e_surf_resource_state_t state_initial,
61                           tmgr_trace_t state_trace,
62                           xbt_dict_t cpu_properties);
63   void addTraces() {DIE_IMPOSSIBLE;};
64
65   HostL07Model *p_hostModel;
66 };
67
68 class NetworkL07Model : public NetworkModel {
69 public:
70   NetworkL07Model() : NetworkModel() {};
71   ~NetworkL07Model() {surf_network_model = NULL;};
72   Link* createLink(const char *name,
73                                                    double bw_initial,
74                                                    tmgr_trace_t bw_trace,
75                                                    double lat_initial,
76                                                    tmgr_trace_t lat_trace,
77                                                    e_surf_resource_state_t
78                                                    state_initial,
79                                                    tmgr_trace_t state_trace,
80                                                    e_surf_link_sharing_policy_t
81                                                    policy, xbt_dict_t properties);
82
83   Action *communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate);
84   void addTraces() {DIE_IMPOSSIBLE;};
85   bool shareResourcesIsIdempotent() {return true;}
86
87   HostL07Model *p_hostModel;
88 };
89
90 /************
91  * Resource *
92  ************/
93
94 class HostL07 : public Host {
95 public:
96   HostL07(HostModel *model, const char* name, xbt_dict_t props, RoutingEdge *netElm, Cpu *cpu);
97   //bool isUsed();
98   bool isUsed() {DIE_IMPOSSIBLE;};
99   void updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/) {DIE_IMPOSSIBLE;};
100   Action *execute(double size);
101   Action *sleep(double duration);
102   e_surf_resource_state_t getState();
103   double getPowerPeakAt(int pstate_index);
104   int getNbPstates();
105   void setPstate(int pstate_index);
106   int  getPstate();
107   double getConsumedEnergy();
108 };
109
110 class CpuL07 : public Cpu {
111   friend void HostL07Model::addTraces();
112   tmgr_trace_event_t p_stateEvent;
113   tmgr_trace_event_t p_powerEvent;
114 public:
115   CpuL07(CpuL07Model *model, const char* name, xbt_dict_t properties,
116                  double power_scale, double power_initial, tmgr_trace_t power_trace,
117      int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
118   bool isUsed();
119   //bool isUsed() {DIE_IMPOSSIBLE;};
120   void updateState(tmgr_trace_event_t event_type, double value, double date);
121   CpuAction *execute(double /*size*/) {DIE_IMPOSSIBLE;};
122   CpuAction *sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
123
124   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
125   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
126   int getNbPstates() {THROW_UNIMPLEMENTED;};
127   void setPstate(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
128   int  getPstate() {THROW_UNIMPLEMENTED;};
129   double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
130 };
131
132 class LinkL07 : public Link {
133 public:
134   LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
135                   double bw_initial,
136           tmgr_trace_t bw_trace,
137           double lat_initial,
138           tmgr_trace_t lat_trace,
139           e_surf_resource_state_t
140           state_initial,
141           tmgr_trace_t state_trace,
142           e_surf_link_sharing_policy_t policy);
143   ~LinkL07(){
144   };
145   bool isUsed();
146   void updateState(tmgr_trace_event_t event_type, double value, double date);
147   double getBandwidth();
148   double getLatency();
149   bool isShared();
150   void updateBandwidth(double value, double date=surf_get_clock());
151   void updateLatency(double value, double date=surf_get_clock());
152
153   double m_latCurrent;
154   tmgr_trace_event_t p_latEvent;
155   double m_bwCurrent;
156   tmgr_trace_event_t p_bwEvent;
157 };
158
159 /**********
160  * Action *
161  **********/
162 class L07Action : public HostAction {
163   friend Action *HostL07::execute(double size);
164   friend Action *HostL07::sleep(double duration);
165   friend Action *HostL07Model::executeParallelTask(int host_nb,
166                                                    sg_host_t*host_list,
167                                                    double *flops_amount,
168                                                                                                    double *bytes_amount,
169                                                    double rate);
170 public:
171   L07Action(Model *model, double cost, bool failed)
172   : HostAction(model, cost, failed) {};
173  ~L07Action();
174
175   void updateBound();
176
177   int unref();
178   void cancel();
179   void suspend();
180   void resume();
181   bool isSuspended();
182   void setMaxDuration(double duration);
183   void setPriority(double priority);
184   double getRemains();
185
186   vector<RoutingEdge*> * p_edgeList = new vector<RoutingEdge*>();
187   double *p_computationAmount;
188   double *p_communicationAmount;
189   double m_latency;
190   double m_rate;
191 };
192
193 #endif /* HOST_L07_HPP_ */