Logo AND Algorithmique Numérique Distribuée

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