Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #57 from fabienchaix/oldstyle_element_set
[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 namespace simgrid {
19 namespace surf {
20
21 /***********
22  * Classes *
23  ***********/
24
25 class XBT_PRIVATE HostL07Model;
26 class XBT_PRIVATE CpuL07Model;
27 class XBT_PRIVATE NetworkL07Model;
28
29 class XBT_PRIVATE HostL07;
30 class XBT_PRIVATE CpuL07;
31 class XBT_PRIVATE LinkL07;
32
33 class XBT_PRIVATE L07Action;
34 /*********
35  * Tools *
36  *********/
37
38 /*********
39  * Model *
40  *********/
41 class HostL07Model : public HostModel {
42 public:
43   HostL07Model();
44   ~HostL07Model();
45
46   double shareResources(double now) override;
47   void updateActionsState(double now, double delta) override;
48   Action *executeParallelTask(int host_nb, sg_host_t *host_list,
49                                                           double *flops_amount, double *bytes_amount,
50                                                           double rate) override;
51
52   void addTraces() override;
53 };
54
55 class CpuL07Model : public CpuModel {
56 public:
57   CpuL07Model(HostL07Model *hmodel,lmm_system_t sys);
58   ~CpuL07Model();
59
60   Cpu *createCpu(simgrid::s4u::Host *host,  xbt_dynar_t speedPeakList,
61                           int pstate, double speedScale,
62                           tmgr_trace_t speedTrace, int core,
63                           int initiallyOn,
64                           tmgr_trace_t state_trace) override;
65   void addTraces() override {DIE_IMPOSSIBLE;};
66
67   HostL07Model *p_hostModel;
68 };
69
70 class NetworkL07Model : public NetworkModel {
71 public:
72   NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys);
73   ~NetworkL07Model();
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                   int initiallyOn,
80                   tmgr_trace_t state_trace,
81                   e_surf_link_sharing_policy_t policy,
82                   xbt_dict_t properties) override;
83
84   Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
85   void addTraces() override {DIE_IMPOSSIBLE;};
86   bool shareResourcesIsIdempotent() override {return true;}
87
88   HostL07Model *p_hostModel;
89 };
90
91 /************
92  * Resource *
93  ************/
94
95 class CpuL07 : public Cpu {
96 public:
97   CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate,
98                  double power_scale, tmgr_trace_t power_trace,
99      int core, int initiallyOn, tmgr_trace_t state_trace);
100   ~CpuL07();
101   bool isUsed() override;
102   void updateState(tmgr_trace_iterator_t event_type, double value, double date) override;
103   Action *execution_start(double size) override;
104   Action *sleep(double duration) override;
105 protected:
106   void onSpeedChange() override;
107 };
108
109 class LinkL07 : public Link {
110 public:
111   LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
112                   double bw_initial,
113           tmgr_trace_t bw_trace,
114           double lat_initial,
115           tmgr_trace_t lat_trace,
116           int initiallyOn,
117           tmgr_trace_t state_trace,
118           e_surf_link_sharing_policy_t policy);
119   ~LinkL07(){ };
120   bool isUsed() override;
121   void updateState(tmgr_trace_iterator_t event_type, double value, double date) override;
122   double getBandwidth() override;
123   void updateBandwidth(double value, double date=surf_get_clock()) override;
124   void updateLatency(double value, double date=surf_get_clock()) override;
125
126   double m_bwCurrent;
127   tmgr_trace_iterator_t p_bwEvent;
128 };
129
130 /**********
131  * Action *
132  **********/
133 class L07Action : public CpuAction {
134   friend Action *CpuL07::execution_start(double size);
135   friend Action *CpuL07::sleep(double duration);
136   friend Action *HostL07Model::executeParallelTask(int host_nb,
137                                                    sg_host_t*host_list,
138                                                    double *flops_amount,
139                                                    double *bytes_amount,
140                                                    double rate);
141 public:
142   L07Action(Model *model, int host_nb,
143           sg_host_t*host_list,
144           double *flops_amount,
145                    double *bytes_amount,
146           double rate);
147  ~L07Action();
148
149   void updateBound();
150
151   int unref() override;
152
153   std::vector<NetCard*> * p_netcardList = new std::vector<NetCard*>();
154   double *p_computationAmount;
155   double *p_communicationAmount;
156   double m_latency;
157   double m_rate;
158 };
159
160 }
161 }
162
163 #endif /* HOST_L07_HPP_ */