Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
protect smpi against problems with replay+collectives.
[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   void parseInit(sg_platf_host_cbarg_t host);  
33   CpuPtr createResource(const char *name, xbt_dynar_t power_peak, int pstate,
34                                   double power_scale,
35                           tmgr_trace_t power_trace, int core,
36                           e_surf_resource_state_t state_initial,
37                           tmgr_trace_t state_trace,
38                           xbt_dict_t cpu_properties);
39   double shareResourcesFull(double now);  
40   void addTraces();
41   ActionListPtr p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
42 };
43
44 /************
45  * Resource *
46  ************/
47 /*
48  * Energy-related properties for the cpu_cas01 model
49  */
50 typedef struct energy_cpu_cas01 {
51         xbt_dynar_t power_range_watts_list;             /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
52         double total_energy;                                    /*< Total energy consumed by the host */
53         double last_updated;                                    /*< Timestamp of the last energy update event*/
54 } s_energy_cpu_cas01_t, *energy_cpu_cas01_t;
55
56 class CpuCas01 : public Cpu {
57 public://FIXME:
58   tmgr_trace_event_t p_stateEvent;
59 public:
60   CpuCas01(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
61         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
62         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
63         xbt_dict_t properties) ;
64   ~CpuCas01();
65   void updateState(tmgr_trace_event_t event_type, double value, double date);
66   CpuActionPtr execute(double size);
67   CpuActionPtr sleep(double duration);
68
69   double getCurrentPowerPeak();
70   double getPowerPeakAt(int pstate_index);
71   int getNbPstates();
72   void setPowerPeakAt(int pstate_index);
73
74   bool isUsed();
75
76   tmgr_trace_event_t p_powerEvent;
77   xbt_dynar_t p_powerPeakList;                          /*< List of supported CPU capacities */
78   int m_pstate;                                                         /*< Current pstate (index in the power_peak_list)*/
79 };
80
81 /**********
82  * Action *
83  **********/
84 class CpuCas01Action: public CpuAction {
85   friend CpuActionPtr CpuCas01::execute(double size);
86   friend CpuActionPtr CpuCas01::sleep(double duration);
87 public:
88   CpuCas01Action() {};
89   CpuCas01Action(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint);
90
91   ~CpuCas01Action() {};
92 };