gem5  v20.1.0.0
activity.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __CPU_ACTIVITY_HH__
30 #define __CPU_ACTIVITY_HH__
31 
32 #include "base/trace.hh"
33 #include "cpu/timebuf.hh"
34 
51 {
52  public:
53  ActivityRecorder(const std::string &name, int num_stages,
54  int longest_latency, int count);
56 
58  void activity();
59 
64  void advance();
65 
67  void activateStage(const int idx);
68 
70  void deactivateStage(const int idx);
71 
73  bool getStageActive(const int idx) const { return stageActive[idx]; }
74 
76  int getNumStages() const { return numStages; }
77 
79  int getActivityCount() const { return activityCount; }
80 
85  { activityCount = count; }
86 
88  bool active() { return activityCount; }
89 
91  void reset();
92 
94  void dump();
95 
99  void validate();
100 
101  const std::string &name() const { return _name; }
102 
103  private:
104  // provide name() for DPRINTF.
105  std::string _name;
106 
116 
119 
130 
133 
135  bool *stageActive;
136 };
137 
138 #endif // __CPU_ACTIVITY_HH__
ActivityRecorder
ActivityRecorder helper class that informs the CPU if it can switch over to being idle or not.
Definition: activity.hh:50
ActivityRecorder::name
const std::string & name() const
Definition: activity.hh:101
ActivityRecorder::getNumStages
int getNumStages() const
Returns the number of stages.
Definition: activity.hh:76
ActivityRecorder::advance
void advance()
Advances the activity buffer, decrementing the activityCount if active communication just left the ti...
Definition: activity.cc:70
X86ISA::count
count
Definition: misc.hh:703
ActivityRecorder::longestLatency
int longestLatency
Longest latency time buffer in the CPU.
Definition: activity.hh:118
ActivityRecorder::active
bool active()
Returns if the CPU should be active.
Definition: activity.hh:88
TimeBuffer< bool >
ActivityRecorder::_name
std::string _name
Definition: activity.hh:105
timebuf.hh
ActivityRecorder::~ActivityRecorder
~ActivityRecorder()
Definition: activity.cc:48
ActivityRecorder::setActivityCount
void setActivityCount(int count)
Sets the count to a starting value.
Definition: activity.hh:84
ActivityRecorder::getActivityCount
int getActivityCount() const
Returns how many things are active within the recorder.
Definition: activity.hh:79
ActivityRecorder::reset
void reset()
Clears the time buffer and the activity count.
Definition: activity.cc:124
ActivityRecorder::numStages
int numStages
Number of stages that can be marked as active or inactive.
Definition: activity.hh:132
ActivityRecorder::activityBuffer
TimeBuffer< bool > activityBuffer
Time buffer that tracks if any cycles has active communication in them.
Definition: activity.hh:115
ActivityRecorder::activityCount
int activityCount
Tracks how many stages and cycles of time buffer have activity.
Definition: activity.hh:129
ActivityRecorder::validate
void validate()
Debug function to ensure that the activity count matches the contents of the time buffer.
Definition: activity.cc:151
ActivityRecorder::stageActive
bool * stageActive
Records which stages are active/inactive.
Definition: activity.hh:135
ActivityRecorder::activity
void activity()
Records that there is activity this cycle.
Definition: activity.cc:54
ActivityRecorder::activateStage
void activateStage(const int idx)
Marks a stage as active.
Definition: activity.cc:90
ActivityRecorder::getStageActive
bool getStageActive(const int idx) const
Returns the activity status of a stage.
Definition: activity.hh:73
trace.hh
ActivityRecorder::deactivateStage
void deactivateStage(const int idx)
Deactivates a stage.
Definition: activity.cc:107
ActivityRecorder::ActivityRecorder
ActivityRecorder(const std::string &name, int num_stages, int longest_latency, int count)
Definition: activity.cc:38
ActivityRecorder::dump
void dump()
Debug function to dump the contents of the time buffer.
Definition: activity.cc:133

Generated on Wed Sep 30 2020 14:02:08 for gem5 by doxygen 1.8.17