Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a0aa2103bed0526bb244f99744dd392f13ac1bef
[simgrid.git] / src / surf / cpu_cas01.hpp
1 /* Copyright (c) 2013-2015. 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 class CpuCas01;
14 class CpuCas01Action;
15
16 /*********
17  * Model *
18  *********/
19 class CpuCas01Model : public CpuModel {
20 public:
21   CpuCas01Model();
22   ~CpuCas01Model();
23
24   double (CpuCas01Model::*shareResources)(double now);
25   void (CpuCas01Model::*updateActionsState)(double now, double delta);
26
27   Cpu *createCpu(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   ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
36 };
37
38 /************
39  * Resource *
40  ************/
41
42 class CpuCas01 : public Cpu {
43 public:
44   CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t power_peak,
45         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
46         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
47         xbt_dict_t properties) ;
48   ~CpuCas01();
49   void updateState(tmgr_trace_event_t event_type, double value, double date);
50   CpuAction *execute(double size);
51   CpuAction *sleep(double duration);
52
53   double getCurrentPowerPeak();
54   double getPowerPeakAt(int pstate_index);
55   int getNbPstates();
56   void setPstate(int pstate_index);
57   int  getPstate();
58   bool isUsed();
59   void setStateEvent(tmgr_trace_event_t stateEvent);
60   void setPowerEvent(tmgr_trace_event_t stateEvent);
61   xbt_dynar_t getPowerPeakList();
62
63   int getPState();
64
65 private:
66   tmgr_trace_event_t p_stateEvent;
67   tmgr_trace_event_t p_powerEvent;
68   xbt_dynar_t p_powerPeakList;       /*< List of supported CPU capacities */
69   int m_pstate;                      /*< Current pstate (index in the power_peak_list)*/
70 };
71
72 /**********
73  * Action *
74  **********/
75 class CpuCas01Action: public CpuAction {
76   friend CpuAction *CpuCas01::execute(double size);
77   friend CpuAction *CpuCas01::sleep(double duration);
78 public:
79   CpuCas01Action(Model *model, double cost, bool failed, double power,
80                  lmm_constraint_t constraint);
81
82   ~CpuCas01Action() {};
83 };