Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove the state trace from the Link constructor
[simgrid.git] / src / surf / 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 "src/surf/HostImpl.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 CpuL07;
30 class XBT_PRIVATE LinkL07;
31
32 class XBT_PRIVATE L07Action;
33 /*********
34  * Tools *
35  *********/
36
37 /*********
38  * Model *
39  *********/
40 class HostL07Model : public HostModel {
41 public:
42   HostL07Model();
43   ~HostL07Model();
44
45   double next_occuring_event(double now) override;
46   void updateActionsState(double now, double delta) override;
47   Action *executeParallelTask(int host_nb, sg_host_t *host_list,
48                 double *flops_amount, double *bytes_amount,
49                 double rate) override;
50 };
51
52 class CpuL07Model : public CpuModel {
53 public:
54   CpuL07Model(HostL07Model *hmodel,lmm_system_t sys);
55   ~CpuL07Model();
56
57   Cpu *createCpu(simgrid::s4u::Host *host,  xbt_dynar_t speedPeakList,
58                           tmgr_trace_t speedTrace, int core,
59                           tmgr_trace_t state_trace) override;
60   HostL07Model *p_hostModel;
61 };
62
63 class NetworkL07Model : public NetworkModel {
64 public:
65   NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys);
66   ~NetworkL07Model();
67   Link* createLink(const char *name,
68       double bw_initial,
69       tmgr_trace_t bw_trace,
70       double lat_initial,
71       tmgr_trace_t lat_trace,
72       e_surf_link_sharing_policy_t policy,
73       xbt_dict_t properties) override;
74
75   Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
76   bool next_occuring_event_isIdempotent() override {return true;}
77
78   HostL07Model *p_hostModel;
79 };
80
81 /************
82  * Resource *
83  ************/
84
85 class CpuL07 : public Cpu {
86 public:
87   CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList,
88      tmgr_trace_t power_trace, int core, tmgr_trace_t state_trace);
89   ~CpuL07();
90   bool isUsed() override;
91   void apply_event(tmgr_trace_iterator_t event, double value) override;
92   Action *execution_start(double size) override;
93   Action *sleep(double duration) override;
94 protected:
95   void onSpeedChange() override;
96 };
97
98 class LinkL07 : public Link {
99 public:
100   LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
101       double bw_initial, tmgr_trace_t bw_trace,
102       double lat_initial, tmgr_trace_t lat_trace,
103       e_surf_link_sharing_policy_t policy);
104   ~LinkL07(){ };
105   bool isUsed() override;
106   void apply_event(tmgr_trace_iterator_t event, double value) override;
107   void updateBandwidth(double value) override;
108   void updateLatency(double value) override;
109 };
110
111 /**********
112  * Action *
113  **********/
114 class L07Action : public CpuAction {
115   friend Action *CpuL07::execution_start(double size);
116   friend Action *CpuL07::sleep(double duration);
117   friend Action *HostL07Model::executeParallelTask(int host_nb,
118                                                    sg_host_t*host_list,
119                                                    double *flops_amount,
120                                                    double *bytes_amount,
121                                                    double rate);
122 public:
123   L07Action(Model *model, int host_nb,
124           sg_host_t*host_list,
125           double *flops_amount,
126        double *bytes_amount,
127           double rate);
128  ~L07Action();
129
130   void updateBound();
131
132   int unref() override;
133
134   std::vector<NetCard*> * p_netcardList = new std::vector<NetCard*>();
135   double *p_computationAmount;
136   double *p_communicationAmount;
137   double m_latency;
138   double m_rate;
139 };
140
141 }
142 }
143
144 #endif /* HOST_L07_HPP_ */