Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
no need to override stuff to the exact same content
[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,RoutingEdge *netElm, Cpu *cpu);
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 };
50
51 class CpuL07Model : public CpuModel {
52 public:
53   CpuL07Model(HostL07Model *hmodel) : CpuModel() {p_hostModel = hmodel;};
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(HostL07Model *hmodel) : NetworkModel() {p_hostModel = hmodel;};
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() {DIE_IMPOSSIBLE;};
96   void updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/) {DIE_IMPOSSIBLE;};
97   Action *execute(double size) {return p_cpu->execute(size);};
98   Action *sleep(double duration) {return p_cpu->sleep(duration);};
99   e_surf_resource_state_t getState();
100 };
101
102 class CpuL07 : public Cpu {
103   friend void HostL07Model::addTraces();
104   tmgr_trace_event_t p_stateEvent;
105   tmgr_trace_event_t p_powerEvent;
106 public:
107   CpuL07(CpuL07Model *model, const char* name, xbt_dict_t properties,
108                  double power_scale, double power_initial, tmgr_trace_t power_trace,
109      int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
110   bool isUsed();
111   void updateState(tmgr_trace_event_t event_type, double value, double date);
112   Action *execute(double size);
113   Action *sleep(double duration);
114
115   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
116   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
117   int getNbPstates() {THROW_UNIMPLEMENTED;};
118   void setPstate(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
119   int  getPstate() {THROW_UNIMPLEMENTED;};
120   double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
121 };
122
123 class LinkL07 : public Link {
124 public:
125   LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
126                   double bw_initial,
127           tmgr_trace_t bw_trace,
128           double lat_initial,
129           tmgr_trace_t lat_trace,
130           e_surf_resource_state_t
131           state_initial,
132           tmgr_trace_t state_trace,
133           e_surf_link_sharing_policy_t policy);
134   ~LinkL07(){
135   };
136   bool isUsed();
137   void updateState(tmgr_trace_event_t event_type, double value, double date);
138   double getBandwidth();
139   void updateBandwidth(double value, double date=surf_get_clock());
140   void updateLatency(double value, double date=surf_get_clock());
141
142   double m_bwCurrent;
143   tmgr_trace_event_t p_bwEvent;
144 };
145
146 /**********
147  * Action *
148  **********/
149 class L07Action : public HostAction {
150   friend Action *CpuL07::execute(double size);
151   friend Action *CpuL07::sleep(double duration);
152   friend Action *HostL07Model::executeParallelTask(int host_nb,
153                                                    sg_host_t*host_list,
154                                                    double *flops_amount,
155                                                                                                    double *bytes_amount,
156                                                    double rate);
157 public:
158   L07Action(Model *model, double cost, bool failed)
159   : HostAction(model, cost, failed) {};
160  ~L07Action();
161
162   void updateBound();
163
164   int unref();
165   void cancel();
166   void suspend();
167   void resume();
168   bool isSuspended();
169   void setMaxDuration(double duration);
170   void setPriority(double priority);
171   double getRemains();
172
173   vector<RoutingEdge*> * p_edgeList = new vector<RoutingEdge*>();
174   double *p_computationAmount;
175   double *p_communicationAmount;
176   double m_latency;
177   double m_rate;
178 };
179
180 #endif /* HOST_L07_HPP_ */