Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge commit '045db1657e870c721be490b411868f4181a12ced' into surf++
[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 };
36
37 /************
38  * Resource *
39  ************/
40 /*
41  * Energy-related properties for the cpu_cas01 model
42  */
43 typedef struct energy_cpu_cas01 {
44         xbt_dynar_t power_range_watts_list;             /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
45         double total_energy;                                    /*< Total energy consumed by the host */
46         double last_updated;                                    /*< Timestamp of the last energy update event*/
47 } s_energy_cpu_cas01_t, *energy_cpu_cas01_t;
48
49 class CpuCas01Lmm : public CpuLmm {
50 public:
51   CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
52         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
53         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
54         xbt_dict_t properties) ;
55   ~CpuCas01Lmm();
56   void updateState(tmgr_trace_event_t event_type, double value, double date);
57   ActionPtr execute(double size);
58   ActionPtr sleep(double duration);
59
60   xbt_dynar_t getWattsRangeList();
61   double getCurrentWattsValue(double cpu_load);
62   void updateEnergy(double cpu_load);
63
64   double getCurrentPowerPeak();
65   double getPowerPeakAt(int pstate_index);
66   int getNbPstates();
67   void setPowerPeakAt(int pstate_index);
68   double getConsumedEnergy();
69
70   bool isUsed();
71
72   tmgr_trace_event_t p_powerEvent;
73
74   xbt_dynar_t p_powerPeakList;                          /*< List of supported CPU capacities */
75   int m_pstate;                                                         /*< Current pstate (index in the power_peak_list)*/
76   energy_cpu_cas01_t p_energy;                          /*< Structure with energy-consumption data */
77 };
78
79 /**********
80  * Action *
81  **********/
82 class CpuCas01ActionLmm: public CpuActionLmm {
83 public:
84   CpuCas01ActionLmm() {};
85   CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
86   void updateEnergy();
87
88 };