Logo AND Algorithmique Numérique Distribuée

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