Logo AND Algorithmique Numérique Distribuée

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