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

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>

Inheritance diagram for TrafficGen:
MemObject ClockedObject SimObject Clocked EventManager Serializable Drainable

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 ()
 
BaseMasterPortgetMasterPort (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 Paramsparams () const
 
 MemObject (const Params *params)
 
virtual BaseSlavePortgetSlavePort (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 Paramsparams () 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 Paramsparams () 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...
 
ProbeManagergetProbeManager ()
 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)
 
EventQueueeventQueue () 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

Systemsystem
 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::noProgressnoProgressEvent
 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::updateupdateEvent
 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 SimObjectfind (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
 
Clockedoperator= (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
EventQueueeventq
 A pointer to this object's event queue. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

TrafficGen::TrafficGen ( const TrafficGenParams *  p)

Definition at line 57 of file traffic_gen.cc.

TrafficGen::~TrafficGen ( )
inline

Definition at line 226 of file traffic_gen.hh.

Member Function Documentation

DrainState TrafficGen::drain ( )
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.

Note
An object that has entered the Drained state can be disturbed by other objects in the system and consequently stop being drained. These perturbations are not visible in the drain state. The simulator therefore repeats the draining process until all objects return DrainState::Drained on the first call to drain().
Returns
DrainState::Drained if the object is drained at this point in time, DrainState::Draining if it needs further simulation.

Implements Drainable.

Definition at line 127 of file traffic_gen.cc.

References EventManager::deschedule(), Drained, Draining, MaxTick, nextPacketTick, nextTransitionTick, retryPkt, Event::scheduled(), and updateEvent.

void TrafficGen::enterState ( uint32_t  newState)
private

Enter a new state.

Parameters
newStateidentifier 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().

BaseMasterPort & TrafficGen::getMasterPort ( const std::string &  if_name,
PortID  idx = InvalidPortID 
)
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.

Parameters
if_namePort name
idxIndex in the case of a VectorPort
Returns
A reference to the given port

Reimplemented from MemObject.

Definition at line 83 of file traffic_gen.cc.

References MemObject::getMasterPort(), and port.

void TrafficGen::init ( )
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.

void TrafficGen::initState ( )
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.

void TrafficGen::noProgress ( )
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.

void TrafficGen::parseConfig ( )
private
void TrafficGen::recvReqRetry ( )
private
void TrafficGen::regStats ( )
overridevirtual
std::string TrafficGen::resolveFile ( const std::string &  name)
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.

Parameters
namePath to resolve

Definition at line 236 of file traffic_gen.cc.

References configFile, csprintf(), and SimObject::name().

Referenced by parseConfig().

void TrafficGen::serialize ( CheckpointOut cp) const
overridevirtual

Serialize an object.

Output an object's state into the current checkpoint section.

Parameters
cpCheckpoint 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().

void TrafficGen::transition ( )
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().

void TrafficGen::unserialize ( CheckpointIn cp)
overridevirtual

Unserialize an object.

Read an object's state from the current checkpoint section.

Parameters
cpCheckpoint state

Implements Serializable.

Definition at line 165 of file traffic_gen.cc.

References currState, nextPacketTick, nextTransitionTick, EventManager::schedule(), UNSERIALIZE_SCALAR, and updateEvent.

void TrafficGen::update ( )
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.

Member Data Documentation

const std::string TrafficGen::configFile
private

The config file to parse.

Definition at line 138 of file traffic_gen.hh.

Referenced by parseConfig(), and resolveFile().

uint32_t TrafficGen::currState
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().

const bool TrafficGen::elasticReq
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().

MasterID TrafficGen::masterID
private

MasterID used in generated requests.

Definition at line 133 of file traffic_gen.hh.

Referenced by parseConfig().

Tick TrafficGen::nextPacketTick
private

Time of the next packet.

Definition at line 161 of file traffic_gen.hh.

Referenced by drain(), initState(), recvReqRetry(), serialize(), unserialize(), and update().

Tick TrafficGen::nextTransitionTick
private

Time of next transition.

Definition at line 158 of file traffic_gen.hh.

Referenced by drain(), enterState(), initState(), recvReqRetry(), serialize(), unserialize(), and update().

EventWrapper<TrafficGen, &TrafficGen::noProgress> TrafficGen::noProgressEvent
private

Event to keep track of our progress, or lack thereof.

Definition at line 155 of file traffic_gen.hh.

Referenced by update().

Stats::Scalar TrafficGen::numPackets
private

Count the number of generated packets.

Definition at line 214 of file traffic_gen.hh.

Referenced by regStats(), and update().

Stats::Scalar TrafficGen::numRetries
private

Count the number of retries.

Definition at line 217 of file traffic_gen.hh.

Referenced by recvReqRetry(), and regStats().

uint64_t TrafficGen::numSuppressed
private

Definition at line 211 of file traffic_gen.hh.

Referenced by update().

TrafficGenPort TrafficGen::port
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().

const Tick TrafficGen::progressCheck
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().

PacketPtr TrafficGen::retryPkt
private

Packet waiting to be sent.

Definition at line 203 of file traffic_gen.hh.

Referenced by drain(), recvReqRetry(), and update().

Tick TrafficGen::retryPktTick
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().

Stats::Scalar TrafficGen::retryTicks
private

Count the time incurred from back-pressure.

Definition at line 220 of file traffic_gen.hh.

Referenced by recvReqRetry(), and regStats().

std::unordered_map<uint32_t, BaseGen*> TrafficGen::states
private

Map of generator states.

Definition at line 170 of file traffic_gen.hh.

Referenced by enterState(), initState(), parseConfig(), recvReqRetry(), transition(), and update().

System* TrafficGen::system
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().

std::vector<std::vector<double> > TrafficGen::transitionMatrix
private

State transition matrix.

Definition at line 164 of file traffic_gen.hh.

Referenced by parseConfig(), and transition().

EventWrapper<TrafficGen, &TrafficGen::update> TrafficGen::updateEvent
private

Event for scheduling updates.

Definition at line 209 of file traffic_gen.hh.

Referenced by drain(), initState(), recvReqRetry(), serialize(), unserialize(), and update().


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

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