1 #include "surf_interface.hpp"
2 #include "maxmin_private.hpp"
4 #ifndef SURF_CPU_INTERFACE_HPP_
5 #define SURF_CPU_INTERFACE_HPP_
11 typedef CpuModel *CpuModelPtr;
17 typedef CpuAction *CpuActionPtr;
20 typedef CpuPlugin *CpuPluginPtr;
25 CpuPtr getActionCpu(CpuActionPtr action);
27 extern surf_callback(void, CpuPtr) createCpuCallbacks;
28 extern surf_callback(void, CpuPtr) deleteCpuCallbacks;
29 extern surf_callback(void, CpuActionPtr) updateCpuActionCallbacks;
34 class CpuModel : public Model {
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);
41 virtual void addTraces() =0;
47 class Cpu : public Resource {
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);
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();
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;
68 double m_powerPeak; /*< CPU power peak */
69 double m_powerScale; /*< Percentage of CPU disponible */
71 /* Note (hypervisor): */
72 lmm_constraint_t *p_constraintCore;
73 void **p_constraintCoreId;
79 class CpuAction : public Action {
80 friend CpuPtr getActionCpu(CpuActionPtr action);
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);
90 void updateRemainingLazy(double now);
94 #endif /* SURF_CPU_INTERFACE_HPP_ */