2 #include "trace_mgr_private.h"
3 #include "surf/surf_routing.h"
6 #define EPSILON 0.000000001
12 typedef CpuTiTrace *CpuTiTracePtr;
15 typedef CpuTiTgmr *CpuTiTgmrPtr;
18 typedef CpuTiModel *CpuTiModelPtr;
21 typedef CpuTi *CpuTiPtr;
24 typedef CpuTiAction *CpuTiActionPtr;
31 CpuTiTrace(tmgr_trace_t powerTrace);
34 double integrateSimple(double a, double b);
35 double integrateSimplePoint(double a);
36 double solveSimple(double a, double amount);
41 int binarySearch(double *array, double a, int low, int high);
48 TRACE_FIXED, /*< Trace fixed, no availability file */
49 TRACE_DYNAMIC /*< Dynamic, availability file disponible */
54 CpuTiTgmr(trace_type type, double value): m_type(type), m_value(value){};
55 CpuTiTgmr(tmgr_trace_t power_trace, double value);
58 double integrate(double a, double b);
59 double solve(double a, double amount);
60 double solveSomewhatSimple(double a, double amount);
61 double getPowerScale(double a);
64 double m_value; /*< Percentage of cpu power disponible. Value fixed between 0 and 1 */
67 double m_lastTime; /*< Integral interval last point (discret time) */
68 double m_total; /*< Integral total between 0 and last_pointn */
70 CpuTiTracePtr p_trace;
71 tmgr_trace_t p_powerTrace;
78 class CpuTiModel : public CpuModel {
83 void parseInit(sg_platf_host_cbarg_t host);
84 CpuTiPtr createResource(const char *name, xbt_dynar_t powerPeak,
85 int pstate, double power_scale,
86 tmgr_trace_t power_trace, int core,
87 e_surf_resource_state_t state_initial,
88 tmgr_trace_t state_trace,
89 xbt_dict_t cpu_properties);
90 CpuTiActionPtr createAction(double cost, bool failed);
91 double shareResources(double now);
92 void updateActionsState(double now, double delta);
96 void NotifyResourceTurnedOn(ResourcePtr){};
97 void NotifyResourceTurnedOff(ResourcePtr){};
99 void NotifyActionCancel(ActionPtr){};
100 void NotifyActionResume(ActionPtr){};
101 void NotifyActionSuspend(ActionPtr){};
107 class CpuTi : public Cpu {
110 CpuTi(CpuTiModelPtr model, const char *name, xbt_dynar_t powerPeak,
111 int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
112 e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
113 xbt_dict_t properties) ;
116 void updateState(tmgr_trace_event_t event_type, double value, double date);
117 void updateActionFinishDate(double now);
119 void printCpuTiModel();
120 CpuActionPtr execute(double size);
121 CpuTiActionPtr _execute(double size);
122 CpuActionPtr sleep(double duration);
123 double getAvailableSpeed();
125 xbt_dynar_t getWattsRangeList() {THROW_UNIMPLEMENTED;};
126 double getCurrentWattsValue(double /*cpu_load*/) {THROW_UNIMPLEMENTED;};
127 void updateEnergy(double /*cpu_load*/) {THROW_UNIMPLEMENTED;};
129 double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
130 double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
131 int getNbPstates() {THROW_UNIMPLEMENTED;};
132 void setPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
133 double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
135 CpuTiTgmrPtr p_availTrace; /*< Structure with data needed to integrate trace file */
136 tmgr_trace_event_t p_stateEvent; /*< trace file with states events (ON or OFF) */
137 tmgr_trace_event_t p_powerEvent; /*< trace file with availability events */
138 xbt_swag_t p_actionSet; /*< set with all actions running on cpu */
139 s_xbt_swag_hookup_t p_modifiedCpuHookup; /*< hookup to swag that indicates whether share resources must be recalculated or not */
140 double m_sumPriority; /*< the sum of actions' priority that are running on cpu */
141 double m_lastUpdate; /*< last update of actions' remaining amount done */
143 int m_pstate; /*< Current pstate (index in the power_peak_list)*/
144 double current_frequency;
146 void updateRemainingAmount(double now);
153 class CpuTiAction: public CpuAction {
156 CpuTiAction(CpuTiModelPtr model, double cost, bool failed)
157 : Action(model, cost, failed), CpuAction(model, cost, failed) {
158 p_cpuListHookup.next = 0;
159 p_cpuListHookup.prev = 0;
162 void setState(e_surf_action_state_t state);
166 void updateIndexHeap(int i);
170 void setMaxDuration(double duration);
171 void setPriority(double priority);
175 s_xbt_swag_hookup_t p_cpuListHookup;