Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix memleak
[simgrid.git] / src / surf / cpu_cas01.hpp
1 #include "cpu.hpp"
2
3 /***********
4  * Classes *
5  ***********/
6 class CpuCas01Model;
7 typedef CpuCas01Model *CpuCas01ModelPtr;
8
9 class CpuCas01Lmm;
10 typedef CpuCas01Lmm *CpuCas01LmmPtr;
11
12 class CpuCas01ActionLmm;
13 typedef CpuCas01ActionLmm *CpuCas01ActionLmmPtr;
14
15 /*********
16  * Model *
17  *********/
18 class CpuCas01Model : public CpuModel {
19 public:
20   CpuCas01Model();
21   ~CpuCas01Model();
22
23   double (CpuCas01Model::*shareResources)(double now);
24   void (CpuCas01Model::*updateActionsState)(double now, double delta);
25
26   void parseInit(sg_platf_host_cbarg_t host);  
27   CpuCas01LmmPtr createResource(const char *name, xbt_dynar_t power_peak, int pstate,
28                                   double power_scale,
29                           tmgr_trace_t power_trace, int core,
30                           e_surf_resource_state_t state_initial,
31                           tmgr_trace_t state_trace,
32                           xbt_dict_t cpu_properties);
33   double shareResourcesFull(double now);  
34   void addTraces();
35   xbt_swag_t p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
36 };
37
38 /************
39  * Resource *
40  ************/
41 /*
42  * Energy-related properties for the cpu_cas01 model
43  */
44 typedef struct energy_cpu_cas01 {
45         xbt_dynar_t power_range_watts_list;             /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
46         double total_energy;                                    /*< Total energy consumed by the host */
47         double last_updated;                                    /*< Timestamp of the last energy update event*/
48 } s_energy_cpu_cas01_t, *energy_cpu_cas01_t;
49
50 class CpuCas01Lmm : public CpuLmm {
51 public:
52   CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
53         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
54         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
55         xbt_dict_t properties) ;
56   ~CpuCas01Lmm();
57   void updateState(tmgr_trace_event_t event_type, double value, double date);
58   ActionPtr execute(double size);
59   ActionPtr sleep(double duration);
60
61   xbt_dynar_t getWattsRangeList();
62   double getCurrentWattsValue(double cpu_load);
63   void updateEnergy(double cpu_load);
64
65   double getCurrentPowerPeak();
66   double getPowerPeakAt(int pstate_index);
67   int getNbPstates();
68   void setPowerPeakAt(int pstate_index);
69   double getConsumedEnergy();
70
71   bool isUsed();
72
73   tmgr_trace_event_t p_powerEvent;
74
75   xbt_dynar_t p_powerPeakList;                          /*< List of supported CPU capacities */
76   int m_pstate;                                                         /*< Current pstate (index in the power_peak_list)*/
77   energy_cpu_cas01_t p_energy;                          /*< Structure with energy-consumption data */
78 };
79
80 /**********
81  * Action *
82  **********/
83 class CpuCas01ActionLmm: public CpuActionLmm {
84 public:
85   CpuCas01ActionLmm() {};
86   CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
87   void updateEnergy();
88
89 };