Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / kernel / resource / models / cpu_cas01.hpp
1 /* Copyright (c) 2013-2023. 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_MODEL_CPU_CAS01_HPP
7 #define SIMGRID_MODEL_CPU_CAS01_HPP
8
9 #include "src/kernel/resource/CpuImpl.hpp"
10
11 namespace simgrid::kernel::resource {
12
13 /***********
14  * Classes *
15  ***********/
16
17 class XBT_PRIVATE CpuCas01Model;
18 class XBT_PRIVATE CpuCas01;
19 class XBT_PRIVATE CpuCas01Action;
20
21 /*********
22  * Model *
23  *********/
24
25 class CpuCas01Model : public CpuModel {
26 public:
27   explicit CpuCas01Model(const std::string& name);
28   CpuCas01Model(const CpuCas01Model&)            = delete;
29   CpuCas01Model& operator=(const CpuCas01Model&) = delete;
30
31   CpuImpl* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
32 };
33
34 /************
35  * Resource *
36  ************/
37
38 class CpuCas01 : public CpuImpl {
39   std::function<s4u::Host::CpuFactorCb> factor_cb_ = {};
40
41 public:
42   using CpuImpl::CpuImpl;
43   CpuCas01(const CpuCas01&)            = delete;
44   CpuCas01& operator=(const CpuCas01&) = delete;
45   void apply_event(profile::Event* event, double value) override;
46   CpuAction* execution_start(double size, double user_bound) override;
47   CpuAction* execution_start(double size, int requested_cores, double user_bound) override;
48   CpuAction* sleep(double duration) override;
49   void set_factor_cb(const std::function<s4u::Host::CpuFactorCb>& cb) override;
50
51 protected:
52   void on_speed_change() override;
53 };
54
55 /**********
56  * Action *
57  **********/
58 class CpuCas01Action : public CpuAction {
59   int requested_core_ = 1;
60
61 public:
62   CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm::Constraint* constraint, int requested_core);
63   CpuCas01Action(const CpuCas01Action&)            = delete;
64   CpuCas01Action& operator=(const CpuCas01Action&) = delete;
65   int requested_core() const { return requested_core_; }
66 };
67
68 } // namespace simgrid::kernel::resource
69
70 #endif