Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
0993fea896387dd3915ed87e55bb2c61dfce516a
[simgrid.git] / src / surf / cpu_cas01.hpp
1 /* Copyright (c) 2013-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "cpu_interface.hpp"
8
9 /***********
10  * Classes *
11  ***********/
12 class CpuCas01Model;
13 typedef CpuCas01Model *CpuCas01ModelPtr;
14
15 class CpuCas01;
16 typedef CpuCas01 *CpuCas01Ptr;
17
18 class CpuCas01Action;
19 typedef CpuCas01Action *CpuCas01ActionPtr;
20
21 /*********
22  * Model *
23  *********/
24 class CpuCas01Model : public CpuModel {
25 public:
26   CpuCas01Model();
27   ~CpuCas01Model();
28
29   double (CpuCas01Model::*shareResources)(double now);
30   void (CpuCas01Model::*updateActionsState)(double now, double delta);
31
32   CpuPtr createCpu(const char *name, xbt_dynar_t power_peak, int pstate,
33                                   double power_scale,
34                           tmgr_trace_t power_trace, int core,
35                           e_surf_resource_state_t state_initial,
36                           tmgr_trace_t state_trace,
37                           xbt_dict_t cpu_properties);
38   double shareResourcesFull(double now);
39   void addTraces();
40   ActionListPtr p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
41 };
42
43 /************
44  * Resource *
45  ************/
46
47 class CpuCas01 : public Cpu {
48 public:
49   CpuCas01(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
50         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
51         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
52         xbt_dict_t properties) ;
53   ~CpuCas01();
54   void updateState(tmgr_trace_event_t event_type, double value, double date);
55   CpuActionPtr execute(double size);
56   CpuActionPtr sleep(double duration);
57
58   double getCurrentPowerPeak();
59   double getPowerPeakAt(int pstate_index);
60   int getNbPstates();
61   void setPowerPeakAt(int pstate_index);
62   bool isUsed();
63   void setStateEvent(tmgr_trace_event_t stateEvent);
64   void setPowerEvent(tmgr_trace_event_t stateEvent);
65   xbt_dynar_t getPowerPeakList();
66
67   int getPState();
68
69 private:
70   tmgr_trace_event_t p_stateEvent;
71   tmgr_trace_event_t p_powerEvent;
72   xbt_dynar_t p_powerPeakList;                          /*< List of supported CPU capacities */
73   int m_pstate;                                                         /*< Current pstate (index in the power_peak_list)*/
74 };
75
76 /**********
77  * Action *
78  **********/
79 class CpuCas01Action: public CpuAction {
80   friend CpuActionPtr CpuCas01::execute(double size);
81   friend CpuActionPtr CpuCas01::sleep(double duration);
82 public:
83   CpuCas01Action(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint);
84
85   ~CpuCas01Action() {};
86 };