gem5  v21.1.0.2
Public Member Functions | Private Attributes | List of all members
gem5::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 gem5::ActivityRecorder:
gem5::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 53 of file activity.hh.

Constructor & Destructor Documentation

◆ ActivityRecorder()

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

Definition at line 39 of file activity.cc.

References numStages, and stageActive.

◆ ~ActivityRecorder()

gem5::ActivityRecorder::~ActivityRecorder ( )

Definition at line 49 of file activity.cc.

References stageActive.

Member Function Documentation

◆ activateStage()

void gem5::ActivityRecorder::activateStage ( const int  idx)

◆ active()

bool gem5::ActivityRecorder::active ( )
inline

Returns if the CPU should be active.

Definition at line 91 of file activity.hh.

References activityCount.

Referenced by gem5::minor::Pipeline::evaluate(), gem5::o3::CPU::tick(), and gem5::o3::CPU::wakeCPU().

◆ activity()

void gem5::ActivityRecorder::activity ( )

◆ advance()

void gem5::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 71 of file activity.cc.

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

Referenced by gem5::minor::MinorActivityRecorder::evaluate(), and gem5::o3::CPU::tick().

◆ deactivateStage()

void gem5::ActivityRecorder::deactivateStage ( const int  idx)

Deactivates a stage.

Definition at line 108 of file activity.cc.

References activityCount, DPRINTF, and stageActive.

Referenced by gem5::o3::CPU::deactivateStage(), and gem5::minor::Pipeline::evaluate().

◆ dump()

void gem5::ActivityRecorder::dump ( )

Debug function to dump the contents of the time buffer.

Definition at line 134 of file activity.cc.

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

◆ getActivityCount()

int gem5::ActivityRecorder::getActivityCount ( ) const
inline

Returns how many things are active within the recorder.

Definition at line 82 of file activity.hh.

References activityCount.

Referenced by gem5::minor::MinorActivityRecorder::minorTrace().

◆ getNumStages()

int gem5::ActivityRecorder::getNumStages ( ) const
inline

Returns the number of stages.

Definition at line 79 of file activity.hh.

References numStages.

Referenced by gem5::minor::MinorActivityRecorder::minorTrace().

◆ getStageActive()

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

Returns the activity status of a stage.

Definition at line 76 of file activity.hh.

References stageActive.

Referenced by gem5::minor::MinorActivityRecorder::minorTrace().

◆ name()

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

Definition at line 104 of file activity.hh.

References _name.

◆ reset()

void gem5::ActivityRecorder::reset ( )

Clears the time buffer and the activity count.

Definition at line 125 of file activity.cc.

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

Referenced by gem5::MinorCPU::switchOut(), and gem5::o3::CPU::switchOut().

◆ setActivityCount()

void gem5::ActivityRecorder::setActivityCount ( int  count)
inline

Sets the count to a starting value.

Can be used to disable the idling option.

Definition at line 87 of file activity.hh.

References activityCount, and gem5::X86ISA::count.

◆ validate()

void gem5::ActivityRecorder::validate ( )

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

Definition at line 152 of file activity.cc.

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

Member Data Documentation

◆ _name

std::string gem5::ActivityRecorder::_name
private

Definition at line 108 of file activity.hh.

Referenced by name().

◆ activityBuffer

TimeBuffer<bool> gem5::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 118 of file activity.hh.

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

◆ activityCount

int gem5::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 132 of file activity.hh.

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

◆ longestLatency

int gem5::ActivityRecorder::longestLatency
private

Longest latency time buffer in the CPU.

Definition at line 121 of file activity.hh.

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

◆ numStages

int gem5::ActivityRecorder::numStages
private

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

Definition at line 135 of file activity.hh.

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

◆ stageActive

bool* gem5::ActivityRecorder::stageActive
private

Records which stages are active/inactive.

Definition at line 138 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 Tue Sep 21 2021 12:27:11 for gem5 by doxygen 1.8.17