Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix a bug
[simgrid.git] / src / surf / cpu_cas01.hpp
1 #include "cpu_interface.hpp"
2
3 /***********
4  * Classes *
5  ***********/
6 class CpuCas01Model;
7 typedef CpuCas01Model *CpuCas01ModelPtr;
8
9 class CpuCas01;
10 typedef CpuCas01 *CpuCas01Ptr;
11
12 class CpuCas01Action;
13 typedef CpuCas01Action *CpuCas01ActionPtr;
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   CpuPtr 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   ActionListPtr 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 CpuCas01 : public Cpu {
51 public://FIXME:
52   tmgr_trace_event_t p_stateEvent;
53 public:
54   CpuCas01(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
55         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
56         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
57         xbt_dict_t properties) ;
58   ~CpuCas01();
59   void updateState(tmgr_trace_event_t event_type, double value, double date);
60   CpuActionPtr execute(double size);
61   CpuActionPtr sleep(double duration);
62
63   xbt_dynar_t getWattsRangeList();
64   double getCurrentWattsValue(double cpu_load);
65   void updateEnergy(double cpu_load);
66
67   double getCurrentPowerPeak();
68   double getPowerPeakAt(int pstate_index);
69   int getNbPstates();
70   void setPowerPeakAt(int pstate_index);
71   double getConsumedEnergy();
72
73   bool isUsed();
74
75   tmgr_trace_event_t p_powerEvent;
76   xbt_dynar_t p_powerPeakList;                          /*< List of supported CPU capacities */
77   int m_pstate;                                                         /*< Current pstate (index in the power_peak_list)*/
78   energy_cpu_cas01_t p_energy;                          /*< Structure with energy-consumption data */
79 };
80
81 /**********
82  * Action *
83  **********/
84 class CpuCas01Action: public CpuAction {
85   friend CpuActionPtr CpuCas01::execute(double size);
86   friend CpuActionPtr CpuCas01::sleep(double duration);
87 public:
88   CpuCas01Action() {};
89   CpuCas01Action(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint);
90
91   ~CpuCas01Action() {};
92   void updateEnergy();
93 };