gem5  v21.2.0.0
elastic_trace.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 - 2015 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
46 #ifndef __CPU_O3_PROBE_ELASTIC_TRACE_HH__
47 #define __CPU_O3_PROBE_ELASTIC_TRACE_HH__
48 
49 #include <set>
50 #include <unordered_map>
51 #include <utility>
52 
53 #include "base/statistics.hh"
54 #include "cpu/o3/dyn_inst_ptr.hh"
55 #include "cpu/reg_class.hh"
56 #include "mem/request.hh"
57 #include "params/ElasticTrace.hh"
58 #include "proto/inst_dep_record.pb.h"
59 #include "proto/packet.pb.h"
60 #include "proto/protoio.hh"
61 #include "sim/eventq.hh"
62 #include "sim/probe/probe.hh"
63 
64 namespace gem5
65 {
66 
67 namespace o3
68 {
69 
70 class CPU;
71 
94 {
95 
96  public:
98 
100  typedef ProtoMessage::InstDepRecord::RecordType RecordType;
101  typedef ProtoMessage::InstDepRecord Record;
102 
104  ElasticTrace(const ElasticTraceParams &params);
105 
110  void regProbeListeners();
111 
113  void regEtraceListeners();
114 
119  void flushTraces();
120 
128  void fetchReqTrace(const RequestPtr &req);
129 
136  void recordExecTick(const DynInstConstPtr& dyn_inst);
137 
145  void recordToCommTick(const DynInstConstPtr& dyn_inst);
146 
156  void updateRegDep(const DynInstConstPtr& dyn_inst);
157 
165  void removeRegDepMapEntry(const SeqNumRegPair &inst_reg_pair);
166 
173  void addSquashedInst(const DynInstConstPtr& head_inst);
174 
180  void addCommittedInst(const DynInstConstPtr& head_inst);
181 
184 
185  private:
191  bool firstWin;
192 
194 
200  {
216  std::set<InstSeqNum> physRegDepSet;
221  : executeTick(MaxTick),
223  { }
224  };
225 
233  std::unordered_map<InstSeqNum, InstExecInfo*> tempStore;
234 
240 
246  std::unordered_map<RegIndex, InstSeqNum> physRegDepMap;
247 
258  struct TraceInfo
259  {
264  /* Instruction sequence number. */
268  /* Tick when instruction was in execute stage. */
270  /* Tick when instruction was marked ready and sent to commit stage. */
272  /* Tick when instruction was committed. */
274  /* If instruction was committed, as against squashed. */
275  bool commit;
276  /* List of order dependencies. */
278  /* List of physical register RAW dependencies. */
284  int64_t compDelay;
285  /* Number of dependents. */
286  uint32_t numDepts;
287  /* The instruction PC for a load, store or non load/store. */
289  /* Request flags in case of a load/store instruction */
291  /* Request physical address in case of a load/store instruction */
293  /* Request virtual address in case of a load/store instruction */
295  /* Request size in case of a load/store instruction */
296  unsigned size;
299  : type(Record::INVALID)
300  { }
302  bool isLoad() const { return (type == Record::LOAD); }
304  bool isStore() const { return (type == Record::STORE); }
306  bool isComp() const { return (type == Record::COMP); }
308  const std::string& typeToStr() const;
316  Tick getExecuteTick() const;
317  };
318 
332 
337  std::unordered_map<InstSeqNum, TraceInfo*> traceInfoMap;
338 
341 
343  typedef typename std::reverse_iterator<depTraceItr> depTraceRevItr;
344 
351  uint32_t depWindowSize;
352 
355 
358 
361 
369 
371  const bool traceVirtAddr;
372 
375 
386  void addDepTraceRecord(const DynInstConstPtr& head_inst,
387  InstExecInfo* exec_info_ptr, bool commit);
388 
395  void clearTempStoreUntil(const DynInstConstPtr& head_inst);
396 
407  void compDelayRob(TraceInfo* past_record, TraceInfo* new_record);
408 
420  void compDelayPhysRegDep(TraceInfo* past_record, TraceInfo* new_record);
421 
429  void writeDepTrace(uint32_t num_to_write);
430 
443  void updateCommitOrderDep(TraceInfo* new_record, bool find_load_not_store);
444 
456  void updateIssueOrderDep(TraceInfo* new_record);
457 
467  void assignRobDep(TraceInfo* past_record, TraceInfo* new_record);
468 
477  bool hasStoreCommitted(TraceInfo* past_record, Tick execute_tick) const;
478 
489  bool hasLoadCompleted(TraceInfo* past_record, Tick execute_tick) const;
490 
499  bool hasLoadBeenSent(TraceInfo* past_record, Tick execute_tick) const;
500 
511  bool hasCompCompleted(TraceInfo* past_record, Tick execute_tick) const;
512 
514  {
516 
519 
525 
531 
537 
543 
546 
549 
555 
561  } stats;
562 
563 };
564 
565 } // namespace o3
566 } // namespace gem5
567 
568 #endif//__CPU_O3_PROBE_ELASTIC_TRACE_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1930
gem5::o3::ElasticTrace::allProbesReg
bool allProbesReg
Whther the elastic trace listener has been registered for all probes.
Definition: elastic_trace.hh:368
gem5::o3::ElasticTrace::TraceInfo::numDepts
uint32_t numDepts
Definition: elastic_trace.hh:286
gem5::o3::ElasticTrace::TraceInfo::pc
Addr pc
Definition: elastic_trace.hh:288
gem5::o3::ElasticTrace::InstExecInfo
Definition: elastic_trace.hh:199
gem5::o3::ElasticTrace::TraceInfo::physRegDepList
std::list< InstSeqNum > physRegDepList
Definition: elastic_trace.hh:279
gem5::o3::ElasticTrace::TraceInfo::executeTick
Tick executeTick
Definition: elastic_trace.hh:269
gem5::o3::ElasticTrace::ElasticTraceStats::ElasticTraceStats
ElasticTraceStats(statistics::Group *parent)
Definition: elastic_trace.cc:890
gem5::o3::ElasticTrace
The elastic trace is a type of probe listener and listens to probe points in multiple stages of the O...
Definition: elastic_trace.hh:93
gem5::o3::ElasticTrace::SeqNumRegPair
std::pair< InstSeqNum, RegIndex > SeqNumRegPair
Definition: elastic_trace.hh:97
gem5::o3::ElasticTrace::TraceInfo::toCommitTick
Tick toCommitTick
Definition: elastic_trace.hh:271
gem5::o3::ElasticTrace::updateIssueOrderDep
void updateIssueOrderDep(TraceInfo *new_record)
Reverse iterate through the graph, search for an issue order dependency for a new node and update the...
Definition: elastic_trace.cc:569
gem5::o3::ElasticTrace::cpu
CPU * cpu
Pointer to the O3CPU that is this listener's parent a.k.a.
Definition: elastic_trace.hh:374
gem5::o3::ElasticTrace::fetchReqTrace
void fetchReqTrace(const RequestPtr &req)
Take the fields of the request class object that are relevant to create an instruction fetch request.
Definition: elastic_trace.cc:154
gem5::o3::ElasticTrace::recordExecTick
void recordExecTick(const DynInstConstPtr &dyn_inst)
Populate the execute timestamp field in an InstExecInfo object for an instruction in flight.
Definition: elastic_trace.cc:176
gem5::o3::ElasticTrace::recordToCommTick
void recordToCommTick(const DynInstConstPtr &dyn_inst)
Populate the timestamp field in an InstExecInfo object for an instruction in flight when it is execut...
Definition: elastic_trace.cc:213
gem5::o3::ElasticTrace::firstWin
bool firstWin
Used for checking the first window for processing and writing of dependency trace.
Definition: elastic_trace.hh:191
gem5::o3::ElasticTrace::InstExecInfo::InstExecInfo
InstExecInfo()
Constructor.
Definition: elastic_trace.hh:220
gem5::o3::ElasticTrace::regProbeListeners
void regProbeListeners()
Register the probe listeners that is the methods called on a probe point notify() call.
Definition: elastic_trace.cc:107
gem5::o3::ElasticTrace::ElasticTrace
ElasticTrace(const ElasticTraceParams &params)
Constructor.
Definition: elastic_trace.cc:54
gem5::o3::ElasticTrace::addCommittedInst
void addCommittedInst(const DynInstConstPtr &head_inst)
Add an instruction that is at the head of the ROB and is committed.
Definition: elastic_trace.cc:341
protoio.hh
gem5::o3::ElasticTrace::ElasticTraceStats::numFilteredNodes
statistics::Scalar numFilteredNodes
Number of filtered nodes.
Definition: elastic_trace.hh:545
gem5::MaxTick
const Tick MaxTick
Definition: types.hh:60
std::vector
STL vector class.
Definition: stl.hh:37
gem5::ProbeListenerObject
This class is a minimal wrapper around SimObject.
Definition: probe.hh:107
gem5::o3::ElasticTrace::TraceInfo::TraceInfo
TraceInfo()
Default Constructor.
Definition: elastic_trace.hh:298
gem5::o3::ElasticTrace::zeroReg
RegIndex zeroReg
Definition: elastic_trace.hh:193
gem5::o3::ElasticTrace::hasLoadBeenSent
bool hasLoadBeenSent(TraceInfo *past_record, Tick execute_tick) const
Check if past record is a load sent earlier than the execute tick.
Definition: elastic_trace.cc:646
gem5::Request::FlagsType
uint64_t FlagsType
Definition: request.hh:100
request.hh
gem5::o3::ElasticTrace::ElasticTraceStats::numOrderDepStores
statistics::Scalar numOrderDepStores
Number of stores that got assigned a commit order dependency on a past load/store.
Definition: elastic_trace.hh:524
gem5::o3::ElasticTrace::ElasticTraceStats::numIssueOrderDepStores
statistics::Scalar numIssueOrderDepStores
Number of store insts that got assigned an issue order dependency because they were dependency-free.
Definition: elastic_trace.hh:536
gem5::RefCountingPtr
If you want a reference counting pointer to a mutable object, create it like this:
Definition: refcnt.hh:126
gem5::o3::ElasticTrace::regEtraceListenersEvent
EventFunctionWrapper regEtraceListenersEvent
Event to trigger registering this listener for all probe points.
Definition: elastic_trace.hh:183
gem5::o3::ElasticTrace::InstExecInfo::executeTick
Tick executeTick
Timestamp when instruction was first processed by execute stage.
Definition: elastic_trace.hh:206
gem5::o3::ElasticTrace::flushTraces
void flushTraces()
Process any outstanding trace records, flush them out to the protobuf output streams and delete the s...
Definition: elastic_trace.cc:924
gem5::o3::ElasticTrace::TraceInfo::typeToStr
const std::string & typeToStr() const
Return string specifying the type of the node.
Definition: elastic_trace.cc:918
gem5::o3::ElasticTrace::hasStoreCommitted
bool hasStoreCommitted(TraceInfo *past_record, Tick execute_tick) const
Check if past record is a store sent earlier than the execute tick.
Definition: elastic_trace.cc:631
gem5::o3::ElasticTrace::addDepTraceRecord
void addDepTraceRecord(const DynInstConstPtr &head_inst, InstExecInfo *exec_info_ptr, bool commit)
Add a record to the dependency trace depTrace which is a sequential container.
Definition: elastic_trace.cc:400
gem5::o3::ElasticTrace::TraceInfo::robDepList
std::list< InstSeqNum > robDepList
Definition: elastic_trace.hh:277
gem5::o3::CPU
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
Definition: cpu.hh:94
gem5::o3::ElasticTrace::TraceInfo::isComp
bool isComp() const
Is the record a fetch triggering an Icache request.
Definition: elastic_trace.hh:306
gem5::o3::ElasticTrace::physRegDepMap
std::unordered_map< RegIndex, InstSeqNum > physRegDepMap
Map for recording the producer of a physical register to check Read After Write dependencies.
Definition: elastic_trace.hh:246
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
gem5::o3::ElasticTrace::TraceInfo::compDelay
int64_t compDelay
Computational delay after the last dependent inst.
Definition: elastic_trace.hh:284
gem5::o3::ElasticTrace::clearTempStoreUntil
void clearTempStoreUntil(const DynInstConstPtr &head_inst)
Clear entries in the temporary store of execution info objects to free allocated memory until the pre...
Definition: elastic_trace.cc:662
gem5::o3::ElasticTrace::lastClearedSeqNum
InstSeqNum lastClearedSeqNum
The last cleared instruction sequence number used to free up the memory allocated in the temporary st...
Definition: elastic_trace.hh:239
statistics.hh
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
gem5::o3::ElasticTrace::ElasticTraceStats::maxTempStoreSize
statistics::Scalar maxTempStoreSize
Maximum size of the temporary store mostly useful as a check that it is not growing.
Definition: elastic_trace.hh:554
gem5::o3::ElasticTrace::RecordType
ProtoMessage::InstDepRecord::RecordType RecordType
Trace record types corresponding to instruction node types.
Definition: elastic_trace.hh:100
gem5::o3::ElasticTrace::Record
ProtoMessage::InstDepRecord Record
Definition: elastic_trace.hh:101
gem5::o3::ElasticTrace::TraceInfo::size
unsigned size
Definition: elastic_trace.hh:296
gem5::o3::ElasticTrace::ElasticTraceStats::numIssueOrderDepOther
statistics::Scalar numIssueOrderDepOther
Number of non load/store insts that got assigned an issue order dependency because they were dependen...
Definition: elastic_trace.hh:542
gem5::o3::ElasticTrace::compDelayPhysRegDep
void compDelayPhysRegDep(TraceInfo *past_record, TraceInfo *new_record)
Calculate the computational delay between an instruction and a subsequent instruction that has a Phys...
Definition: elastic_trace.cc:727
gem5::o3::ElasticTrace::dataTraceStream
ProtoOutputStream * dataTraceStream
Protobuf output stream for data dependency trace.
Definition: elastic_trace.hh:354
gem5::o3::ElasticTrace::writeDepTrace
void writeDepTrace(uint32_t num_to_write)
Write out given number of records to the trace starting with the first record in depTrace and iterati...
Definition: elastic_trace.cc:786
gem5::HtmFailureFaultCause::INVALID
@ INVALID
gem5::o3::ElasticTrace::traceInfoMap
std::unordered_map< InstSeqNum, TraceInfo * > traceInfoMap
Map where the instruction sequence number is mapped to the pointer to the TraceInfo object.
Definition: elastic_trace.hh:337
gem5::o3::ElasticTrace::TraceInfo::commitTick
Tick commitTick
Definition: elastic_trace.hh:273
gem5::o3::ElasticTrace::hasLoadCompleted
bool hasLoadCompleted(TraceInfo *past_record, Tick execute_tick) const
Check if past record is a load that completed earlier than the execute tick.
Definition: elastic_trace.cc:638
gem5::o3::ElasticTrace::InstExecInfo::toCommitTick
Tick toCommitTick
Timestamp when instruction execution is completed in execute stage and instruction is marked as ready...
Definition: elastic_trace.hh:211
gem5::o3::ElasticTrace::startTraceInst
const InstSeqNum startTraceInst
Number of instructions after which to enable tracing.
Definition: elastic_trace.hh:360
gem5::o3::ElasticTrace::TraceInfo::type
RecordType type
The type of trace record for the instruction node.
Definition: elastic_trace.hh:267
std::pair
STL pair class.
Definition: stl.hh:58
gem5::o3::ElasticTrace::depWindowSize
uint32_t depWindowSize
The maximum distance for a dependency and is set by a top level level parameter.
Definition: elastic_trace.hh:351
gem5::o3::ElasticTrace::addSquashedInst
void addSquashedInst(const DynInstConstPtr &head_inst)
Add an instruction that is at the head of the ROB and is squashed only if it is a load and a request ...
Definition: elastic_trace.cc:313
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
dyn_inst_ptr.hh
gem5::o3::ElasticTrace::TraceInfo::physAddr
Addr physAddr
Definition: elastic_trace.hh:292
gem5::o3::ElasticTrace::removeRegDepMapEntry
void removeRegDepMapEntry(const SeqNumRegPair &inst_reg_pair)
When an instruction gets squashed the destination register mapped to it is freed up in the rename sta...
Definition: elastic_trace.cc:303
gem5::o3::ElasticTrace::InstExecInfo::physRegDepSet
std::set< InstSeqNum > physRegDepSet
Set of instruction sequence numbers that this instruction depends on due to Read After Write data dep...
Definition: elastic_trace.hh:216
gem5::EventFunctionWrapper
Definition: eventq.hh:1115
gem5::o3::ElasticTrace::TraceInfo
Definition: elastic_trace.hh:258
gem5::o3::ElasticTrace::TraceInfo::instNum
InstSeqNum instNum
Definition: elastic_trace.hh:265
gem5::o3::ElasticTrace::TraceInfo::reqFlags
Request::FlagsType reqFlags
Definition: elastic_trace.hh:290
gem5::o3::ElasticTrace::depTraceRevItr
std::reverse_iterator< depTraceItr > depTraceRevItr
Typedef of the reverse iterator to the instruction dependency trace.
Definition: elastic_trace.hh:343
reg_class.hh
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:40
gem5::o3::ElasticTrace::compDelayRob
void compDelayRob(TraceInfo *past_record, TraceInfo *new_record)
Calculate the computational delay between an instruction and a subsequent instruction that has an ROB...
Definition: elastic_trace.cc:684
gem5::o3::ElasticTrace::TraceInfo::virtAddr
Addr virtAddr
Definition: elastic_trace.hh:294
gem5::o3::ElasticTrace::stats
gem5::o3::ElasticTrace::ElasticTraceStats stats
gem5::o3::ElasticTrace::ElasticTraceStats
Definition: elastic_trace.hh:513
gem5::o3::ElasticTrace::ElasticTraceStats::maxPhysRegDepMapSize
statistics::Scalar maxPhysRegDepMapSize
Maximum size of the map that holds the last writer to a physical register.
Definition: elastic_trace.hh:560
gem5::RegIndex
uint16_t RegIndex
Definition: types.hh:176
std::list< InstSeqNum >
gem5::o3::ElasticTrace::traceVirtAddr
const bool traceVirtAddr
Whether to trace virtual addresses for memory requests.
Definition: elastic_trace.hh:371
gem5::o3::ElasticTrace::ElasticTraceStats::numIssueOrderDepLoads
statistics::Scalar numIssueOrderDepLoads
Number of load insts that got assigned an issue order dependency because they were dependency-free.
Definition: elastic_trace.hh:530
probe.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::o3::ElasticTrace::TraceInfo::isLoad
bool isLoad() const
Is the record a load.
Definition: elastic_trace.hh:302
gem5::o3::ElasticTrace::ElasticTraceStats::numRegDep
statistics::Scalar numRegDep
Number of register dependencies recorded during tracing.
Definition: elastic_trace.hh:518
gem5::o3::ElasticTrace::hasCompCompleted
bool hasCompCompleted(TraceInfo *past_record, Tick execute_tick) const
Check if past record is a comp node that completed earlier than the execute tick.
Definition: elastic_trace.cc:655
gem5::o3::ElasticTrace::updateRegDep
void updateRegDep(const DynInstConstPtr &dyn_inst)
Record a Read After Write physical register dependency if there has been a write to the source regist...
Definition: elastic_trace.cc:234
ProtoOutputStream
A ProtoOutputStream wraps a coded stream, potentially with compression, based on looking at the file ...
Definition: protoio.hh:90
gem5::o3::ElasticTrace::assignRobDep
void assignRobDep(TraceInfo *past_record, TraceInfo *new_record)
The new_record has an order dependency on a past_record, thus update the new record's Rob dependency ...
Definition: elastic_trace.cc:615
gem5::o3::ElasticTrace::TraceInfo::commit
bool commit
Definition: elastic_trace.hh:275
gem5::o3::ElasticTrace::updateCommitOrderDep
void updateCommitOrderDep(TraceInfo *new_record, bool find_load_not_store)
Reverse iterate through the graph, search for a store-after-store or store-after-load dependency and ...
Definition: elastic_trace.cc:528
gem5::o3::ElasticTrace::regEtraceListeners
void regEtraceListeners()
Register all listeners.
Definition: elastic_trace.cc:124
gem5::o3::ElasticTrace::depTrace
std::vector< TraceInfo * > depTrace
The instruction dependency trace containing TraceInfo objects.
Definition: elastic_trace.hh:331
gem5::o3::ElasticTrace::ElasticTraceStats::maxNumDependents
statistics::Scalar maxNumDependents
Maximum number of dependents on any instruction.
Definition: elastic_trace.hh:548
gem5::o3::ElasticTrace::instTraceStream
ProtoOutputStream * instTraceStream
Protobuf output stream for instruction fetch trace.
Definition: elastic_trace.hh:357
gem5::o3::ElasticTrace::tempStore
std::unordered_map< InstSeqNum, InstExecInfo * > tempStore
Temporary store of InstExecInfo objects.
Definition: elastic_trace.hh:233
gem5::o3::ElasticTrace::depTraceItr
std::vector< TraceInfo * >::iterator depTraceItr
Typedef of iterator to the instruction dependency trace.
Definition: elastic_trace.hh:340
gem5::o3::ElasticTrace::TraceInfo::isStore
bool isStore() const
Is the record a store.
Definition: elastic_trace.hh:304
gem5::o3::ElasticTrace::TraceInfo::getExecuteTick
Tick getExecuteTick() const
Get the execute tick of the instruction.
Definition: elastic_trace.cc:768
eventq.hh

Generated on Tue Dec 21 2021 11:34:26 for gem5 by doxygen 1.8.17