Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
moved a line for comprehension
[simgrid.git] / src / surf / cpu_cas01.hpp
1 /* Copyright (c) 2013-2020. 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, int core) override;
36 };
37
38 /************
39  * Resource *
40  ************/
41
42 class CpuCas01 : public Cpu {
43 public:
44   CpuCas01(CpuCas01Model* model, s4u::Host* host, const std::vector<double>& speed_per_pstate, int core);
45   CpuCas01(const CpuCas01&) = delete;
46   CpuCas01& operator=(const CpuCas01&) = delete;
47   ~CpuCas01() override;
48   void apply_event(profile::Event* event, double value) override;
49   CpuAction* execution_start(double size) override;
50   CpuAction* execution_start(double size, int requested_cores) override;
51   CpuAction* sleep(double duration) override;
52
53   bool is_used() override;
54
55 protected:
56   void on_speed_change() override;
57 };
58
59 /**********
60  * Action *
61  **********/
62 class CpuCas01Action : public CpuAction {
63   friend CpuAction* CpuCas01::execution_start(double size);
64   friend CpuAction* CpuCas01::sleep(double duration);
65
66 public:
67   CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm::Constraint* constraint, int core_count);
68   CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm::Constraint* constraint);
69   CpuCas01Action(const CpuCas01Action&) = delete;
70   CpuCas01Action& operator=(const CpuCas01Action&) = delete;
71   ~CpuCas01Action() override;
72   int requested_core();
73
74 private:
75   int requested_core_ = 1;
76 };
77
78 } // namespace resource
79 } // namespace kernel
80 } // namespace simgrid
81
82 #endif