gem5  v20.1.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 "cpu/o3/dyn_inst.hh"
54 #include "cpu/o3/impl.hh"
55 #include "mem/request.hh"
56 #include "params/ElasticTrace.hh"
57 #include "proto/inst_dep_record.pb.h"
58 #include "proto/packet.pb.h"
59 #include "proto/protoio.hh"
60 #include "sim/eventq.hh"
61 #include "sim/probe/probe.hh"
62 
85 {
86 
87  public:
91 
93  typedef ProtoMessage::InstDepRecord::RecordType RecordType;
94  typedef ProtoMessage::InstDepRecord Record;
95 
97  ElasticTrace(const ElasticTraceParams *params);
98 
103  void regProbeListeners();
104 
106  void regEtraceListeners();
107 
109  const std::string name() const;
110 
115  void flushTraces();
116 
124  void fetchReqTrace(const RequestPtr &req);
125 
132  void recordExecTick(const DynInstConstPtr& dyn_inst);
133 
141  void recordToCommTick(const DynInstConstPtr& dyn_inst);
142 
152  void updateRegDep(const DynInstConstPtr& dyn_inst);
153 
161  void removeRegDepMapEntry(const SeqNumRegPair &inst_reg_pair);
162 
169  void addSquashedInst(const DynInstConstPtr& head_inst);
170 
176  void addCommittedInst(const DynInstConstPtr& head_inst);
177 
180 
181  private:
187  bool firstWin;
188 
194  {
210  std::set<InstSeqNum> physRegDepSet;
215  : executeTick(MaxTick),
217  { }
218  };
219 
227  std::unordered_map<InstSeqNum, InstExecInfo*> tempStore;
228 
234 
240  std::unordered_map<PhysRegIndex, InstSeqNum> physRegDepMap;
241 
252  struct TraceInfo
253  {
258  /* Instruction sequence number. */
262  /* Tick when instruction was in execute stage. */
264  /* Tick when instruction was marked ready and sent to commit stage. */
266  /* Tick when instruction was committed. */
268  /* If instruction was committed, as against squashed. */
269  bool commit;
270  /* List of order dependencies. */
272  /* List of physical register RAW dependencies. */
278  int64_t compDelay;
279  /* Number of dependents. */
280  uint32_t numDepts;
281  /* The instruction PC for a load, store or non load/store. */
283  /* Request flags in case of a load/store instruction */
285  /* Request physical address in case of a load/store instruction */
287  /* Request virtual address in case of a load/store instruction */
289  /* Request size in case of a load/store instruction */
290  unsigned size;
293  : type(Record::INVALID)
294  { }
296  bool isLoad() const { return (type == Record::LOAD); }
298  bool isStore() const { return (type == Record::STORE); }
300  bool isComp() const { return (type == Record::COMP); }
302  const std::string& typeToStr() const;
310  Tick getExecuteTick() const;
311  };
312 
326 
331  std::unordered_map<InstSeqNum, TraceInfo*> traceInfoMap;
332 
335 
337  typedef typename std::reverse_iterator<depTraceItr> depTraceRevItr;
338 
345  uint32_t depWindowSize;
346 
349 
352 
355 
363 
365  const bool traceVirtAddr;
366 
369 
380  void addDepTraceRecord(const DynInstConstPtr& head_inst,
381  InstExecInfo* exec_info_ptr, bool commit);
382 
389  void clearTempStoreUntil(const DynInstConstPtr& head_inst);
390 
401  void compDelayRob(TraceInfo* past_record, TraceInfo* new_record);
402 
414  void compDelayPhysRegDep(TraceInfo* past_record, TraceInfo* new_record);
415 
423  void writeDepTrace(uint32_t num_to_write);
424 
437  void updateCommitOrderDep(TraceInfo* new_record, bool find_load_not_store);
438 
450  void updateIssueOrderDep(TraceInfo* new_record);
451 
461  void assignRobDep(TraceInfo* past_record, TraceInfo* new_record);
462 
471  bool hasStoreCommitted(TraceInfo* past_record, Tick execute_tick) const;
472 
483  bool hasLoadCompleted(TraceInfo* past_record, Tick execute_tick) const;
484 
493  bool hasLoadBeenSent(TraceInfo* past_record, Tick execute_tick) const;
494 
505  bool hasCompCompleted(TraceInfo* past_record, Tick execute_tick) const;
506 
507  struct ElasticTraceStats : public Stats::Group {
509 
512 
518 
524 
530 
536 
539 
542 
548 
554  } stats;
555 
556 };
557 #endif//__CPU_O3_PROBE_ELASTIC_TRACE_HH__
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:84
ElasticTrace::TraceInfo::executeTick
Tick executeTick
Definition: elastic_trace.hh:263
FullO3CPU< O3CPUImpl >
ElasticTrace::physRegDepMap
std::unordered_map< PhysRegIndex, InstSeqNum > physRegDepMap
Map for recording the producer of a physical register to check Read After Write dependencies.
Definition: elastic_trace.hh:240
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:331
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:202
ElasticTrace::TraceInfo::isStore
bool isStore() const
Is the record a store.
Definition: elastic_trace.hh:298
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:643
ElasticTrace::TraceInfo::size
unsigned size
Definition: elastic_trace.hh:290
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:650
Request::FlagsType
uint64_t FlagsType
Definition: request.hh:90
ElasticTrace::startTraceInst
const InstSeqNum startTraceInst
Number of instructions after which to enable tracing.
Definition: elastic_trace.hh:354
ElasticTrace::DynInstPtr
O3CPUImpl::DynInstPtr DynInstPtr
Definition: elastic_trace.hh:88
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:233
ElasticTrace::ElasticTraceStats::numIssueOrderDepOther
Stats::Scalar numIssueOrderDepOther
Number of non load/store insts that got assigned an issue order dependency because they were dependen...
Definition: elastic_trace.hh:535
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:557
ElasticTrace::TraceInfo::compDelay
int64_t compDelay
Computational delay after the last dependent inst.
Definition: elastic_trace.hh:278
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:626
ElasticTrace::regEtraceListeners
void regEtraceListeners()
Register all listeners.
Definition: elastic_trace.cc:113
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:914
ElasticTrace::regProbeListeners
void regProbeListeners()
Register the probe listeners that is the methods called on a probe point notify() call.
Definition: elastic_trace.cc:96
ElasticTrace::traceVirtAddr
const bool traceVirtAddr
Whether to trace virtual addresses for memory requests.
Definition: elastic_trace.hh:365
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:143
ElasticTrace::ElasticTraceStats::numIssueOrderDepStores
Stats::Scalar numIssueOrderDepStores
Number of store insts that got assigned an issue order dependency because they were dependency-free.
Definition: elastic_trace.hh:529
ElasticTrace::TraceInfo
Definition: elastic_trace.hh:252
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
protoio.hh
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:715
ElasticTrace::TraceInfo::toCommitTick
Tick toCommitTick
Definition: elastic_trace.hh:265
ElasticTrace::TraceInfo::isLoad
bool isLoad() const
Is the record a load.
Definition: elastic_trace.hh:296
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:82
ElasticTrace::ElasticTraceStats::maxTempStoreSize
Stats::Scalar maxTempStoreSize
Maximum size of the temporary store mostly useful as a check that it is not growing.
Definition: elastic_trace.hh:547
std::vector
STL vector class.
Definition: stl.hh:37
ElasticTrace::TraceInfo::virtAddr
Addr virtAddr
Definition: elastic_trace.hh:288
dyn_inst.hh
ElasticTrace::TraceInfo::typeToStr
const std::string & typeToStr() const
Return string specifying the type of the node.
Definition: elastic_trace.cc:902
ElasticTrace::ElasticTraceStats::maxPhysRegDepMapSize
Stats::Scalar maxPhysRegDepMapSize
Maximum size of the map that holds the last writer to a physical register.
Definition: elastic_trace.hh:553
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:223
ElasticTrace::InstExecInfo
Definition: elastic_trace.hh:193
ElasticTrace::firstWin
bool firstWin
Used for checking the first window for processing and writing of dependency trace.
Definition: elastic_trace.hh:187
request.hh
impl.hh
EventFunctionWrapper
Definition: eventq.hh:1101
ElasticTrace::regEtraceListenersEvent
EventFunctionWrapper regEtraceListenersEvent
Event to trigger registering this listener for all probe points.
Definition: elastic_trace.hh:179
ElasticTrace::ElasticTraceStats::numOrderDepStores
Stats::Scalar numOrderDepStores
Number of stores that got assigned a commit order dependency on a past load/store.
Definition: elastic_trace.hh:517
ElasticTrace::TraceInfo::pc
Addr pc
Definition: elastic_trace.hh:282
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
ElasticTrace::dataTraceStream
ProtoOutputStream * dataTraceStream
Protobuf output stream for data dependency trace.
Definition: elastic_trace.hh:348
ElasticTrace::ElasticTraceStats::maxNumDependents
Stats::Scalar maxNumDependents
Maximum number of dependents on any instruction.
Definition: elastic_trace.hh:541
ElasticTrace::SeqNumRegPair
std::pair< InstSeqNum, PhysRegIndex > SeqNumRegPair
Definition: elastic_trace.hh:90
ElasticTrace::TraceInfo::physRegDepList
std::list< InstSeqNum > physRegDepList
Definition: elastic_trace.hh:273
ElasticTrace::depTrace
std::vector< TraceInfo * > depTrace
The instruction dependency trace containing TraceInfo objects.
Definition: elastic_trace.hh:325
ElasticTrace::InstExecInfo::InstExecInfo
InstExecInfo()
Constructor.
Definition: elastic_trace.hh:214
ElasticTrace::cpu
FullO3CPU< O3CPUImpl > * cpu
Pointer to the O3CPU that is this listener's parent a.k.a.
Definition: elastic_trace.hh:368
ElasticTrace::name
const std::string name() const
Returns the name of the trace probe listener.
Definition: elastic_trace.cc:908
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:672
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:210
ElasticTrace::ElasticTraceStats::ElasticTraceStats
ElasticTraceStats(Stats::Group *parent)
Definition: elastic_trace.cc:878
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:634
ElasticTrace::depTraceItr
std::vector< TraceInfo * >::iterator depTraceItr
Typedef of iterator to the instruction dependency trace.
Definition: elastic_trace.hh:334
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:603
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:165
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:291
ElasticTrace::TraceInfo::robDepList
std::list< InstSeqNum > robDepList
Definition: elastic_trace.hh:271
ElasticTrace::TraceInfo::TraceInfo
TraceInfo()
Default Constructor.
Definition: elastic_trace.hh:292
std::pair
STL pair class.
Definition: stl.hh:58
InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:37
ProbeListenerObject
This class is a minimal wrapper around SimObject.
Definition: probe.hh:98
ElasticTrace::stats
ElasticTrace::ElasticTraceStats stats
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ElasticTrace::tempStore
std::unordered_map< InstSeqNum, InstExecInfo * > tempStore
Temporary store of InstExecInfo objects.
Definition: elastic_trace.hh:227
SimObject::params
const Params * params() const
Definition: sim_object.hh:119
ElasticTrace::ElasticTraceStats::numIssueOrderDepLoads
Stats::Scalar numIssueOrderDepLoads
Number of load insts that got assigned an issue order dependency because they were dependency-free.
Definition: elastic_trace.hh:523
ElasticTrace::TraceInfo::getExecuteTick
Tick getExecuteTick() const
Get the execute tick of the instruction.
Definition: elastic_trace.cc:756
ElasticTrace::TraceInfo::commitTick
Tick commitTick
Definition: elastic_trace.hh:267
ElasticTrace::allProbesReg
bool allProbesReg
Whther the elastic trace listener has been registered for all probes.
Definition: elastic_trace.hh:362
ElasticTrace::ElasticTraceStats::numRegDep
Stats::Scalar numRegDep
Number of register dependencies recorded during tracing.
Definition: elastic_trace.hh:511
ElasticTrace::depTraceRevItr
std::reverse_iterator< depTraceItr > depTraceRevItr
Typedef of the reverse iterator to the instruction dependency trace.
Definition: elastic_trace.hh:337
ElasticTrace::InstExecInfo::executeTick
Tick executeTick
Timestamp when instruction was first processed by execute stage.
Definition: elastic_trace.hh:200
ElasticTrace::depWindowSize
uint32_t depWindowSize
The maximum distance for a dependency and is set by a top level level parameter.
Definition: elastic_trace.hh:345
ElasticTrace::TraceInfo::commit
bool commit
Definition: elastic_trace.hh:269
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:329
ElasticTrace::TraceInfo::physAddr
Addr physAddr
Definition: elastic_trace.hh:286
ElasticTrace::RecordType
ProtoMessage::InstDepRecord::RecordType RecordType
Trace record types corresponding to instruction node types.
Definition: elastic_trace.hh:93
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:388
ElasticTrace::ElasticTraceStats
Definition: elastic_trace.hh:507
ElasticTrace::TraceInfo::instNum
InstSeqNum instNum
Definition: elastic_trace.hh:259
Stats::Group
Statistics container.
Definition: group.hh:83
ElasticTrace::DynInstConstPtr
O3CPUImpl::DynInstConstPtr DynInstConstPtr
Definition: elastic_trace.hh:89
RefCountingPtr
If you want a reference counting pointer to a mutable object, create it like this:
Definition: refcnt.hh:118
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:516
ElasticTrace::ElasticTraceStats::numFilteredNodes
Stats::Scalar numFilteredNodes
Number of filtered nodes.
Definition: elastic_trace.hh:538
ElasticTrace::TraceInfo::reqFlags
Request::FlagsType reqFlags
Definition: elastic_trace.hh:284
HtmFailureFaultCause::INVALID
@ INVALID
std::list< InstSeqNum >
ElasticTrace::instTraceStream
ProtoOutputStream * instTraceStream
Protobuf output stream for instruction fetch trace.
Definition: elastic_trace.hh:351
probe.hh
ElasticTrace::TraceInfo::type
RecordType type
The type of trace record for the instruction node.
Definition: elastic_trace.hh:261
ElasticTrace::Record
ProtoMessage::InstDepRecord Record
Definition: elastic_trace.hh:94
ProtoOutputStream
A ProtoOutputStream wraps a coded stream, potentially with compression, based on looking at the file ...
Definition: protoio.hh:90
ElasticTrace::ElasticTrace
ElasticTrace(const ElasticTraceParams *params)
Constructor.
Definition: elastic_trace.cc:47
ElasticTrace::InstExecInfo::toCommitTick
Tick toCommitTick
Timestamp when instruction execution is completed in execute stage and instruction is marked as ready...
Definition: elastic_trace.hh:205
ElasticTrace::TraceInfo::isComp
bool isComp() const
Is the record a fetch triggering an Icache request.
Definition: elastic_trace.hh:300
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:619
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:774
MaxTick
const Tick MaxTick
Definition: types.hh:65
ElasticTrace::TraceInfo::numDepts
uint32_t numDepts
Definition: elastic_trace.hh:280
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:301
eventq.hh

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17