gem5  v20.1.0.0
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 50 of file activity.hh.

Constructor & Destructor Documentation

◆ ActivityRecorder()

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

Definition at line 38 of file activity.cc.

References numStages, and stageActive.

◆ ~ActivityRecorder()

ActivityRecorder::~ActivityRecorder ( )

Definition at line 48 of file activity.cc.

References stageActive.

Member Function Documentation

◆ activateStage()

void ActivityRecorder::activateStage ( const int  idx)

◆ active()

bool ActivityRecorder::active ( )
inline

Returns if the CPU should be active.

Definition at line 88 of file activity.hh.

References activityCount.

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

◆ activity()

void ActivityRecorder::activity ( )

◆ advance()

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 70 of file activity.cc.

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

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

◆ deactivateStage()

void ActivityRecorder::deactivateStage ( const int  idx)

Deactivates a stage.

Definition at line 107 of file activity.cc.

References activityCount, DPRINTF, and stageActive.

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

◆ dump()

void ActivityRecorder::dump ( )

Debug function to dump the contents of the time buffer.

Definition at line 133 of file activity.cc.

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

◆ getActivityCount()

int ActivityRecorder::getActivityCount ( ) const
inline

Returns how many things are active within the recorder.

Definition at line 79 of file activity.hh.

References activityCount.

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

◆ getNumStages()

int ActivityRecorder::getNumStages ( ) const
inline

Returns the number of stages.

Definition at line 76 of file activity.hh.

References numStages.

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

◆ getStageActive()

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

Returns the activity status of a stage.

Definition at line 73 of file activity.hh.

References stageActive.

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

◆ name()

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

Definition at line 101 of file activity.hh.

References _name.

◆ reset()

void ActivityRecorder::reset ( )

Clears the time buffer and the activity count.

Definition at line 124 of file activity.cc.

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

Referenced by MinorCPU::switchOut().

◆ setActivityCount()

void ActivityRecorder::setActivityCount ( int  count)
inline

Sets the count to a starting value.

Can be used to disable the idling option.

Definition at line 84 of file activity.hh.

References activityCount, and X86ISA::count.

◆ validate()

void ActivityRecorder::validate ( )

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

Definition at line 151 of file activity.cc.

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

Member Data Documentation

◆ _name

std::string ActivityRecorder::_name
private

Definition at line 105 of file activity.hh.

Referenced by name().

◆ activityBuffer

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 115 of file activity.hh.

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

◆ activityCount

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 129 of file activity.hh.

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

◆ longestLatency

int ActivityRecorder::longestLatency
private

Longest latency time buffer in the CPU.

Definition at line 118 of file activity.hh.

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

◆ numStages

int ActivityRecorder::numStages
private

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

Definition at line 132 of file activity.hh.

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

◆ stageActive

bool* ActivityRecorder::stageActive
private

Records which stages are active/inactive.

Definition at line 135 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 Wed Sep 30 2020 14:02:20 for gem5 by doxygen 1.8.17