Logo AND Algorithmique Numérique Distribuée

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