gem5
|
The traffic generator is a master module that generates stimuli for the memory system, based on a collection of simple generator behaviours that are either probabilistic or based on traces. More...
#include <traffic_gen.hh>
Classes | |
class | TrafficGenPort |
Master port specialisation for the traffic generator. More... | |
struct | Transition |
Struct to represent a probabilistic transition during parsing. More... | |
Public Member Functions | |
TrafficGen (const TrafficGenParams *p) | |
~TrafficGen () | |
BaseMasterPort & | getMasterPort (const std::string &if_name, PortID idx=InvalidPortID) override |
Get a master port with a given name and index. More... | |
void | init () override |
init() is called after all C++ SimObjects have been created and all ports are connected. More... | |
void | initState () override |
initState() is called on each SimObject when not restoring from a checkpoint. More... | |
DrainState | drain () override |
Notify an object that it needs to drain its state. More... | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. More... | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. More... | |
void | regStats () override |
Register statistics. More... | |
Public Member Functions inherited from MemObject | |
const Params * | params () const |
MemObject (const Params *params) | |
virtual BaseSlavePort & | getSlavePort (const std::string &if_name, PortID idx=InvalidPortID) |
Get a slave port with a given name and index. More... | |
Public Member Functions inherited from ClockedObject | |
ClockedObject (const ClockedObjectParams *p) | |
const Params * | params () const |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. More... | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. More... | |
Enums::PwrState | pwrState () const |
std::string | pwrStateName () const |
std::vector< double > | pwrStateWeights () const |
Returns the percentage residency for each power state. More... | |
void | computeStats () |
Record stats values like state residency by computing the time difference from previous update. More... | |
void | pwrState (Enums::PwrState) |
void | regStats () override |
Register statistics for this object. More... | |
Public Member Functions inherited from SimObject | |
const Params * | params () const |
SimObject (const Params *_params) | |
virtual | ~SimObject () |
virtual const std::string | name () const |
virtual void | loadState (CheckpointIn &cp) |
loadState() is called on each SimObject when restoring from a checkpoint. More... | |
virtual void | resetStats () |
Reset statistics associated with this object. More... | |
virtual void | regProbePoints () |
Register probe points for this object. More... | |
virtual void | regProbeListeners () |
Register probe listeners for this object. More... | |
ProbeManager * | getProbeManager () |
Get the probe manager for this object. More... | |
virtual void | startup () |
startup() is the final initialization call before simulation. More... | |
DrainState | drain () override |
Provide a default implementation of the drain interface for objects that don't need draining. More... | |
virtual void | memWriteback () |
Write back dirty buffers to memory using functional writes. More... | |
virtual void | memInvalidate () |
Invalidate the contents of memory buffers. More... | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. More... | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. More... | |
Public Member Functions inherited from EventManager | |
EventManager (EventManager &em) | |
EventManager (EventManager *em) | |
EventManager (EventQueue *eq) | |
EventQueue * | eventQueue () const |
void | schedule (Event &event, Tick when) |
void | deschedule (Event &event) |
void | reschedule (Event &event, Tick when, bool always=false) |
void | schedule (Event *event, Tick when) |
void | deschedule (Event *event) |
void | reschedule (Event *event, Tick when, bool always=false) |
void | wakeupEventQueue (Tick when=(Tick)-1) |
void | setCurTick (Tick newVal) |
Public Member Functions inherited from Serializable | |
Serializable () | |
virtual | ~Serializable () |
void | serializeSection (CheckpointOut &cp, const char *name) const |
Serialize an object into a new section. More... | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. More... | |
void | unserializeSection (CheckpointIn &cp, const std::string &name) |
Public Member Functions inherited from Drainable | |
DrainState | drainState () const |
Return the current drain state of an object. More... | |
virtual void | notifyFork () |
Notify a child process of a fork. More... | |
Public Member Functions inherited from Clocked | |
void | updateClockPeriod () const |
Update the tick to the current tick. More... | |
Tick | clockEdge (Cycles cycles=Cycles(0)) const |
Determine the tick when a cycle begins, by default the current one, but the argument also enables the caller to determine a future cycle. More... | |
Cycles | curCycle () const |
Determine the current cycle, corresponding to a tick aligned to a clock edge. More... | |
Tick | nextCycle () const |
Based on the clock of the object, determine the start tick of the first cycle that is at least one cycle in the future. More... | |
uint64_t | frequency () const |
Tick | clockPeriod () const |
double | voltage () const |
Cycles | ticksToCycles (Tick t) const |
Tick | cyclesToTicks (Cycles c) const |
Private Member Functions | |
void | transition () |
Determine next state and perform the transition. More... | |
void | enterState (uint32_t newState) |
Enter a new state. More... | |
std::string | resolveFile (const std::string &name) |
Resolve a file path in the configuration file. More... | |
void | parseConfig () |
Parse the config file and build the state map and transition matrix. More... | |
void | update () |
Schedules event for next update and executes an update on the state graph, either performing a state transition or executing the current state, depending on the current time. More... | |
void | recvReqRetry () |
Receive a retry from the neighbouring port and attempt to resend the waiting packet. More... | |
void | noProgress () |
Method to inform the user we have made no progress. More... | |
Private Attributes | |
System * | system |
The system used to determine which mode we are currently operating in. More... | |
MasterID | masterID |
MasterID used in generated requests. More... | |
const std::string | configFile |
The config file to parse. More... | |
const bool | elasticReq |
Determine whether to add elasticity in the request injection, thus responding to backpressure by slowing things down. More... | |
const Tick | progressCheck |
Time to tolerate waiting for retries (not making progress), until we declare things broken. More... | |
EventWrapper< TrafficGen,&TrafficGen::noProgress > | noProgressEvent |
Event to keep track of our progress, or lack thereof. More... | |
Tick | nextTransitionTick |
Time of next transition. More... | |
Tick | nextPacketTick |
Time of the next packet. More... | |
std::vector< std::vector < double > > | transitionMatrix |
State transition matrix. More... | |
uint32_t | currState |
Index of the current state. More... | |
std::unordered_map< uint32_t, BaseGen * > | states |
Map of generator states. More... | |
TrafficGenPort | port |
The instance of master port used by the traffic generator. More... | |
PacketPtr | retryPkt |
Packet waiting to be sent. More... | |
Tick | retryPktTick |
Tick when the stalled packet was meant to be sent. More... | |
EventWrapper< TrafficGen,&TrafficGen::update > | updateEvent |
Event for scheduling updates. More... | |
uint64_t | numSuppressed |
Stats::Scalar | numPackets |
Count the number of generated packets. More... | |
Stats::Scalar | numRetries |
Count the number of retries. More... | |
Stats::Scalar | retryTicks |
Count the time incurred from back-pressure. More... | |
Additional Inherited Members | |
Public Types inherited from MemObject | |
typedef MemObjectParams | Params |
Public Types inherited from ClockedObject | |
typedef ClockedObjectParams | Params |
Parameters of ClockedObject. More... | |
Public Types inherited from SimObject | |
typedef SimObjectParams | Params |
Static Public Member Functions inherited from SimObject | |
static void | serializeAll (CheckpointOut &cp) |
Serialize all SimObjects in the system. More... | |
static SimObject * | find (const char *name) |
Find the SimObject with the given name and return a pointer to it. More... | |
Static Public Member Functions inherited from Serializable | |
static const std::string & | currentSection () |
Get the fully-qualified name of the active section. More... | |
static void | serializeAll (const std::string &cpt_dir) |
static void | unserializeGlobals (CheckpointIn &cp) |
Static Public Attributes inherited from Serializable | |
static int | ckptCount = 0 |
static int | ckptMaxCount = 0 |
static int | ckptPrevCount = -1 |
Protected Member Functions inherited from Drainable | |
Drainable () | |
virtual | ~Drainable () |
virtual void | drainResume () |
Resume execution after a successful drain. More... | |
void | signalDrainDone () const |
Signal that an object is drained. More... | |
Protected Member Functions inherited from Clocked | |
Clocked (ClockDomain &clk_domain) | |
Create a clocked object and set the clock domain based on the parameters. More... | |
Clocked (Clocked &)=delete | |
Clocked & | operator= (Clocked &)=delete |
virtual | ~Clocked () |
Virtual destructor due to inheritance. More... | |
void | resetClock () const |
Reset the object's clock using the current global tick value. More... | |
Protected Attributes inherited from ClockedObject | |
Enums::PwrState | _currPwrState |
To keep track of the current power state. More... | |
Tick | prvEvalTick |
Stats::Scalar | numPwrStateTransitions |
Stats::Distribution | pwrStateClkGateDist |
Stats::Vector | pwrStateResidencyTicks |
Protected Attributes inherited from SimObject | |
const SimObjectParams * | _params |
Cached copy of the object parameters. More... | |
Protected Attributes inherited from EventManager | |
EventQueue * | eventq |
A pointer to this object's event queue. More... | |
The traffic generator is a master module that generates stimuli for the memory system, based on a collection of simple generator behaviours that are either probabilistic or based on traces.
It can be used stand alone for creating test cases for interconnect and memory controllers, or function as a black box replacement for system components that are not yet modelled in detail, e.g. a video engine or baseband subsystem.
Definition at line 61 of file traffic_gen.hh.
TrafficGen::TrafficGen | ( | const TrafficGenParams * | p | ) |
Definition at line 57 of file traffic_gen.cc.
|
inline |
Definition at line 226 of file traffic_gen.hh.
|
overridevirtual |
Notify an object that it needs to drain its state.
If the object does not need further simulation to drain internal buffers, it returns DrainState::Drained and automatically switches to the Drained state. If the object needs more simulation, it returns DrainState::Draining and automatically enters the Draining state. Other return values are invalid.
Implements Drainable.
Definition at line 127 of file traffic_gen.cc.
References EventManager::deschedule(), Drained, Draining, MaxTick, nextPacketTick, nextTransitionTick, retryPkt, Event::scheduled(), and updateEvent.
|
private |
Enter a new state.
newState | identifier of state to enter |
Definition at line 499 of file traffic_gen.cc.
References currState, curTick(), DPRINTF, nextTransitionTick, and states.
Referenced by init(), and transition().
|
overridevirtual |
Get a master port with a given name and index.
This is used at binding time and returns a reference to a protocol-agnostic base master port.
if_name | Port name |
idx | Index in the case of a VectorPort |
Reimplemented from MemObject.
Definition at line 83 of file traffic_gen.cc.
References MemObject::getMasterPort(), and port.
|
overridevirtual |
init() is called after all C++ SimObjects have been created and all ports are connected.
Initializations that are independent of unserialization but rely on a fully instantiated and connected SimObject graph should be done here.
Reimplemented from SimObject.
Definition at line 93 of file traffic_gen.cc.
References currState, DPRINTF, enterState(), fatal, BaseMasterPort::isConnected(), System::isTimingMode(), SimObject::name(), parseConfig(), port, and system.
|
overridevirtual |
initState() is called on each SimObject when not restoring from a checkpoint.
This provides a hook for state initializations that are only required for a "cold start".
Reimplemented from SimObject.
Definition at line 113 of file traffic_gen.cc.
References currState, DPRINTF, elasticReq, System::isTimingMode(), nextPacketTick, nextTransitionTick, EventManager::schedule(), states, system, and updateEvent.
|
private |
Method to inform the user we have made no progress.
Definition at line 545 of file traffic_gen.cc.
References fatal, SimObject::name(), and progressCheck.
|
private |
Parse the config file and build the state map and transition matrix.
Definition at line 257 of file traffic_gen.cc.
References System::cacheLineSize(), configFile, currState, divCeil(), DPRINTF, fatal, TrafficGen::Transition::from, ArmISA::i, SparcISA::id, MipsISA::is, ArmISA::j, masterID, ArmISA::mode, SimObject::name(), TrafficGen::Transition::p, resolveFile(), states, Stats::sum(), system, ArmISA::t, TrafficGen::Transition::to, transition(), transitionMatrix, and warn.
Referenced by init().
|
private |
Receive a retry from the neighbouring port and attempt to resend the waiting packet.
Definition at line 512 of file traffic_gen.cc.
References currState, curTick(), DPRINTF, Draining, Drainable::drainState(), elasticReq, MaxTick, nextPacketTick, nextTransitionTick, numRetries, port, retryPkt, retryPktTick, retryTicks, EventManager::schedule(), MasterPort::sendTimingReq(), Drainable::signalDrainDone(), states, and updateEvent.
Referenced by TrafficGen::TrafficGenPort::recvReqRetry().
|
overridevirtual |
Register statistics.
Reimplemented from SimObject.
Definition at line 552 of file traffic_gen.cc.
References Stats::DataWrap< Derived, InfoProxyType >::desc(), SimObject::name(), Stats::DataWrap< Derived, InfoProxyType >::name(), numPackets, numRetries, ClockedObject::regStats(), and retryTicks.
|
private |
Resolve a file path in the configuration file.
This method resolves a relative path to a file that has been referenced in the configuration file. It first tries to resolve the file relative to the configuration file's path. If that fails, it falls back to constructing a path relative to the current working directory.
Absolute paths are returned unmodified.
name | Path to resolve |
Definition at line 236 of file traffic_gen.cc.
References configFile, csprintf(), and SimObject::name().
Referenced by parseConfig().
|
overridevirtual |
Serialize an object.
Output an object's state into the current checkpoint section.
cp | Checkpoint state |
Implements Serializable.
Definition at line 146 of file traffic_gen.cc.
References currState, DPRINTF, nextPacketTick, nextTransitionTick, Event::scheduled(), SERIALIZE_SCALAR, updateEvent, and Event::when().
|
private |
Determine next state and perform the transition.
Definition at line 480 of file traffic_gen.cc.
References currState, enterState(), ArmISA::i, MipsISA::p, Random::random(), random_mt, X86ISA::size(), states, and transitionMatrix.
Referenced by parseConfig(), and update().
|
overridevirtual |
Unserialize an object.
Read an object's state from the current checkpoint section.
cp | Checkpoint state |
Implements Serializable.
Definition at line 165 of file traffic_gen.cc.
References currState, nextPacketTick, nextTransitionTick, EventManager::schedule(), UNSERIALIZE_SCALAR, and updateEvent.
|
private |
Schedules event for next update and executes an update on the state graph, either performing a state transition or executing the current state, depending on the current time.
Definition at line 185 of file traffic_gen.cc.
References Packet::cmdString(), currState, curTick(), DPRINTF, elasticReq, Packet::getAddr(), System::isMemAddr(), SimObject::name(), nextPacketTick, nextTransitionTick, noProgressEvent, numPackets, numSuppressed, port, progressCheck, Packet::req, EventManager::reschedule(), retryPkt, retryPktTick, EventManager::schedule(), MasterPort::sendTimingReq(), states, system, transition(), updateEvent, and warn.
|
private |
The config file to parse.
Definition at line 138 of file traffic_gen.hh.
Referenced by parseConfig(), and resolveFile().
|
private |
Index of the current state.
Definition at line 167 of file traffic_gen.hh.
Referenced by enterState(), init(), initState(), parseConfig(), recvReqRetry(), serialize(), transition(), unserialize(), and update().
|
private |
Determine whether to add elasticity in the request injection, thus responding to backpressure by slowing things down.
Definition at line 144 of file traffic_gen.hh.
Referenced by initState(), recvReqRetry(), and update().
|
private |
MasterID used in generated requests.
Definition at line 133 of file traffic_gen.hh.
Referenced by parseConfig().
|
private |
Time of the next packet.
Definition at line 161 of file traffic_gen.hh.
Referenced by drain(), initState(), recvReqRetry(), serialize(), unserialize(), and update().
|
private |
Time of next transition.
Definition at line 158 of file traffic_gen.hh.
Referenced by drain(), enterState(), initState(), recvReqRetry(), serialize(), unserialize(), and update().
|
private |
Event to keep track of our progress, or lack thereof.
Definition at line 155 of file traffic_gen.hh.
Referenced by update().
|
private |
Count the number of generated packets.
Definition at line 214 of file traffic_gen.hh.
Referenced by regStats(), and update().
|
private |
Count the number of retries.
Definition at line 217 of file traffic_gen.hh.
Referenced by recvReqRetry(), and regStats().
|
private |
Definition at line 211 of file traffic_gen.hh.
Referenced by update().
|
private |
The instance of master port used by the traffic generator.
Definition at line 200 of file traffic_gen.hh.
Referenced by getMasterPort(), init(), recvReqRetry(), and update().
|
private |
Time to tolerate waiting for retries (not making progress), until we declare things broken.
Definition at line 150 of file traffic_gen.hh.
Referenced by noProgress(), and update().
|
private |
Packet waiting to be sent.
Definition at line 203 of file traffic_gen.hh.
Referenced by drain(), recvReqRetry(), and update().
|
private |
Tick when the stalled packet was meant to be sent.
Definition at line 206 of file traffic_gen.hh.
Referenced by recvReqRetry(), and update().
|
private |
Count the time incurred from back-pressure.
Definition at line 220 of file traffic_gen.hh.
Referenced by recvReqRetry(), and regStats().
|
private |
Map of generator states.
Definition at line 170 of file traffic_gen.hh.
Referenced by enterState(), initState(), parseConfig(), recvReqRetry(), transition(), and update().
|
private |
The system used to determine which mode we are currently operating in.
Definition at line 128 of file traffic_gen.hh.
Referenced by init(), initState(), parseConfig(), and update().
|
private |
State transition matrix.
Definition at line 164 of file traffic_gen.hh.
Referenced by parseConfig(), and transition().
|
private |
Event for scheduling updates.
Definition at line 209 of file traffic_gen.hh.
Referenced by drain(), initState(), recvReqRetry(), serialize(), unserialize(), and update().