Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove the last remainings of the addTraces() pimple \o/
[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 next_occuring_event(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
53 class CpuL07Model : public CpuModel {
54 public:
55   CpuL07Model(HostL07Model *hmodel,lmm_system_t sys);
56   ~CpuL07Model();
57
58   Cpu *createCpu(simgrid::s4u::Host *host,  xbt_dynar_t speedPeakList,
59                           int pstate, double speedScale,
60                           tmgr_trace_t speedTrace, int core,
61                           int initiallyOn,
62                           tmgr_trace_t state_trace) override;
63   HostL07Model *p_hostModel;
64 };
65
66 class NetworkL07Model : public NetworkModel {
67 public:
68   NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys);
69   ~NetworkL07Model();
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       int initiallyOn,
76       tmgr_trace_t state_trace,
77       e_surf_link_sharing_policy_t policy,
78       xbt_dict_t properties) override;
79
80   Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
81   bool next_occuring_event_isIdempotent() override {return true;}
82
83   HostL07Model *p_hostModel;
84 };
85
86 /************
87  * Resource *
88  ************/
89
90 class CpuL07 : public Cpu {
91 public:
92   CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate,
93      double power_scale, tmgr_trace_t power_trace,
94      int core, int initiallyOn, tmgr_trace_t state_trace);
95   ~CpuL07();
96   bool isUsed() override;
97   void apply_event(tmgr_trace_iterator_t event_type, double value) override;
98   Action *execution_start(double size) override;
99   Action *sleep(double duration) override;
100 protected:
101   void onSpeedChange() override;
102 };
103
104 class LinkL07 : public Link {
105 public:
106   LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
107       double bw_initial,
108           tmgr_trace_t bw_trace,
109           double lat_initial,
110           tmgr_trace_t lat_trace,
111           int initiallyOn,
112           tmgr_trace_t state_trace,
113           e_surf_link_sharing_policy_t policy);
114   ~LinkL07(){ };
115   bool isUsed() override;
116   void apply_event(tmgr_trace_iterator_t event_type, double value) override;
117   void updateBandwidth(double value) override;
118   void updateLatency(double value) override;
119 };
120
121 /**********
122  * Action *
123  **********/
124 class L07Action : public CpuAction {
125   friend Action *CpuL07::execution_start(double size);
126   friend Action *CpuL07::sleep(double duration);
127   friend Action *HostL07Model::executeParallelTask(int host_nb,
128                                                    sg_host_t*host_list,
129                                                    double *flops_amount,
130                                                    double *bytes_amount,
131                                                    double rate);
132 public:
133   L07Action(Model *model, int host_nb,
134           sg_host_t*host_list,
135           double *flops_amount,
136        double *bytes_amount,
137           double rate);
138  ~L07Action();
139
140   void updateBound();
141
142   int unref() override;
143
144   std::vector<NetCard*> * p_netcardList = new std::vector<NetCard*>();
145   double *p_computationAmount;
146   double *p_communicationAmount;
147   double m_latency;
148   double m_rate;
149 };
150
151 }
152 }
153
154 #endif /* HOST_L07_HPP_ */