Logo AND Algorithmique Numérique Distribuée

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