gem5
|
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 | |
TraceCPU & | owner |
Reference of the TraceCPU. More... | |
MasterPort & | port |
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< ReadyNode > | readyList |
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... | |
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 558 of file trace_cpu.hh.
|
private |
Node ROB number type.
Definition at line 567 of file trace_cpu.hh.
|
private |
Node sequence number type.
Definition at line 564 of file trace_cpu.hh.
|
private |
Definition at line 570 of file trace_cpu.hh.
|
private |
Definition at line 569 of file trace_cpu.hh.
|
inline |
Definition at line 856 of file trace_cpu.hh.
References DPRINTF, and windowSize.
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.
new_node | new node to add to the graph |
dep_array | the dependency array of type rob or register, that is to be iterated, and may get modified |
num_dep | the number of dependencies set in the array which may get modified during iteration |
Definition at line 410 of file trace_cpu.cc.
References depGraph, maxDependents, and Stats::ScalarBase< Derived, Stor >::value().
Referenced by readNextWindow().
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.
seq_num | seq. num of ready node |
exec_tick | the execute tick of the ready node |
Definition at line 813 of file trace_cpu.cc.
References TraceCPU::ElasticDataGen::ReadyNode::execTick, Request::getReqInstSeqNum(), maxReadyListSize, readyList, Packet::req, retryPkt, TraceCPU::ElasticDataGen::ReadyNode::seqNum, and Stats::ScalarBase< Derived, Stor >::value().
Referenced by checkAndIssue().
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.
trace_offset | trace offset set by comparing both traces |
Definition at line 344 of file trace_cpu.cc.
References ArmISA::offset, and readyList.
Referenced by TraceCPU::init().
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.
node_ptr | pointer to node to be issued |
first | true if this is the first attempt to issue this node |
Definition at line 706 of file trace_cpu.cc.
References addToSortedReadyList(), TraceCPU::ElasticDataGen::GraphNode::compDelay, depFreeQueue, DPRINTFR, hwResource, TraceCPU::ElasticDataGen::HardwareResource::isAvailable(), TraceCPU::ElasticDataGen::GraphNode::numRegDep, TraceCPU::ElasticDataGen::GraphNode::numRobDep, TraceCPU::ElasticDataGen::HardwareResource::occupy(), owner, TraceCPU::ElasticDataGen::GraphNode::robNum, TraceCPU::ElasticDataGen::GraphNode::seqNum, and TraceCPU::ElasticDataGen::GraphNode::typeToStr().
Referenced by completeMemAccess(), execute(), and readNextWindow().
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 746 of file trace_cpu.cc.
References checkAndIssue(), ArmISA::clear(), depGraph, DPRINTF, DTRACE, Request::getReqInstSeqNum(), hwResource, Packet::isWrite(), nextRead, owner, printReadyList(), readyList, TraceCPU::ElasticDataGen::HardwareResource::release(), TraceCPU::ElasticDataGen::HardwareResource::releaseStoreBuffer(), Packet::req, retryPkt, TraceCPU::schedDcacheNextEvent(), traceComplete, TraceCPU::updateNumOps(), and windowSize.
Referenced by TraceCPU::dcacheRecvTimingResp().
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 440 of file trace_cpu.cc.
References TraceCPU::ElasticDataGen::HardwareResource::awaitingResponse(), checkAndIssue(), ArmISA::clear(), curTick(), dataLastTick, depFreeQueue, depGraph, DPRINTF, DPRINTFR, DTRACE, execComplete, executeMemReq(), Request::getReqInstSeqNum(), hwResource, TraceCPU::ElasticDataGen::HardwareResource::isAvailable(), nextRead, numRetrySucceeded, owner, panic, port, TraceCPU::ElasticDataGen::HardwareResource::printOccupancy(), printReadyList(), readNextWindow(), readyList, TraceCPU::ElasticDataGen::HardwareResource::release(), Packet::req, retryPkt, TraceCPU::schedDcacheNextEvent(), MasterPort::sendTimingReq(), traceComplete, TraceCPU::updateNumOps(), and windowSize.
Referenced by TraceCPU::schedDcacheNext().
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.
node_ptr | pointer to the load or store node to be executed |
Definition at line 634 of file trace_cpu.cc.
References TraceCPU::ElasticDataGen::GraphNode::asid, Packet::createRead(), Packet::createWrite(), Packet::dataDynamic(), DPRINTF, TraceCPU::ElasticDataGen::GraphNode::flags, Request::getSize(), TraceCPU::ElasticDataGen::GraphNode::isLoad(), TraceCPU::ElasticDataGen::GraphNode::isStrictlyOrdered(), masterID, numSendAttempted, numSendFailed, numSendSucceeded, numSOLoads, numSOStores, numSplitReqs, owner, TraceCPU::ElasticDataGen::GraphNode::pc, TraceCPU::ElasticDataGen::GraphNode::physAddr, port, MasterPort::sendTimingReq(), TraceCPU::ElasticDataGen::GraphNode::seqNum, Request::setPaddr(), Request::setPC(), Request::setReqInstSeqNum(), Request::setVirt(), TraceCPU::ElasticDataGen::GraphNode::size, and TraceCPU::ElasticDataGen::GraphNode::virtAddr.
Referenced by execute().
void TraceCPU::ElasticDataGen::exit | ( | ) |
Exit the ElasticDataGen.
Definition at line 351 of file trace_cpu.cc.
References TraceCPU::ElasticDataGen::InputStream::reset(), and trace.
|
inline |
Get number of micro-ops modelled in the TraceCPU replay.
Definition at line 984 of file trace_cpu.hh.
References TraceCPU::ElasticDataGen::InputStream::getMicroOpCount(), and trace.
Tick TraceCPU::ElasticDataGen::init | ( | ) |
Reads the first message from the input trace file and returns the send tick.
Definition at line 314 of file trace_cpu.cc.
References depGraph, DPRINTF, DTRACE, panic, printReadyList(), readNextWindow(), readyList, and windowSize.
Referenced by TraceCPU::init().
|
inline |
Returns the execComplete variable which is set when the last node is executed.
Definition at line 969 of file trace_cpu.hh.
References execComplete.
Referenced by TraceCPU::schedDcacheNext().
|
inline |
Returns name of the ElasticDataGen instance.
Definition at line 893 of file trace_cpu.hh.
References genName.
Referenced by TraceCPU::FixedRetryGen::regStats(), and regStats().
void TraceCPU::ElasticDataGen::printReadyList | ( | ) |
Print readyList for debugging using debug flag TraceCPUData.
Definition at line 870 of file trace_cpu.cc.
References depGraph, DPRINTF, DPRINTFR, M5_VAR_USED, and readyList.
Referenced by completeMemAccess(), execute(), and init().
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.
Definition at line 357 of file trace_cpu.cc.
References addDepsOnParent(), checkAndIssue(), depGraph, DPRINTF, TraceCPU::ElasticDataGen::GraphNode::numRegDep, TraceCPU::ElasticDataGen::GraphNode::numRobDep, TraceCPU::ElasticDataGen::InputStream::read(), TraceCPU::ElasticDataGen::GraphNode::regDep, TraceCPU::ElasticDataGen::GraphNode::robDep, TraceCPU::ElasticDataGen::GraphNode::seqNum, trace, traceComplete, and windowSize.
void TraceCPU::ElasticDataGen::regStats | ( | ) |
Definition at line 258 of file trace_cpu.cc.
References dataLastTick, Stats::DataWrap< Derived, InfoProxyType >::desc(), maxDependents, maxReadyListSize, Stats::DataWrap< Derived, InfoProxyType >::name(), name(), numRetrySucceeded, numSendAttempted, numSendFailed, numSendSucceeded, numSOLoads, numSOStores, and numSplitReqs.
Referenced by TraceCPU::regStats().
|
private |
Tick when ElasticDataGen completes execution.
Definition at line 1060 of file trace_cpu.hh.
Referenced by execute(), and regStats().
|
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 1044 of file trace_cpu.hh.
Referenced by checkAndIssue(), and execute().
|
private |
Store the depGraph of GraphNodes.
Definition at line 1035 of file trace_cpu.hh.
Referenced by addDepsOnParent(), completeMemAccess(), execute(), init(), printReadyList(), and readNextWindow().
|
private |
Set true when execution of trace is complete.
Definition at line 1015 of file trace_cpu.hh.
Referenced by execute(), and isExecComplete().
|
private |
String to store the name of the FixedRetryGen.
Definition at line 1003 of file trace_cpu.hh.
Referenced by name().
|
private |
Hardware resources required to contain in-flight nodes and to throttle issuing of new nodes when resources are not available.
Definition at line 1032 of file trace_cpu.hh.
Referenced by checkAndIssue(), completeMemAccess(), and execute().
|
private |
MasterID used for the requests being sent.
Definition at line 997 of file trace_cpu.hh.
Referenced by executeMemReq(), and TraceCPU::FixedRetryGen::send().
|
private |
Stats for data memory accesses replayed.
Definition at line 1050 of file trace_cpu.hh.
Referenced by addDepsOnParent(), and regStats().
|
private |
Definition at line 1051 of file trace_cpu.hh.
Referenced by addToSortedReadyList(), and regStats().
|
private |
Set to true when the next window of instructions need to be read.
Definition at line 1012 of file trace_cpu.hh.
Referenced by completeMemAccess(), and execute().
|
private |
Definition at line 1055 of file trace_cpu.hh.
Referenced by execute(), TraceCPU::FixedRetryGen::regStats(), regStats(), and TraceCPU::FixedRetryGen::tryNext().
|
private |
Definition at line 1052 of file trace_cpu.hh.
Referenced by executeMemReq(), TraceCPU::FixedRetryGen::regStats(), regStats(), and TraceCPU::FixedRetryGen::tryNext().
|
private |
Definition at line 1054 of file trace_cpu.hh.
Referenced by executeMemReq(), TraceCPU::FixedRetryGen::regStats(), regStats(), and TraceCPU::FixedRetryGen::tryNext().
|
private |
Definition at line 1053 of file trace_cpu.hh.
Referenced by executeMemReq(), TraceCPU::FixedRetryGen::regStats(), regStats(), and TraceCPU::FixedRetryGen::tryNext().
|
private |
Definition at line 1057 of file trace_cpu.hh.
Referenced by executeMemReq(), and regStats().
|
private |
Definition at line 1058 of file trace_cpu.hh.
Referenced by executeMemReq(), and regStats().
|
private |
Definition at line 1056 of file trace_cpu.hh.
Referenced by executeMemReq(), and regStats().
|
private |
Reference of the TraceCPU.
Definition at line 991 of file trace_cpu.hh.
Referenced by checkAndIssue(), completeMemAccess(), execute(), executeMemReq(), TraceCPU::IcachePort::recvReqRetry(), TraceCPU::DcachePort::recvReqRetry(), and TraceCPU::DcachePort::recvTimingResp().
|
private |
Reference of the port to be used to issue memory requests.
Definition at line 994 of file trace_cpu.hh.
Referenced by execute(), executeMemReq(), TraceCPU::FixedRetryGen::send(), and TraceCPU::FixedRetryGen::tryNext().
List of nodes that are ready to execute.
Definition at line 1047 of file trace_cpu.hh.
Referenced by addToSortedReadyList(), adjustInitTraceOffset(), completeMemAccess(), execute(), init(), and printReadyList().
|
private |
PacketPtr used to store the packet to retry.
Definition at line 1006 of file trace_cpu.hh.
Referenced by addToSortedReadyList(), completeMemAccess(), execute(), TraceCPU::FixedRetryGen::send(), and TraceCPU::FixedRetryGen::tryNext().
|
private |
Input stream used for reading the input trace file.
Definition at line 1000 of file trace_cpu.hh.
Referenced by TraceCPU::FixedRetryGen::exit(), exit(), getMicroOpCount(), TraceCPU::FixedRetryGen::nextExecute(), TraceCPU::ElasticDataGen::InputStream::read(), readNextWindow(), and TraceCPU::ElasticDataGen::InputStream::reset().
|
private |
Set to true when end of trace is reached.
Definition at line 1009 of file trace_cpu.hh.
Referenced by completeMemAccess(), execute(), TraceCPU::FixedRetryGen::nextExecute(), readNextWindow(), and TraceCPU::FixedRetryGen::tryNext().
|
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 1026 of file trace_cpu.hh.
Referenced by completeMemAccess(), ElasticDataGen(), execute(), init(), and readNextWindow().