gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
ActivityRecorder Class Reference

ActivityRecorder helper class that informs the CPU if it can switch over to being idle or not. More...

#include <activity.hh>

Inheritance diagram for ActivityRecorder:
Minor::MinorActivityRecorder

Public Member Functions

 ActivityRecorder (const std::string &name, int num_stages, int longest_latency, int count)
 
 ~ActivityRecorder ()
 
void activity ()
 Records that there is activity this cycle. More...
 
void advance ()
 Advances the activity buffer, decrementing the activityCount if active communication just left the time buffer, and determining if there is no activity. More...
 
void activateStage (const int idx)
 Marks a stage as active. More...
 
void deactivateStage (const int idx)
 Deactivates a stage. More...
 
bool getStageActive (const int idx) const
 Returns the activity status of a stage. More...
 
int getNumStages () const
 Returns the number of stages. More...
 
int getActivityCount () const
 Returns how many things are active within the recorder. More...
 
void setActivityCount (int count)
 Sets the count to a starting value. More...
 
bool active ()
 Returns if the CPU should be active. More...
 
void reset ()
 Clears the time buffer and the activity count. More...
 
void dump ()
 Debug function to dump the contents of the time buffer. More...
 
void validate ()
 Debug function to ensure that the activity count matches the contents of the time buffer. More...
 
const std::string & name () const
 

Private Attributes

std::string _name
 
TimeBuffer< bool > activityBuffer
 Time buffer that tracks if any cycles has active communication in them. More...
 
int longestLatency
 Longest latency time buffer in the CPU. More...
 
int activityCount
 Tracks how many stages and cycles of time buffer have activity. More...
 
int numStages
 Number of stages that can be marked as active or inactive. More...
 
bool * stageActive
 Records which stages are active/inactive. More...
 

Detailed Description

ActivityRecorder helper class that informs the CPU if it can switch over to being idle or not.

It works by having a time buffer as long as any time buffer in the CPU, and the CPU and all of its stages inform the ActivityRecorder when they write to any time buffer. The ActivityRecorder marks a 1 in the "0" slot of the time buffer any time a stage writes to a time buffer, and it advances its time buffer at the same time as all other stages. The ActivityRecorder also records if a stage has activity to do next cycle. The recorder keeps a count of these two. Thus any time the count is non-zero, there is either communication still in flight, or activity that still must be done, meaning that the CPU can not idle. If count is zero, then the CPU can safely idle as it has no more outstanding work to do.

Definition at line 52 of file activity.hh.

Constructor & Destructor Documentation

ActivityRecorder::ActivityRecorder ( const std::string &  name,
int  num_stages,
int  longest_latency,
int  count 
)

Definition at line 40 of file activity.cc.

References numStages, and stageActive.

ActivityRecorder::~ActivityRecorder ( )

Definition at line 50 of file activity.cc.

References stageActive.

Member Function Documentation

void ActivityRecorder::activateStage ( const int  idx)
bool ActivityRecorder::active ( )
inline

Returns if the CPU should be active.

Definition at line 90 of file activity.hh.

References activityCount.

Referenced by Minor::Pipeline::evaluate().

void ActivityRecorder::activity ( )
void ActivityRecorder::advance ( )

Advances the activity buffer, decrementing the activityCount if active communication just left the time buffer, and determining if there is no activity.

Definition at line 72 of file activity.cc.

References activityBuffer, activityCount, TimeBuffer< T >::advance(), DPRINTF, and longestLatency.

Referenced by Minor::MinorActivityRecorder::evaluate().

void ActivityRecorder::deactivateStage ( const int  idx)

Deactivates a stage.

Definition at line 109 of file activity.cc.

References activityCount, DPRINTF, and stageActive.

Referenced by FullO3CPU< O3CPUImpl >::deactivateStage(), and Minor::Pipeline::evaluate().

void ActivityRecorder::dump ( )

Debug function to dump the contents of the time buffer.

Definition at line 135 of file activity.cc.

References activityBuffer, activityCount, cprintf(), ArmISA::i, longestLatency, numStages, and stageActive.

int ActivityRecorder::getActivityCount ( ) const
inline

Returns how many things are active within the recorder.

Definition at line 81 of file activity.hh.

References activityCount.

Referenced by Minor::MinorActivityRecorder::minorTrace().

int ActivityRecorder::getNumStages ( ) const
inline

Returns the number of stages.

Definition at line 78 of file activity.hh.

References numStages.

Referenced by Minor::MinorActivityRecorder::minorTrace().

bool ActivityRecorder::getStageActive ( const int  idx) const
inline

Returns the activity status of a stage.

Definition at line 75 of file activity.hh.

References stageActive.

Referenced by Minor::MinorActivityRecorder::minorTrace().

const std::string& ActivityRecorder::name ( ) const
inline

Definition at line 103 of file activity.hh.

References _name.

void ActivityRecorder::reset ( )

Clears the time buffer and the activity count.

Definition at line 126 of file activity.cc.

References activityBuffer, activityCount, TimeBuffer< T >::advance(), ArmISA::i, longestLatency, numStages, and stageActive.

Referenced by MinorCPU::switchOut().

void ActivityRecorder::setActivityCount ( int  count)
inline

Sets the count to a starting value.

Can be used to disable the idling option.

Definition at line 86 of file activity.hh.

References activityCount, and X86ISA::count.

void ActivityRecorder::validate ( )

Debug function to ensure that the activity count matches the contents of the time buffer.

Definition at line 153 of file activity.cc.

References activityBuffer, activityCount, X86ISA::count, ArmISA::i, longestLatency, numStages, and stageActive.

Member Data Documentation

std::string ActivityRecorder::_name
private

Definition at line 107 of file activity.hh.

Referenced by name().

TimeBuffer<bool> ActivityRecorder::activityBuffer
private

Time buffer that tracks if any cycles has active communication in them.

It should be as long as the longest communication latency in the system. Each time any time buffer is written, the activity buffer should also be written to. The activityBuffer is advanced along with all the other time buffers, so it should have a 1 somewhere in it only if there is active communication in a time buffer.

Definition at line 117 of file activity.hh.

Referenced by activity(), advance(), dump(), reset(), and validate().

int ActivityRecorder::activityCount
private

Tracks how many stages and cycles of time buffer have activity.

Stages increment this count when they switch to active, and decrement it when they switch to inactive. Whenever a cycle that previously had no information is written in the time buffer, this is incremented. When a cycle that had information exits the time buffer due to age, this count is decremented. When the count is 0, there is no activity in the CPU, and it can be descheduled.

Definition at line 131 of file activity.hh.

Referenced by activateStage(), active(), activity(), advance(), deactivateStage(), dump(), getActivityCount(), reset(), setActivityCount(), and validate().

int ActivityRecorder::longestLatency
private

Longest latency time buffer in the CPU.

Definition at line 120 of file activity.hh.

Referenced by advance(), dump(), reset(), and validate().

int ActivityRecorder::numStages
private

Number of stages that can be marked as active or inactive.

Definition at line 134 of file activity.hh.

Referenced by ActivityRecorder(), dump(), getNumStages(), reset(), and validate().

bool* ActivityRecorder::stageActive
private

Records which stages are active/inactive.

Definition at line 137 of file activity.hh.

Referenced by activateStage(), ActivityRecorder(), deactivateStage(), dump(), getStageActive(), reset(), validate(), and ~ActivityRecorder().


The documentation for this class was generated from the following files:

Generated on Fri Jun 9 2017 13:04:00 for gem5 by doxygen 1.8.6