Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7beb42557ac590b33a9446d7bec1401555ab160e
[simgrid.git] / src / surf / cpu_interface.hpp
1 #include "surf_interface.hpp"
2 #include "maxmin_private.h"
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 CpuLmm;
17 typedef CpuLmm *CpuLmmPtr;
18
19 class CpuAction;
20 typedef CpuAction *CpuActionPtr;
21
22 class CpuActionLmm;
23 typedef CpuActionLmm *CpuActionLmmPtr;
24
25 /*********
26  * Model *
27  *********/
28 class CpuModel : public Model {
29 public:
30   CpuModel(string name) : Model(name) {};
31   CpuPtr createResource(string name);
32   void updateActionsStateLazy(double now, double delta);
33   void updateActionsStateFull(double now, double delta);
34
35   virtual void addTraces() =0;
36 };
37
38 /************
39  * Resource *
40  ************/
41 class Cpu : virtual public Resource {
42 public:
43   Cpu(){};
44   Cpu(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale)
45    : Resource(model, name, properties), m_core(core), m_powerPeak(powerPeak), m_powerScale(powerScale)
46    {};
47   virtual ActionPtr execute(double size)=0;
48   virtual ActionPtr sleep(double duration)=0;
49   virtual int getCore();
50   virtual double getSpeed(double load);
51   virtual double getAvailableSpeed();
52
53   virtual double getCurrentPowerPeak()=0;
54   virtual double getPowerPeakAt(int pstate_index)=0;
55   virtual int getNbPstates()=0;
56   virtual void setPowerPeakAt(int pstate_index)=0;
57   virtual double getConsumedEnergy()=0;
58
59   void addTraces(void);
60   int m_core;
61   double m_powerPeak;            /*< CPU power peak */
62   double m_powerScale;           /*< Percentage of CPU disponible */
63 protected:
64
65   //virtual boost::shared_ptr<Action> execute(double size) = 0;
66   //virtual boost::shared_ptr<Action> sleep(double duration) = 0;
67 };
68
69 class CpuLmm : public ResourceLmm, public Cpu {
70 public:
71   CpuLmm() : p_constraintCore(NULL), p_constraintCoreId(NULL) {};
72   CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale);
73   ~CpuLmm();
74   /* Note (hypervisor): */
75   lmm_constraint_t *p_constraintCore;
76   void **p_constraintCoreId;
77
78 };
79
80 /**********
81  * Action *
82  **********/
83 class CpuAction : virtual public Action {
84 public:
85   CpuAction(){};
86   CpuAction(ModelPtr model, double cost, bool failed)
87   : Action(model, cost, failed) {};
88   virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
89   virtual void setBound(double bound)=0;
90 };
91
92 class CpuActionLmm : public ActionLmm, public CpuAction {
93 public:
94   CpuActionLmm(){};
95   CpuActionLmm(ModelPtr model, double cost, bool failed)
96   : Action(model, cost, failed), ActionLmm(model, cost, failed), CpuAction(model, cost, failed) {};
97   void updateRemainingLazy(double now);
98   virtual void updateEnergy()=0;
99   void setAffinity(CpuPtr cpu, unsigned long mask);
100   void setBound(double bound);
101   double m_bound;
102 };
103
104
105 #endif /* SURF_CPU_INTERFACE_HPP_ */