Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move code in simgrid::mc
[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, double bandwidth, double latency,
68       e_surf_link_sharing_policy_t policy,
69       xbt_dict_t properties) override;
70
71   Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
72   bool next_occuring_event_isIdempotent() override {return true;}
73
74   HostL07Model *p_hostModel;
75 };
76
77 /************
78  * Resource *
79  ************/
80
81 class CpuL07 : public Cpu {
82 public:
83   CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList,
84      tmgr_trace_t power_trace, int core, tmgr_trace_t state_trace);
85   ~CpuL07();
86   bool isUsed() override;
87   void apply_event(tmgr_trace_iterator_t event, double value) override;
88   Action *execution_start(double size) override;
89   Action *sleep(double duration) override;
90 protected:
91   void onSpeedChange() override;
92 };
93
94 class LinkL07 : public Link {
95 public:
96   LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
97       double bandwidth, double latency, e_surf_link_sharing_policy_t policy);
98   ~LinkL07(){ };
99   bool isUsed() override;
100   void apply_event(tmgr_trace_iterator_t event, double value) override;
101   void updateBandwidth(double value) override;
102   void updateLatency(double value) override;
103 };
104
105 /**********
106  * Action *
107  **********/
108 class L07Action : public CpuAction {
109   friend Action *CpuL07::execution_start(double size);
110   friend Action *CpuL07::sleep(double duration);
111   friend Action *HostL07Model::executeParallelTask(int host_nb,
112                                                    sg_host_t*host_list,
113                                                    double *flops_amount,
114                                                    double *bytes_amount,
115                                                    double rate);
116 public:
117   L07Action(Model *model, int host_nb,
118           sg_host_t*host_list,
119           double *flops_amount,
120        double *bytes_amount,
121           double rate);
122  ~L07Action();
123
124   void updateBound();
125
126   int unref() override;
127
128   std::vector<NetCard*> * p_netcardList = new std::vector<NetCard*>();
129   double *p_computationAmount;
130   double *p_communicationAmount;
131   double m_latency;
132   double m_rate;
133 };
134
135 }
136 }
137
138 #endif /* HOST_L07_HPP_ */