Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[simgrid.git] / src / surf / cpu_cas01.hpp
1 /* Copyright (c) 2013-2021. 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 #ifndef SIMGRID_SURF_CPUCAS01_HPP
7 #define SIMGRID_SURF_CPUCAS01_HPP
8
9 #include "cpu_interface.hpp"
10 #include "xbt/base.h"
11
12 /***********
13  * Classes *
14  ***********/
15
16 namespace simgrid {
17 namespace kernel {
18 namespace resource {
19
20 class XBT_PRIVATE CpuCas01Model;
21 class XBT_PRIVATE CpuCas01;
22 class XBT_PRIVATE CpuCas01Action;
23
24 /*********
25  * Model *
26  *********/
27
28 class CpuCas01Model : public CpuModel {
29 public:
30   explicit CpuCas01Model(Model::UpdateAlgo algo);
31   CpuCas01Model(const CpuCas01Model&) = delete;
32   CpuCas01Model& operator=(const CpuCas01Model&) = delete;
33   ~CpuCas01Model() override;
34
35   Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
36 };
37
38 /************
39  * Resource *
40  ************/
41
42 class CpuCas01 : public Cpu {
43 public:
44   CpuCas01(s4u::Host* host, const std::vector<double>& speed_per_pstate) : Cpu(host, speed_per_pstate) {}
45   CpuCas01(const CpuCas01&) = delete;
46   CpuCas01& operator=(const CpuCas01&) = delete;
47   void apply_event(profile::Event* event, double value) override;
48   CpuAction* execution_start(double size) override;
49   CpuAction* execution_start(double size, int requested_cores) override;
50   CpuAction* sleep(double duration) override;
51
52   bool is_used() const override;
53
54 protected:
55   void on_speed_change() override;
56 };
57
58 /**********
59  * Action *
60  **********/
61 class CpuCas01Action : public CpuAction {
62   friend CpuAction* CpuCas01::execution_start(double size);
63   friend CpuAction* CpuCas01::sleep(double duration);
64
65 public:
66   CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm::Constraint* constraint,
67                  int requested_core = 1);
68   CpuCas01Action(const CpuCas01Action&) = delete;
69   CpuCas01Action& operator=(const CpuCas01Action&) = delete;
70   ~CpuCas01Action() override;
71   int requested_core() const;
72
73 private:
74   int requested_core_ = 1;
75 };
76
77 } // namespace resource
78 } // namespace kernel
79 } // namespace simgrid
80
81 #endif