Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ccf8defe5a2ef162e258d81cac2e1a9d14625c9d
[simgrid.git] / src / surf / cpu_ti.hpp
1 #include "cpu.hpp"
2 #include "trace_mgr_private.h"
3 #include "surf/surf_routing.h"
4
5 /* Epsilon */
6 #define EPSILON 0.000000001
7
8 /***********
9  * Classes *
10  ***********/
11 class CpuTiModel;
12 typedef CpuTiModel *CpuTiModelPtr;
13
14 class CpuTi;
15 typedef CpuTi *CpuTiPtr;
16
17 class CpuTiAction;
18 typedef CpuTiAction *CpuTiActionPtr;
19
20 /*********
21  * Trace *
22  *********/
23 typedef struct surf_cpu_ti_trace {
24   double *time_points;
25   double *integral;
26   int nb_points;
27 } s_surf_cpu_ti_trace_t, *surf_cpu_ti_trace_t;
28
29 enum trace_type { 
30   TRACE_FIXED,                /*< Trace fixed, no availability file */
31   TRACE_DYNAMIC               /*< Dynamic, availability file disponible */
32 };
33 typedef struct surf_cpu_ti_tgmr {
34   trace_type type;
35
36   double value;                 /*< Percentage of cpu power disponible. Value fixed between 0 and 1 */
37
38   /* Dynamic */
39   double last_time;             /*< Integral interval last point (discret time) */
40   double total;                 /*< Integral total between 0 and last_pointn */
41
42   surf_cpu_ti_trace_t trace;
43   tmgr_trace_t power_trace;
44
45 } s_surf_cpu_ti_tgmr_t, *surf_cpu_ti_tgmr_t;
46
47
48 /*********
49  * Model *
50  *********/
51 class CpuTiModel : public CpuModel {
52 public:
53   CpuTiModel();
54   ~CpuTiModel() {}
55
56   CpuTiPtr createResource(string name, double power_peak, double power_scale,
57                           tmgr_trace_t power_trace, int core,
58                           e_surf_resource_state_t state_initial,
59                           tmgr_trace_t state_trace,
60                           xbt_dict_t cpu_properties);
61   CpuTiActionPtr createAction(double cost, bool failed);
62
63 protected:
64   void NotifyResourceTurnedOn(ResourcePtr r){};
65   void NotifyResourceTurnedOff(ResourcePtr r){};
66
67   void NotifyActionCancel(ActionPtr a){};
68   void NotifyActionResume(ActionPtr a){};
69   void NotifyActionSuspend(ActionPtr a){};
70 };
71
72 /************
73  * Resource *
74  ************/
75 class CpuTi : public Cpu {
76 public:
77   CpuTi(CpuTiModelPtr model, string name, double powerPeak,
78         double powerScale, tmgr_trace_t powerTrace, int core,
79         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
80         xbt_dict_t properties) ;
81   ~CpuTi() {};
82   virtual double getSpeed (double load);
83   virtual double getAvailableSpeed ();
84   void printCpuTiModel();
85   CpuTiModelPtr getModel();
86   
87   double m_powerPeak;            /*< CPU power peak */
88   double m_powerScale;           /*< Percentage of CPU disponible */
89   surf_cpu_ti_tgmr_t m_availTrace;       /*< Structure with data needed to integrate trace file */
90   e_surf_resource_state_t m_stateCurrent;        /*< CPU current state (ON or OFF) */
91   tmgr_trace_event_t m_stateEvent;       /*< trace file with states events (ON or OFF) */
92   tmgr_trace_event_t m_powerEvent;       /*< trace file with availabitly events */
93   std::vector<CpuTiActionPtr> m_actionSet;        /*< set with all actions running on cpu */
94   s_xbt_swag_hookup_t m_modifiedCpuHookup;      /*< hookup to swag that indicacates whether share resources must be recalculated or not */
95   double m_sumPriority;          /*< the sum of actions' priority that are running on cpu */
96   double m_lastUpdate;           /*< last update of actions' remaining amount done */
97
98 };
99
100 /**********
101  * Action *
102  **********/
103 class CpuTiAction: public CpuAction {
104 public:
105   CpuTiAction(CpuTiModelPtr model, double cost, bool failed): CpuAction(model, cost, failed) {};
106
107   virtual double getRemains();
108   virtual double getStartTime();
109   virtual double getFinishTime();
110 };