Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetic cleanups in network models
[simgrid.git] / src / surf / cpu_cas01.hpp
1 /* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "cpu_interface.hpp"
7 #include "xbt/base.h"
8
9 /***********
10  * Classes *
11  ***********/
12
13 namespace simgrid {
14 namespace surf {
15
16 class XBT_PRIVATE CpuCas01Model;
17 class XBT_PRIVATE CpuCas01;
18 class XBT_PRIVATE CpuCas01Action;
19
20 /*********
21  * Model *
22  *********/
23
24 class CpuCas01Model : public kernel::resource::CpuModel {
25 public:
26   explicit CpuCas01Model(kernel::resource::Model::UpdateAlgo algo);
27   CpuCas01Model(const CpuCas01Model&) = delete;
28   CpuCas01Model& operator=(const CpuCas01Model&) = delete;
29   ~CpuCas01Model() override;
30
31   kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core) override;
32 };
33
34 /************
35  * Resource *
36  ************/
37
38 class CpuCas01 : public kernel::resource::Cpu {
39 public:
40   CpuCas01(CpuCas01Model* model, simgrid::s4u::Host* host, const std::vector<double>& speed_per_pstate, int core);
41   CpuCas01(const CpuCas01&) = delete;
42   CpuCas01& operator=(const CpuCas01&) = delete;
43   ~CpuCas01() override;
44   void apply_event(simgrid::kernel::profile::Event* event, double value) override;
45   kernel::resource::CpuAction* execution_start(double size) override;
46   kernel::resource::CpuAction* execution_start(double size, int requested_cores) override;
47   kernel::resource::CpuAction* sleep(double duration) override;
48
49   bool is_used() override;
50
51 protected:
52   void on_speed_change() override;
53 };
54
55 /**********
56  * Action *
57  **********/
58 class CpuCas01Action : public kernel::resource::CpuAction {
59   friend kernel::resource::CpuAction* CpuCas01::execution_start(double size);
60   friend kernel::resource::CpuAction* CpuCas01::sleep(double duration);
61
62 public:
63   CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed,
64                  kernel::lmm::Constraint* constraint, int core_count);
65   CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed,
66                  kernel::lmm::Constraint* constraint);
67   CpuCas01Action(const CpuCas01Action&) = delete;
68   CpuCas01Action& operator=(const CpuCas01Action&) = delete;
69   ~CpuCas01Action() override;
70   int requested_core();
71
72 private:
73   int requested_core_ = 1;
74 };
75
76 }
77 }