Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b98fd237e6b57c662f82ff4b0ea9ca326c325094
[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 <xbt/base.h>
8
9 #include "cpu_interface.hpp"
10
11 /***********
12  * Classes *
13  ***********/
14
15 namespace simgrid {
16 namespace surf {
17
18 class XBT_PRIVATE CpuCas01Model;
19 class XBT_PRIVATE CpuCas01;
20 class XBT_PRIVATE CpuCas01Action;
21
22 /*********
23  * Model *
24  *********/
25
26 class CpuCas01Model : public simgrid::surf::CpuModel {
27 public:
28   CpuCas01Model();
29   ~CpuCas01Model();
30
31   double (CpuCas01Model::*shareResources)(double now);
32   void (CpuCas01Model::*updateActionsState)(double now, double delta);
33
34   Cpu *createCpu(const char *name, xbt_dynar_t speedPeak, int pstate,
35                    double speedScale,
36                           tmgr_trace_t speedTrace, int core,
37                           e_surf_resource_state_t state_initial,
38                           tmgr_trace_t state_trace,
39                           xbt_dict_t cpu_properties);
40   double shareResourcesFull(double now);
41   void addTraces();
42   ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
43 };
44
45 /************
46  * Resource *
47  ************/
48
49 class CpuCas01 : public Cpu {
50 public:
51   CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t speedPeak,
52         int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
53         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
54         xbt_dict_t properties) ;
55   ~CpuCas01();
56   void updateState(tmgr_trace_event_t event_type, double value, double date);
57   CpuAction *execute(double size);
58   CpuAction *sleep(double duration);
59
60   double getCurrentPowerPeak();
61   double getPowerPeakAt(int pstate_index);
62   int getNbPstates();
63   void setPstate(int pstate_index);
64   int  getPstate();
65   bool isUsed();
66   void setStateEvent(tmgr_trace_event_t stateEvent);
67   void setPowerEvent(tmgr_trace_event_t stateEvent);
68   xbt_dynar_t getSpeedPeakList();
69
70   int getPState();
71
72 private:
73   tmgr_trace_event_t p_stateEvent;
74   tmgr_trace_event_t p_speedEvent;
75   xbt_dynar_t p_speedPeakList;       /*< List of supported CPU capacities (pstate related) */
76   int m_pstate;                      /*< Current pstate (index in the speedPeakList)*/
77 };
78
79 /**********
80  * Action *
81  **********/
82 class CpuCas01Action: public CpuAction {
83   friend CpuAction *CpuCas01::execute(double size);
84   friend CpuAction *CpuCas01::sleep(double duration);
85 public:
86   CpuCas01Action(Model *model, double cost, bool failed, double speed,
87                  lmm_constraint_t constraint);
88
89   ~CpuCas01Action() {};
90 };
91
92 }
93 }