gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
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

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

Private Types

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

Private Attributes

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

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 554 of file trace_cpu.hh.

Member Typedef Documentation

◆ NodeRobNum

typedef uint64_t TraceCPU::ElasticDataGen::NodeRobNum
private

Node ROB number type.

Definition at line 563 of file trace_cpu.hh.

◆ NodeSeqNum

typedef uint64_t TraceCPU::ElasticDataGen::NodeSeqNum
private

Node sequence number type.

Definition at line 560 of file trace_cpu.hh.

◆ Record

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

Definition at line 566 of file trace_cpu.hh.

◆ RecordType

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

Definition at line 565 of file trace_cpu.hh.

Constructor & Destructor Documentation

◆ ElasticDataGen()

TraceCPU::ElasticDataGen::ElasticDataGen ( TraceCPU _owner,
const std::string &  _name,
MasterPort _port,
MasterID  master_id,
const std::string &  trace_file,
TraceCPUParams *  params 
)
inline

Definition at line 849 of file trace_cpu.hh.

References DPRINTF, TraceCPU::init(), and ArmISA::offset.

Member Function Documentation

◆ addDepsOnParent()

template<typename T >
void TraceCPU::ElasticDataGen::addDepsOnParent ( GraphNode new_node,
T &  dep_array,
uint8_t &  num_dep 
)

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_arraythe dependency array of type rob or register, that is to be iterated, and may get modified
Parameters
num_depthe number of dependencies set in the array which may get modified during iteration

Definition at line 397 of file trace_cpu.cc.

◆ addToSortedReadyList()

void 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 801 of file trace_cpu.cc.

References TraceCPU::ElasticDataGen::ReadyNode::execTick, and TraceCPU::ElasticDataGen::ReadyNode::seqNum.

◆ adjustInitTraceOffset()

void 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 331 of file trace_cpu.cc.

References ArmISA::offset.

Referenced by TraceCPU::init().

◆ checkAndIssue()

bool 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 694 of file trace_cpu.cc.

References TraceCPU::ElasticDataGen::GraphNode::compDelay, DPRINTFR, TraceCPU::ElasticDataGen::GraphNode::numRegDep, TraceCPU::ElasticDataGen::GraphNode::numRobDep, TraceCPU::ElasticDataGen::GraphNode::robNum, TraceCPU::ElasticDataGen::GraphNode::seqNum, and TraceCPU::ElasticDataGen::GraphNode::typeToStr().

◆ completeMemAccess()

void TraceCPU::ElasticDataGen::completeMemAccess ( PacketPtr  pkt)

When a load writeback is received, that is when the load completes, release the dependents on it.

This is called from the dcache port recvTimingResp().

Definition at line 734 of file trace_cpu.cc.

References DPRINTF, DTRACE, Packet::isWrite(), and Packet::req.

Referenced by TraceCPU::dcacheRecvTimingResp().

◆ execute()

void 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 427 of file trace_cpu.cc.

References curTick(), DPRINTF, DPRINTFR, DTRACE, and panic.

Referenced by TraceCPU::schedDcacheNext().

◆ executeMemReq()

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

Creates a new request for a load or store assigning the request parameters.

Calls the port's sendTimingReq() and returns a packet if the send failed so that it can be saved for a retry.

Parameters
node_ptrpointer to the load or store node to be executed
Returns
packet pointer if the request failed and nullptr if it was sent successfully

Definition at line 621 of file trace_cpu.cc.

References Packet::createRead(), Packet::createWrite(), Packet::dataDynamic(), DPRINTF, TraceCPU::ElasticDataGen::GraphNode::flags, TraceCPU::ElasticDataGen::GraphNode::isLoad(), TraceCPU::ElasticDataGen::GraphNode::isStrictlyOrdered(), TraceCPU::ElasticDataGen::GraphNode::pc, TraceCPU::ElasticDataGen::GraphNode::physAddr, TraceCPU::ElasticDataGen::GraphNode::seqNum, TraceCPU::ElasticDataGen::GraphNode::size, and TraceCPU::ElasticDataGen::GraphNode::virtAddr.

◆ exit()

void TraceCPU::ElasticDataGen::exit ( )

Exit the ElasticDataGen.

Definition at line 338 of file trace_cpu.cc.

◆ getMicroOpCount()

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

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

Definition at line 977 of file trace_cpu.hh.

References TraceCPU::regStats().

◆ init()

Tick 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 301 of file trace_cpu.cc.

References DPRINTF, DTRACE, and panic.

Referenced by TraceCPU::init().

◆ isExecComplete()

bool 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 962 of file trace_cpu.hh.

Referenced by TraceCPU::schedDcacheNext().

◆ name()

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

Returns name of the ElasticDataGen instance.

Definition at line 886 of file trace_cpu.hh.

References X86ISA::exit.

Referenced by TraceCPU::FixedRetryGen::regStats().

◆ printReadyList()

void TraceCPU::ElasticDataGen::printReadyList ( )

Print readyList for debugging using debug flag TraceCPUData.

Definition at line 858 of file trace_cpu.cc.

References DPRINTF, and DPRINTFR.

◆ readNextWindow()

bool 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 344 of file trace_cpu.cc.

References DPRINTF, TraceCPU::ElasticDataGen::GraphNode::numRegDep, TraceCPU::ElasticDataGen::GraphNode::numRobDep, TraceCPU::ElasticDataGen::GraphNode::regDep, TraceCPU::ElasticDataGen::GraphNode::robDep, and TraceCPU::ElasticDataGen::GraphNode::seqNum.

◆ regStats()

void TraceCPU::ElasticDataGen::regStats ( )

Definition at line 245 of file trace_cpu.cc.

References SimObject::name().

Referenced by TraceCPU::regStats().

Member Data Documentation

◆ dataLastTick

Stats::Scalar TraceCPU::ElasticDataGen::dataLastTick
private

Tick when ElasticDataGen completes execution.

Definition at line 1053 of file trace_cpu.hh.

◆ depFreeQueue

std::queue<const GraphNode*> 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 1037 of file trace_cpu.hh.

◆ depGraph

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

Store the depGraph of GraphNodes.

Definition at line 1028 of file trace_cpu.hh.

◆ execComplete

bool TraceCPU::ElasticDataGen::execComplete
private

Set true when execution of trace is complete.

Definition at line 1008 of file trace_cpu.hh.

◆ genName

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

String to store the name of the FixedRetryGen.

Definition at line 996 of file trace_cpu.hh.

◆ hwResource

HardwareResource 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 1025 of file trace_cpu.hh.

◆ masterID

const MasterID TraceCPU::ElasticDataGen::masterID
private

MasterID used for the requests being sent.

Definition at line 990 of file trace_cpu.hh.

Referenced by TraceCPU::FixedRetryGen::send().

◆ maxDependents

Stats::Scalar TraceCPU::ElasticDataGen::maxDependents
private

Stats for data memory accesses replayed.

Definition at line 1043 of file trace_cpu.hh.

◆ maxReadyListSize

Stats::Scalar TraceCPU::ElasticDataGen::maxReadyListSize
private

Definition at line 1044 of file trace_cpu.hh.

◆ nextRead

bool TraceCPU::ElasticDataGen::nextRead
private

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

Definition at line 1005 of file trace_cpu.hh.

◆ numRetrySucceeded

Stats::Scalar TraceCPU::ElasticDataGen::numRetrySucceeded
private

◆ numSendAttempted

Stats::Scalar TraceCPU::ElasticDataGen::numSendAttempted
private

◆ numSendFailed

Stats::Scalar TraceCPU::ElasticDataGen::numSendFailed
private

◆ numSendSucceeded

Stats::Scalar TraceCPU::ElasticDataGen::numSendSucceeded
private

◆ numSOLoads

Stats::Scalar TraceCPU::ElasticDataGen::numSOLoads
private

Definition at line 1050 of file trace_cpu.hh.

◆ numSOStores

Stats::Scalar TraceCPU::ElasticDataGen::numSOStores
private

Definition at line 1051 of file trace_cpu.hh.

◆ numSplitReqs

Stats::Scalar TraceCPU::ElasticDataGen::numSplitReqs
private

Definition at line 1049 of file trace_cpu.hh.

◆ owner

TraceCPU& TraceCPU::ElasticDataGen::owner
private

◆ port

MasterPort& TraceCPU::ElasticDataGen::port
private

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

Definition at line 987 of file trace_cpu.hh.

Referenced by TraceCPU::FixedRetryGen::send(), and TraceCPU::FixedRetryGen::tryNext().

◆ readyList

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

List of nodes that are ready to execute.

Definition at line 1040 of file trace_cpu.hh.

◆ retryPkt

PacketPtr TraceCPU::ElasticDataGen::retryPkt
private

PacketPtr used to store the packet to retry.

Definition at line 999 of file trace_cpu.hh.

Referenced by TraceCPU::FixedRetryGen::send(), and TraceCPU::FixedRetryGen::tryNext().

◆ trace

InputStream TraceCPU::ElasticDataGen::trace
private

Input stream used for reading the input trace file.

Definition at line 993 of file trace_cpu.hh.

Referenced by TraceCPU::FixedRetryGen::exit(), and TraceCPU::FixedRetryGen::nextExecute().

◆ traceComplete

bool TraceCPU::ElasticDataGen::traceComplete
private

Set to true when end of trace is reached.

Definition at line 1002 of file trace_cpu.hh.

Referenced by TraceCPU::FixedRetryGen::nextExecute(), and TraceCPU::FixedRetryGen::tryNext().

◆ windowSize

const uint32_t 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 1019 of file trace_cpu.hh.


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

Generated on Mon Jun 8 2020 15:45:30 for gem5 by doxygen 1.8.13