Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
852d71c3a47f094ad03da8bcd8473c9ec184b28e
[simgrid.git] / src / surf / cpu_interface.hpp
1 #include "surf_interface.hpp"
2 #include "maxmin_private.hpp"
3
4 #ifndef SURF_CPU_INTERFACE_HPP_
5 #define SURF_CPU_INTERFACE_HPP_
6
7 /***********
8  * Classes *
9  ***********/
10 class CpuModel;
11 typedef CpuModel *CpuModelPtr;
12
13 class Cpu;
14 typedef Cpu *CpuPtr;
15
16 class CpuAction;
17 typedef CpuAction *CpuActionPtr;
18
19 class CpuPlugin;
20 typedef CpuPlugin *CpuPluginPtr;
21
22 /*************
23  * Callbacks *
24  *************/
25 CpuPtr getActionCpu(CpuActionPtr action);
26
27 extern surf_callback(void, CpuPtr) createCpuCallbacks;
28 extern surf_callback(void, CpuPtr) deleteCpuCallbacks;
29 extern surf_callback(void, CpuActionPtr) updateCpuActionCallbacks;
30
31 /*********
32  * Model *
33  *********/
34 class CpuModel : public Model {
35 public:
36   CpuModel(const char *name) : Model(name) {};
37   CpuPtr createResource(string name);
38   void updateActionsStateLazy(double now, double delta);
39   void updateActionsStateFull(double now, double delta);
40
41   virtual void addTraces() =0;
42 };
43
44 /************
45  * Resource *
46  ************/
47 class Cpu : public Resource {
48 public:
49   Cpu(){surf_callback_emit(createCpuCallbacks, this);};
50   Cpu(ModelPtr model, const char *name, xbt_dict_t props,
51           lmm_constraint_t constraint, int core, double powerPeak, double powerScale);
52   Cpu(ModelPtr model, const char *name, xbt_dict_t props,
53           int core, double powerPeak, double powerScale);
54   ~Cpu();
55   virtual CpuActionPtr execute(double size)=0;
56   virtual CpuActionPtr sleep(double duration)=0;
57   virtual int getCore();
58   virtual double getSpeed(double load);
59   virtual double getAvailableSpeed();
60
61   virtual double getCurrentPowerPeak()=0;
62   virtual double getPowerPeakAt(int pstate_index)=0;
63   virtual int getNbPstates()=0;
64   virtual void setPowerPeakAt(int pstate_index)=0;
65
66   void addTraces(void);
67   int m_core;
68   double m_powerPeak;            /*< CPU power peak */
69   double m_powerScale;           /*< Percentage of CPU disponible */
70
71   /* Note (hypervisor): */
72   lmm_constraint_t *p_constraintCore;
73   void **p_constraintCoreId;
74 };
75
76 /**********
77  * Action *
78  **********/
79 class CpuAction : public Action {
80 friend CpuPtr getActionCpu(CpuActionPtr action);
81 public:
82   CpuAction(){};
83   CpuAction(ModelPtr model, double cost, bool failed)
84   : Action(model, cost, failed) {} //FIXME:REMOVE
85   CpuAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
86   : Action(model, cost, failed, var) {}
87   virtual void setAffinity(CpuPtr cpu, unsigned long mask);
88   virtual void setBound(double bound);
89
90   void updateRemainingLazy(double now);
91   double m_bound;
92 };
93
94 #endif /* SURF_CPU_INTERFACE_HPP_ */