42 #ifndef __CPU_TRACE_TRACE_CPU_HH__
43 #define __CPU_TRACE_TRACE_CPU_HH__
49 #include <unordered_map>
51 #include "arch/registers.hh"
54 #include "debug/TraceCPUData.hh"
55 #include "debug/TraceCPUInst.hh"
56 #include "params/TraceCPU.hh"
57 #include "proto/inst_dep_record.pb.h"
58 #include "proto/packet.pb.h"
431 const std::string& trace_file)
570 typedef ProtoMessage::InstDepRecord
Record;
592 typedef std::array<NodeSeqNum, TheISA::MaxInstSrcRegs>
RegDepArray;
828 const double time_multiplier);
858 const std::string& trace_file, TraceCPUParams *params)
862 trace(trace_file, 1.0 / params->freqMultiplier),
869 hwResource(params->sizeROB, params->sizeStoreBuffer,
870 params->sizeLoadBuffer)
872 DPRINTF(TraceCPUData,
"Window size in the trace is %d.\n",
981 bool checkAndIssue(
const GraphNode* node_ptr,
bool first =
true);
1156 #endif // __CPU_TRACE_TRACE_CPU_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
InputStream trace
Input stream used for reading the input trace file.
void execute()
This is the main execute function which consumes nodes from the sorted readyList. ...
Struct to store a ready-to-execute node and its execution tick.
Counter value() const
Return the current value of this stat as its base type.
void schedDcacheNext()
This is the control flow that uses the functionality of the dcacheGen to replay the trace...
MasterPort & getDataPort()
Used to get a reference to the dcache port.
Stats::Scalar maxReadyListSize
The HardwareResource class models structures that hold the in-flight nodes.
const uint16_t sizeStoreBuffer
The size of store buffer.
std::string genName
String to store the name of the FixedRetryGen.
const uint64_t progressMsgInterval
Interval of committed instructions specified by the user at which a progress info message is printed...
bool send(Addr addr, unsigned size, const MemCmd &cmd, Request::FlagsType flags, Addr pc)
Creates a new request assigning the request parameters passed by the arguments.
Addr blocksize
The size of the access for the request.
Stats::Scalar dataLastTick
Tick when ElasticDataGen completes execution.
IcachePort icachePort
Port to connect to L1 instruction cache.
TraceCPU & owner
Reference of the TraceCPU.
NodeSeqNum seqNum
The sequence number of the ready node.
void exit()
Exit the FixedRetryGen.
void recvReqRetry()
Handle a retry signalled by the cache if data access failed in the first attempt. ...
bool isComp() const
Is the node a compute (non load/store) node.
bool isTraceComplete()
Returns the traceComplete variable which is set when end of the input trace file is reached...
ProtoMessage::InstDepRecord::RecordType RecordType
void recvTimingSnoopReq(PacketPtr pkt)
Required functionally but do nothing.
bool removeRegDep(NodeSeqNum reg_dep)
Remove completed instruction from register dependency array.
std::list< ReadyNode > readyList
List of nodes that are ready to execute.
uint16_t numInFlightStores
Number of ready stores for which request may or may not be sent.
Request::Flags flags
Request flags if any.
RecordType type
Type of the node corresponding to the instruction modelled by it.
PacketPtr retryPkt
PacketPtr used to store the packet to retry.
Stats::Scalar numSchedIcacheEvent
bool nextExecute()
Reads a line of the trace file.
const std::string name() const
Return port name (for DPRINTF).
void updateNumOps(uint64_t rob_num)
HardwareResource(uint16_t max_rob, uint16_t max_stores, uint16_t max_loads)
Constructor that initializes the sizes of the structures.
PacketPtr executeMemReq(GraphNode *node_ptr)
Creates a new request for a load or store assigning the request parameters.
Request::FlagsType flags
Potential request flags to use.
Stats::Scalar numSOStores
void completeMemAccess(PacketPtr pkt)
When a load writeback is received, that is when the load completes, release the dependents on it...
std::map< NodeSeqNum, NodeRobNum > inFlightNodes
A map from the sequence number to the ROB number of the in- flight nodes.
Tick traceOffset
This stores the time offset in the trace, which is taken away from the ready times of requests...
std::string instTraceFile
File names for input instruction and data traces.
ProtoMessage::InstDepRecord Record
void exit()
Exit the ElasticDataGen.
uint32_t asid
The address space id which is set if the virtual address is set.
static const uint8_t maxRobDep
The maximum no.
bool recvTimingResp(PacketPtr pkt)
Receive the timing reponse and simply delete the packet since instruction fetch requests are issued a...
const uint16_t sizeROB
The size of the ROB used to throttle the max.
void checkAndSchedExitEvent()
This is called when either generator finishes executing from the trace.
bool oneTraceComplete
Set to true when one of the generators finishes replaying its trace.
Stats::Scalar numRetrySucceeded
PacketPtr retryPkt
PacketPtr used to store the packet to retry.
void schedIcacheNext()
This is the control flow that uses the functionality of the icacheGen to replay the trace...
Stats::Scalar numSchedDcacheEvent
MemCmd cmd
Specifies if the request is to be a read or a write.
MasterPort & port
Reference of the port to be used to issue memory requests.
void clearRobDep()
Initialize register dependency array to all zeroes.
DcachePort(TraceCPU *_cpu)
Default constructor.
uint64_t NodeSeqNum
Node sequence number type.
bool readNextWindow()
Reads a line of the trace file.
Stats::Scalar maxDependents
Stats for data memory accesses replayed.
uint8_t numRegDep
Number of register dependencies.
bool execComplete
Set true when execution of trace is complete.
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 par...
Stats::Scalar numSendSucceeded
Stats::Scalar numSendAttempted
Stats for instruction accesses replayed.
EventWrapper< TraceCPU,&TraceCPU::schedIcacheNext > icacheNextEvent
Event for the control flow method schedIcacheNext()
Declaration of Statistics objects.
bool traceComplete
Set to true when end of trace is reached.
const std::string & name() const
Returns name of the FixedRetryGen instance.
Tick init()
Called from TraceCPU init().
This is a simple scalar statistic, like a counter.
void clearRegDep()
Initialize register dependency array to all zeroes.
const uint32_t windowSize
Window size within which to check for dependencies.
std::queue< const GraphNode * > depFreeQueue
Queue of dependency-free nodes that are pending issue because resources are not available.
bool isAvailable(const GraphNode *new_node) const
Check if structures required to issue a node are free.
IcachePort(TraceCPU *_cpu)
Default constructor.
The elastic data memory request generator to read protobuf trace containing execution trace annotated...
CountedExitEvent * execCompleteEvent
A CountedExitEvent which when serviced decrements the counter.
uint64_t getMicroOpCount() const
Get number of micro-ops modelled in the TraceCPU replay.
bool isExecComplete() const
Returns the execComplete variable which is set when the last node is executed.
The trace cpu replays traces generated using the elastic trace probe attached to the O3 CPU model...
std::vector< GraphNode * > dependents
A vector of nodes dependent (outgoing) on this node.
uint64_t progressMsgThreshold
NodeRobNum robNum
ROB occupancy number.
std::array< NodeSeqNum, maxRobDep > RobDepArray
Typedef for the array containing the ROB dependencies.
bool isStrictlyOrdered() const
Return true if node has a request which is strictly ordered.
DcachePort dcachePort
Port to connect to L1 data cache.
TraceCPU(TraceCPUParams *params)
const MasterID dataMasterID
Master id for data read and write requests.
uint64_t Tick
Tick count type.
const bool enableEarlyExit
Exit when any one Trace CPU completes its execution.
Counter totalInsts() const
This is a pure virtual function in BaseCPU.
void wakeup(ThreadID tid=0)
int64_t delta
Stores the difference in the send ticks of the current and last packets.
bool isSnooping() const
Required functionally.
The struct GraphNode stores an instruction in the trace file.
bool nextRead
Set to true when the next window of instructions need to be read.
const MasterID masterID
MasterID used for the requests being sent.
bool isValid() const
Check validity of this element.
This struct stores a line in the trace file.
Stats::Scalar instLastTick
Last simulated tick by the FixedRetryGen.
TraceCPU & owner
Reference of the TraceCPU.
void dcacheRetryRecvd()
When data cache port receives a retry, schedule event dcacheNextEvent.
FixedRetryGen icacheGen
Instance of FixedRetryGen to replay instruction read requests.
void recvReqRetry()
Handle a retry signalled by the cache if instruction read failed in the first attempt.
void writeElementAsTrace() const
Write out element in trace-compatible format using debug flag TraceCPUData.
void clear()
Make this element invalid.
Stats::Scalar numSendFailed
std::string genName
String to store the name of the FixedRetryGen.
const std::string & name() const
Returns name of the ElasticDataGen instance.
Generator to read protobuf trace containing memory requests at fixed timestamps, perform flow control...
TraceElement currElement
Store an element read from the trace to send as the next packet.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void release(const GraphNode *done_node)
Release appropriate structures for a completed node.
uint16_t numInFlightLoads
Number of ready loads for which request may or may not be sent.
uint64_t compDelay
Computational delay.
MasterPort & port
Reference of the port to be used to issue memory requests.
static int numTraceCPUs
Number of Trace CPUs in the system used as a shared variable and passed to the CountedExitEvent event...
Stats::Formula cpi
Stat for the CPI.
int64_t Counter
Statistics counter type.
void dcacheRecvTimingResp(PacketPtr pkt)
When data cache port receives a response, this calls the dcache generator method handle to complete t...
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Tick execTick
The tick at which the ready node must be executed.
NodeRobNum oldestInFlightRobNum
The ROB number of the oldest in-flight node.
const uint16_t sizeLoadBuffer
The size of load buffer.
const MasterID instMasterID
Master id for instruction read requests.
Stats::Scalar numOps
Stat for number of simulated micro-ops.
int16_t ThreadID
Thread index/ID type.
bool checkAndIssue(const GraphNode *node_ptr, bool first=true)
Attempts to issue a node once the node's source dependencies are complete.
const MasterID masterID
MasterID used for the requests being sent.
Tick tick
The time at which the request should be sent.
bool recvTimingResp(PacketPtr pkt)
Receive the timing reponse and call dcacheRecvTimingResp() method of the dcacheGen to handle completi...
ElasticDataGen(TraceCPU &_owner, const std::string &_name, MasterPort &_port, MasterID master_id, const std::string &trace_file, TraceCPUParams *params)
uint8_t numRobDep
Number of order dependencies.
IcachePort class that interfaces with L1 Instruction Cache.
Stats::Scalar numSendFailed
void schedDcacheNextEvent(Tick when)
Schedule event dcacheNextEvent at the given tick.
Counter totalOps() const
Return totalOps as the number of committed micro-ops plus the speculatively issued loads that are mod...
EventWrapper< TraceCPU,&TraceCPU::schedDcacheNext > dcacheNextEvent
Event for the control flow method schedDcacheNext()
std::string dataTraceFile
Stats::Scalar numSendAttempted
ElasticDataGen dcacheGen
Instance of ElasticDataGen to replay data read and write requests.
FixedRetryGen(TraceCPU &_owner, const std::string &_name, MasterPort &_port, MasterID master_id, const std::string &trace_file)
bool isLoad() const
Is the node a load.
Addr virtAddr
The virtual address for the request if any.
uint32_t size
Size of request if any.
void printReadyList()
Print readyList for debugging using debug flag TraceCPUData.
void releaseStoreBuffer()
Release store buffer entry for a completed store.
void adjustInitTraceOffset(Tick &offset)
Adjust traceOffset based on what TraceCPU init() determines on comparing the offsets in the fetch req...
void occupy(const GraphNode *new_node)
Occupy appropriate structures for an issued node.
The request is required to be strictly ordered by CPU models and is non-speculative.
RegDepArray regDep
Array of register dependencies (incoming) if any.
Stats::Scalar numRetrySucceeded
std::string typeToStr() const
Return string specifying the type of the node.
Addr addr
The address for the request.
Tick init()
Called from TraceCPU init().
Stats::Scalar numSendSucceeded
bool isStore() const
Is the node a store.
void icacheRetryRecvd()
When instruction cache port receives a retry, schedule event icacheNextEvent.
std::unordered_map< NodeSeqNum, GraphNode * > depGraph
Store the depGraph of GraphNodes.
bool traceComplete
Set to true when end of trace is reached.
Addr physAddr
The address for the request if any.
std::array< NodeSeqNum, TheISA::MaxInstSrcRegs > RegDepArray
Typedef for the array containing the register dependencies.
bool awaitingResponse() const
Check if there are any outstanding requests, i.e.
Stats::Scalar numSplitReqs
void printOccupancy()
Print resource occupancy for debugging.
void recvFunctionalSnoop(PacketPtr pkt)
Required functionally but do nothing.
void addToSortedReadyList(NodeSeqNum seq_num, Tick exec_tick)
Add a ready node to the readyList.
DcachePort class that interfaces with L1 Data Cache.
RobDepArray robDep
Array of order dependencies.
void takeOverFrom(BaseCPU *oldCPU)
void recvTimingSnoopReq(PacketPtr pkt)
Required functionally but do nothing.
uint64_t NodeRobNum
Node ROB number type.
Declaration of a wrapper for protobuf output streams and input streams.
NodeSeqNum seqNum
Instruction sequence number.
InputStream trace
Input stream used for reading the input trace file.
bool removeRobDep(NodeSeqNum rob_dep)
Remove completed instruction from order dependency array.
HardwareResource hwResource
Hardware resources required to contain in-flight nodes and to throttle issuing of new nodes when reso...
bool removeDepOnInst(NodeSeqNum done_seq_num)
Check for all dependencies on completed inst.
MasterPort & getInstPort()
Used to get a reference to the icache port.
bool tryNext()
This tries to send current or retry packet and returns true if successfull.