gem5 v24.0.0.0
|
ActivityRecorder helper class that informs the CPU if it can switch over to being idle or not. More...
#include <activity.hh>
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. | |
void | advance () |
Advances the activity buffer, decrementing the activityCount if active communication just left the time buffer, and determining if there is no activity. | |
void | activateStage (const int idx) |
Marks a stage as active. | |
void | deactivateStage (const int idx) |
Deactivates a stage. | |
bool | getStageActive (const int idx) const |
Returns the activity status of a stage. | |
int | getNumStages () const |
Returns the number of stages. | |
int | getActivityCount () const |
Returns how many things are active within the recorder. | |
void | setActivityCount (int count) |
Sets the count to a starting value. | |
bool | active () |
Returns if the CPU should be active. | |
void | reset () |
Clears the time buffer and the activity count. | |
void | dump () |
Debug function to dump the contents of the time buffer. | |
void | validate () |
Debug function to ensure that the activity count matches the contents of the time buffer. | |
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. | |
int | longestLatency |
Longest latency time buffer in the CPU. | |
int | activityCount |
Tracks how many stages and cycles of time buffer have activity. | |
int | numStages |
Number of stages that can be marked as active or inactive. | |
bool * | stageActive |
Records which stages are active/inactive. | |
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.
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.
gem5::ActivityRecorder::~ActivityRecorder | ( | ) |
Definition at line 49 of file activity.cc.
References stageActive.
void gem5::ActivityRecorder::activateStage | ( | const int | idx | ) |
Marks a stage as active.
Definition at line 91 of file activity.cc.
References activityCount, DPRINTF, and stageActive.
Referenced by gem5::o3::CPU::activateStage(), gem5::minor::Decode::evaluate(), gem5::minor::Fetch2::evaluate(), and gem5::MinorCPU::wakeupOnEvent().
|
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().
void gem5::ActivityRecorder::activity | ( | ) |
Records that there is activity this cycle.
Definition at line 55 of file activity.cc.
References activityBuffer, activityCount, and DPRINTF.
Referenced by gem5::o3::CPU::activateContext(), gem5::o3::CPU::activityThisCycle(), gem5::o3::CPU::drain(), gem5::minor::Decode::evaluate(), gem5::minor::Execute::evaluate(), gem5::minor::Fetch1::evaluate(), gem5::minor::Fetch2::evaluate(), and gem5::minor::Execute::issue().
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().
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().
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.
|
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().
|
inline |
Returns the number of stages.
Definition at line 79 of file activity.hh.
References numStages.
Referenced by gem5::minor::MinorActivityRecorder::minorTrace().
|
inline |
Returns the activity status of a stage.
Definition at line 76 of file activity.hh.
References stageActive.
Referenced by gem5::minor::MinorActivityRecorder::minorTrace().
|
inline |
Definition at line 104 of file activity.hh.
References _name.
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().
|
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.
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.
|
private |
Definition at line 108 of file activity.hh.
Referenced by name().
|
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().
|
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().
|
private |
Longest latency time buffer in the CPU.
Definition at line 121 of file activity.hh.
Referenced by advance(), dump(), reset(), and validate().
|
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().
|
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().