Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a611d4771e9bf9ed5529dab6f1154df6e7c4eeb9
[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 #include <vector>
9 #include <xbt/base.h>
10 #include "src/surf/HostImpl.hpp"
11
12 #ifndef HOST_L07_HPP_
13 #define HOST_L07_HPP_
14
15 namespace simgrid {
16 namespace surf {
17
18 /***********
19  * Classes *
20  ***********/
21
22 class XBT_PRIVATE HostL07Model;
23 class XBT_PRIVATE CpuL07Model;
24 class XBT_PRIVATE NetworkL07Model;
25
26 class XBT_PRIVATE CpuL07;
27 class XBT_PRIVATE LinkL07;
28
29 class XBT_PRIVATE L07Action;
30 /*********
31  * Tools *
32  *********/
33
34 /*********
35  * Model *
36  *********/
37 class HostL07Model : public HostModel {
38 public:
39   HostL07Model();
40   ~HostL07Model();
41
42   double nextOccuringEvent(double now) override;
43   void updateActionsState(double now, double delta) override;
44   Action *executeParallelTask(int host_nb, sg_host_t *host_list,
45                               double *flops_amount, double *bytes_amount, double rate) override;
46 };
47
48 class CpuL07Model : public CpuModel {
49 public:
50   CpuL07Model(HostL07Model *hmodel,lmm_system_t sys);
51   ~CpuL07Model();
52
53   Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
54   HostL07Model *hostModel_;
55 };
56
57 class NetworkL07Model : public NetworkModel {
58 public:
59   NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys);
60   ~NetworkL07Model();
61   Link* createLink(const char *name, double bandwidth, double latency,
62       e_surf_link_sharing_policy_t policy,
63       xbt_dict_t properties) override;
64
65   Action *communicate(kernel::routing::NetCard *src, kernel::routing::NetCard *dst, double size, double rate) override;
66   bool next_occuring_event_isIdempotent() override {return true;}
67
68   HostL07Model *hostModel_;
69 };
70
71 /************
72  * Resource *
73  ************/
74
75 class CpuL07 : public Cpu {
76 public:
77   CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector<double> * speedPerPstate, int core);
78   ~CpuL07();
79   bool isUsed() override;
80   void apply_event(tmgr_trace_iterator_t event, double value) override;
81   Action *execution_start(double size) override;
82   Action *sleep(double duration) override;
83 protected:
84   void onSpeedChange() override;
85 };
86
87 class LinkL07 : public Link {
88 public:
89   LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
90       double bandwidth, double latency, e_surf_link_sharing_policy_t policy);
91   ~LinkL07(){ };
92   bool isUsed() override;
93   void apply_event(tmgr_trace_iterator_t event, double value) override;
94   void updateBandwidth(double value) override;
95   void updateLatency(double value) override;
96 };
97
98 /**********
99  * Action *
100  **********/
101 class L07Action : public CpuAction {
102   friend Action *CpuL07::execution_start(double size);
103   friend Action *CpuL07::sleep(double duration);
104   friend Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t*host_list,
105                                                    double *flops_amount, double *bytes_amount, double rate);
106 public:
107   L07Action(Model *model, int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, double rate);
108  ~L07Action();
109
110   void updateBound();
111
112   int unref() override;
113
114   std::vector<kernel::routing::NetCard*> * netcardList_ = new std::vector<kernel::routing::NetCard*>();
115   double *computationAmount_;
116   double *communicationAmount_;
117   double latency_;
118   double rate_;
119 };
120
121 }
122 }
123
124 #endif /* HOST_L07_HPP_ */