Logo AND Algorithmique Numérique Distribuée

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