gem5 v24.0.0.0
Loading...
Searching...
No Matches
gem5::TraceCPU::ElasticDataGen Class Reference

The elastic data memory request generator to read protobuf trace containing execution trace annotated with data and ordering dependencies. More...

#include <trace_cpu.hh>

Classes

struct  ElasticDataGenStatGroup
 
class  GraphNode
 The struct GraphNode stores an instruction in the trace file. More...
 
class  HardwareResource
 The HardwareResource class models structures that hold the in-flight nodes. More...
 
class  InputStream
 The InputStream encapsulates a trace file and the internal buffers and populates GraphNodes based on the input. More...
 
struct  ReadyNode
 Struct to store a ready-to-execute node and its execution tick. More...
 

Public Member Functions

 ElasticDataGen (TraceCPU &_owner, const std::string &_name, RequestPort &_port, RequestorID requestor_id, const std::string &trace_file, const TraceCPUParams &params)
 
Tick init ()
 Called from TraceCPU init().
 
void adjustInitTraceOffset (Tick &offset)
 Adjust traceOffset based on what TraceCPU init() determines on comparing the offsets in the fetch request and elastic traces.
 
const std::string & name () const
 Returns name of the ElasticDataGen instance.
 
void exit ()
 Exit the ElasticDataGen.
 
bool readNextWindow ()
 Reads a line of the trace file.
 
template<typename T >
void addDepsOnParent (GraphNode *new_node, T &dep_list)
 Iterate over the dependencies of a new node and add the new node to the list of dependents of the parent node.
 
void execute ()
 This is the main execute function which consumes nodes from the sorted readyList.
 
PacketPtr executeMemReq (GraphNode *node_ptr)
 Creates a new request for a load or store assigning the request parameters.
 
void addToSortedReadyList (NodeSeqNum seq_num, Tick exec_tick)
 Add a ready node to the readyList.
 
void printReadyList ()
 Print readyList for debugging using debug flag TraceCPUData.
 
void completeMemAccess (PacketPtr pkt)
 When a load writeback is received, that is when the load completes, release the dependents on it.
 
bool isExecComplete () const
 Returns the execComplete variable which is set when the last node is executed.
 
bool checkAndIssue (const GraphNode *node_ptr, bool first=true)
 Attempts to issue a node once the node's source dependencies are complete.
 
uint64_t getMicroOpCount () const
 Get number of micro-ops modelled in the TraceCPU replay.
 

Protected Attributes

gem5::TraceCPU::ElasticDataGen::ElasticDataGenStatGroup elasticStats
 

Private Types

typedef uint64_t NodeSeqNum
 Node sequence number type.
 
typedef uint64_t NodeRobNum
 Node ROB number type.
 
typedef ProtoMessage::InstDepRecord::RecordType RecordType
 
typedef ProtoMessage::InstDepRecord Record
 

Private Attributes

TraceCPUowner
 Reference of the TraceCPU.
 
RequestPortport
 Reference of the port to be used to issue memory requests.
 
const RequestorID requestorId
 RequestorID used for the requests being sent.
 
InputStream trace
 Input stream used for reading the input trace file.
 
std::string genName
 String to store the name of the FixedRetryGen.
 
PacketPtr retryPkt
 PacketPtr used to store the packet to retry.
 
bool traceComplete
 Set to true when end of trace is reached.
 
bool nextRead
 Set to true when the next window of instructions need to be read.
 
bool execComplete
 Set true when execution of trace is complete.
 
const uint32_t windowSize
 Window size within which to check for dependencies.
 
HardwareResource hwResource
 Hardware resources required to contain in-flight nodes and to throttle issuing of new nodes when resources are not available.
 
std::unordered_map< NodeSeqNum, GraphNode * > depGraph
 Store the depGraph of GraphNodes.
 
std::queue< const GraphNode * > depFreeQueue
 Queue of dependency-free nodes that are pending issue because resources are not available.
 
std::list< ReadyNodereadyList
 List of nodes that are ready to execute.
 

Detailed Description

The elastic data memory request generator to read protobuf trace containing execution trace annotated with data and ordering dependencies.

It deduces the time at which to send a load/store request by tracking the dependencies. It attempts to send a memory request for a load/store without performing real execution of micro-ops. If L1 cache port sends packet succesfully, the generator checks which instructions became dependency free as a result of this and schedules an event accordingly. If it fails to send the packet, it waits for a retry from the cache.

Definition at line 524 of file trace_cpu.hh.

Member Typedef Documentation

◆ NodeRobNum

Node ROB number type.

Definition at line 531 of file trace_cpu.hh.

◆ NodeSeqNum

Node sequence number type.

Definition at line 528 of file trace_cpu.hh.

◆ Record

typedef ProtoMessage::InstDepRecord gem5::TraceCPU::ElasticDataGen::Record
private

Definition at line 534 of file trace_cpu.hh.

◆ RecordType

typedef ProtoMessage::InstDepRecord::RecordType gem5::TraceCPU::ElasticDataGen::RecordType
private

Definition at line 533 of file trace_cpu.hh.

Constructor & Destructor Documentation

◆ ElasticDataGen()

gem5::TraceCPU::ElasticDataGen::ElasticDataGen ( TraceCPU & _owner,
const std::string & _name,
RequestPort & _port,
RequestorID requestor_id,
const std::string & trace_file,
const TraceCPUParams & params )
inline

Definition at line 805 of file trace_cpu.hh.

References DPRINTF, and windowSize.

Member Function Documentation

◆ addDepsOnParent()

template<typename T >
void gem5::TraceCPU::ElasticDataGen::addDepsOnParent ( GraphNode * new_node,
T & dep_list )

Iterate over the dependencies of a new node and add the new node to the list of dependents of the parent node.

Parameters
new_nodenew node to add to the graph
Template Parameters
dep_listthe dependency list of type rob or register, that is to be iterated, and may get modified

Definition at line 344 of file trace_cpu.cc.

References depGraph, elasticStats, gem5::TraceCPU::ElasticDataGen::ElasticDataGenStatGroup::maxDependents, and gem5::statistics::ScalarBase< Derived, Stor >::value().

Referenced by readNextWindow().

◆ addToSortedReadyList()

void gem5::TraceCPU::ElasticDataGen::addToSortedReadyList ( NodeSeqNum seq_num,
Tick exec_tick )

Add a ready node to the readyList.

When inserting, ensure the nodes are sorted in ascending order of their execute ticks.

Parameters
seq_numseq. num of ready node
exec_tickthe execute tick of the ready node

Definition at line 748 of file trace_cpu.cc.

References elasticStats, gem5::TraceCPU::ElasticDataGen::ReadyNode::execTick, gem5::TraceCPU::ElasticDataGen::ElasticDataGenStatGroup::maxReadyListSize, readyList, gem5::Packet::req, retryPkt, gem5::TraceCPU::ElasticDataGen::ReadyNode::seqNum, and gem5::statistics::ScalarBase< Derived, Stor >::value().

Referenced by checkAndIssue().

◆ adjustInitTraceOffset()

void gem5::TraceCPU::ElasticDataGen::adjustInitTraceOffset ( Tick & offset)

Adjust traceOffset based on what TraceCPU init() determines on comparing the offsets in the fetch request and elastic traces.

Parameters
trace_offsettrace offset set by comparing both traces

Definition at line 277 of file trace_cpu.cc.

References gem5::ArmISA::offset, and readyList.

Referenced by gem5::TraceCPU::init().

◆ checkAndIssue()

bool gem5::TraceCPU::ElasticDataGen::checkAndIssue ( const GraphNode * node_ptr,
bool first = true )

Attempts to issue a node once the node's source dependencies are complete.

If resources are available then add it to the readyList, otherwise the node is not issued and is stored in depFreeQueue until resources become available.

Parameters
node_ptrpointer to node to be issued
firsttrue if this is the first attempt to issue this node
Returns
true if node was added to readyList

Definition at line 641 of file trace_cpu.cc.

References addToSortedReadyList(), gem5::Clocked::clockEdge(), gem5::TraceCPU::ElasticDataGen::GraphNode::compDelay, depFreeQueue, DPRINTFR, hwResource, gem5::TraceCPU::ElasticDataGen::HardwareResource::isAvailable(), gem5::TraceCPU::ElasticDataGen::HardwareResource::occupy(), owner, gem5::TraceCPU::ElasticDataGen::GraphNode::regDep, gem5::TraceCPU::ElasticDataGen::GraphNode::robDep, gem5::TraceCPU::ElasticDataGen::GraphNode::robNum, gem5::TraceCPU::ElasticDataGen::GraphNode::seqNum, and gem5::TraceCPU::ElasticDataGen::GraphNode::typeToStr().

Referenced by completeMemAccess(), execute(), and readNextWindow().

◆ completeMemAccess()

◆ execute()

void gem5::TraceCPU::ElasticDataGen::execute ( )

This is the main execute function which consumes nodes from the sorted readyList.

First attempt to issue the pending dependency-free nodes held in the depFreeQueue. Insert the ready-to-issue nodes into the readyList. Then iterate through the readyList and when a node has its execute tick equal to curTick(), execute it. If the node is a load or a store call executeMemReq() and if it is neither, simply mark it complete.

Definition at line 369 of file trace_cpu.cc.

References gem5::TraceCPU::ElasticDataGen::HardwareResource::awaitingResponse(), checkAndIssue(), gem5::Clocked::clockEdge(), gem5::curTick(), gem5::TraceCPU::ElasticDataGen::ElasticDataGenStatGroup::dataLastTick, gem5::TraceCPU::ElasticDataGen::GraphNode::dependents, depFreeQueue, depGraph, DPRINTF, DPRINTFR, elasticStats, execComplete, executeMemReq(), hwResource, gem5::TraceCPU::ElasticDataGen::HardwareResource::isAvailable(), gem5::TraceCPU::ElasticDataGen::GraphNode::isLoad(), gem5::TraceCPU::ElasticDataGen::GraphNode::isStore(), gem5::TraceCPU::ElasticDataGen::GraphNode::isStrictlyOrdered(), nextRead, gem5::TraceCPU::ElasticDataGen::ElasticDataGenStatGroup::numRetrySucceeded, owner, panic, port, gem5::TraceCPU::ElasticDataGen::HardwareResource::printOccupancy(), printReadyList(), readNextWindow(), readyList, gem5::TraceCPU::ElasticDataGen::HardwareResource::release(), gem5::Packet::req, retryPkt, gem5::TraceCPU::ElasticDataGen::GraphNode::robNum, gem5::TraceCPU::schedDcacheNextEvent(), gem5::RequestPort::sendTimingReq(), gem5::TraceCPU::ElasticDataGen::GraphNode::seqNum, traceComplete, gem5::TraceCPU::updateNumOps(), and windowSize.

Referenced by gem5::TraceCPU::schedDcacheNext().

◆ executeMemReq()

PacketPtr gem5::TraceCPU::ElasticDataGen::executeMemReq ( GraphNode * node_ptr)

◆ exit()

void gem5::TraceCPU::ElasticDataGen::exit ( )

Exit the ElasticDataGen.

Definition at line 285 of file trace_cpu.cc.

References gem5::TraceCPU::ElasticDataGen::InputStream::reset(), and trace.

◆ getMicroOpCount()

uint64_t gem5::TraceCPU::ElasticDataGen::getMicroOpCount ( ) const
inline

Get number of micro-ops modelled in the TraceCPU replay.

Definition at line 931 of file trace_cpu.hh.

References gem5::TraceCPU::ElasticDataGen::InputStream::getMicroOpCount(), and trace.

◆ init()

Tick gem5::TraceCPU::ElasticDataGen::init ( )

Called from TraceCPU init().

Reads the first message from the input trace file and returns the send tick.

Returns
Tick when first packet must be sent

Definition at line 246 of file trace_cpu.cc.

References depGraph, DPRINTF, panic_if, printReadyList(), readNextWindow(), readyList, and windowSize.

Referenced by gem5::TraceCPU::init().

◆ isExecComplete()

bool gem5::TraceCPU::ElasticDataGen::isExecComplete ( ) const
inline

Returns the execComplete variable which is set when the last node is executed.

Returns
bool true if execComplete is set, false otherwise.

Definition at line 916 of file trace_cpu.hh.

References execComplete.

Referenced by gem5::TraceCPU::schedDcacheNext().

◆ name()

const std::string & gem5::TraceCPU::ElasticDataGen::name ( ) const
inline

Returns name of the ElasticDataGen instance.

Definition at line 843 of file trace_cpu.hh.

References genName.

◆ printReadyList()

void gem5::TraceCPU::ElasticDataGen::printReadyList ( )

Print readyList for debugging using debug flag TraceCPUData.

Definition at line 808 of file trace_cpu.cc.

References depGraph, DPRINTF, DPRINTFR, readyList, and gem5::TraceCPU::ElasticDataGen::GraphNode::typeToStr().

Referenced by completeMemAccess(), execute(), and init().

◆ readNextWindow()

bool gem5::TraceCPU::ElasticDataGen::readNextWindow ( )

Reads a line of the trace file.

Returns the tick when the next request should be generated. If the end of the file has been reached, it returns false.

Returns
bool false if end of file has been reached else true

Definition at line 291 of file trace_cpu.cc.

References addDepsOnParent(), checkAndIssue(), depGraph, DPRINTF, gem5::TraceCPU::ElasticDataGen::InputStream::read(), gem5::TraceCPU::ElasticDataGen::GraphNode::regDep, gem5::TraceCPU::ElasticDataGen::GraphNode::robDep, gem5::TraceCPU::ElasticDataGen::GraphNode::seqNum, trace, traceComplete, and windowSize.

Referenced by execute(), and init().

Member Data Documentation

◆ depFreeQueue

std::queue<const GraphNode*> gem5::TraceCPU::ElasticDataGen::depFreeQueue
private

Queue of dependency-free nodes that are pending issue because resources are not available.

This is chosen to be FIFO so that dependent nodes which become free in program order get pushed into the queue in that order. Thus nodes are more likely to issue in program order.

Definition at line 988 of file trace_cpu.hh.

Referenced by checkAndIssue(), and execute().

◆ depGraph

std::unordered_map<NodeSeqNum, GraphNode*> gem5::TraceCPU::ElasticDataGen::depGraph
private

Store the depGraph of GraphNodes.

Definition at line 979 of file trace_cpu.hh.

Referenced by addDepsOnParent(), completeMemAccess(), execute(), init(), printReadyList(), and readNextWindow().

◆ elasticStats

gem5::TraceCPU::ElasticDataGen::ElasticDataGenStatGroup gem5::TraceCPU::ElasticDataGen::elasticStats
protected

◆ execComplete

bool gem5::TraceCPU::ElasticDataGen::execComplete
private

Set true when execution of trace is complete.

Definition at line 959 of file trace_cpu.hh.

Referenced by execute(), and isExecComplete().

◆ genName

std::string gem5::TraceCPU::ElasticDataGen::genName
private

String to store the name of the FixedRetryGen.

Definition at line 947 of file trace_cpu.hh.

Referenced by name().

◆ hwResource

HardwareResource gem5::TraceCPU::ElasticDataGen::hwResource
private

Hardware resources required to contain in-flight nodes and to throttle issuing of new nodes when resources are not available.

Definition at line 976 of file trace_cpu.hh.

Referenced by checkAndIssue(), completeMemAccess(), and execute().

◆ nextRead

bool gem5::TraceCPU::ElasticDataGen::nextRead
private

Set to true when the next window of instructions need to be read.

Definition at line 956 of file trace_cpu.hh.

Referenced by completeMemAccess(), and execute().

◆ owner

TraceCPU& gem5::TraceCPU::ElasticDataGen::owner
private

Reference of the TraceCPU.

Definition at line 935 of file trace_cpu.hh.

Referenced by checkAndIssue(), completeMemAccess(), execute(), and executeMemReq().

◆ port

RequestPort& gem5::TraceCPU::ElasticDataGen::port
private

Reference of the port to be used to issue memory requests.

Definition at line 938 of file trace_cpu.hh.

Referenced by execute(), and executeMemReq().

◆ readyList

std::list<ReadyNode> gem5::TraceCPU::ElasticDataGen::readyList
private

List of nodes that are ready to execute.

Definition at line 991 of file trace_cpu.hh.

Referenced by addToSortedReadyList(), adjustInitTraceOffset(), completeMemAccess(), execute(), init(), and printReadyList().

◆ requestorId

const RequestorID gem5::TraceCPU::ElasticDataGen::requestorId
private

RequestorID used for the requests being sent.

Definition at line 941 of file trace_cpu.hh.

Referenced by executeMemReq().

◆ retryPkt

PacketPtr gem5::TraceCPU::ElasticDataGen::retryPkt
private

PacketPtr used to store the packet to retry.

Definition at line 950 of file trace_cpu.hh.

Referenced by addToSortedReadyList(), completeMemAccess(), and execute().

◆ trace

InputStream gem5::TraceCPU::ElasticDataGen::trace
private

Input stream used for reading the input trace file.

Definition at line 944 of file trace_cpu.hh.

Referenced by exit(), getMicroOpCount(), gem5::TraceCPU::ElasticDataGen::InputStream::read(), readNextWindow(), and gem5::TraceCPU::ElasticDataGen::InputStream::reset().

◆ traceComplete

bool gem5::TraceCPU::ElasticDataGen::traceComplete
private

Set to true when end of trace is reached.

Definition at line 953 of file trace_cpu.hh.

Referenced by completeMemAccess(), execute(), and readNextWindow().

◆ windowSize

const uint32_t gem5::TraceCPU::ElasticDataGen::windowSize
private

Window size within which to check for dependencies.

Its value is made equal to the window size used to generate the trace which is recorded in the trace header. The dependency graph must be populated enough such that when a node completes, its potential child node must be found and the dependency removed before the completed node itself is removed. Thus as soon as the graph shrinks to become smaller than this window, we read in the next window.

Definition at line 970 of file trace_cpu.hh.

Referenced by completeMemAccess(), ElasticDataGen(), execute(), init(), and readNextWindow().


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

Generated on Tue Jun 18 2024 16:24:15 for gem5 by doxygen 1.11.0