Logo AND Algorithmique Numérique Distribuée

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