Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sanitize surf API: s/shareResources/next_occuring_event/
[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   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 next_occuring_event_isIdempotent() 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) 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) override;
122   void updateBandwidth(double value) override;
123   void updateLatency(double value) override;
124 };
125
126 /**********
127  * Action *
128  **********/
129 class L07Action : public CpuAction {
130   friend Action *CpuL07::execution_start(double size);
131   friend Action *CpuL07::sleep(double duration);
132   friend Action *HostL07Model::executeParallelTask(int host_nb,
133                                                    sg_host_t*host_list,
134                                                    double *flops_amount,
135                                                    double *bytes_amount,
136                                                    double rate);
137 public:
138   L07Action(Model *model, int host_nb,
139           sg_host_t*host_list,
140           double *flops_amount,
141        double *bytes_amount,
142           double rate);
143  ~L07Action();
144
145   void updateBound();
146
147   int unref() override;
148
149   std::vector<NetCard*> * p_netcardList = new std::vector<NetCard*>();
150   double *p_computationAmount;
151   double *p_communicationAmount;
152   double m_latency;
153   double m_rate;
154 };
155
156 }
157 }
158
159 #endif /* HOST_L07_HPP_ */