gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Authors: Radhika Jagtap
38  * Andreas Hansson
39  * Thomas Grass
40  */
41 
50 #ifndef __CPU_O3_PROBE_ELASTIC_TRACE_HH__
51 #define __CPU_O3_PROBE_ELASTIC_TRACE_HH__
52 
53 #include <set>
54 #include <unordered_map>
55 #include <utility>
56 
57 #include "cpu/o3/dyn_inst.hh"
58 #include "cpu/o3/impl.hh"
59 #include "mem/request.hh"
60 #include "params/ElasticTrace.hh"
61 #include "proto/inst_dep_record.pb.h"
62 #include "proto/packet.pb.h"
63 #include "proto/protoio.hh"
64 #include "sim/eventq.hh"
65 #include "sim/probe/probe.hh"
66 
89 {
90 
91  public:
94 
96  typedef ProtoMessage::InstDepRecord::RecordType RecordType;
97  typedef ProtoMessage::InstDepRecord Record;
98 
100  ElasticTrace(const ElasticTraceParams *params);
101 
106  void regProbeListeners();
107 
109  void regEtraceListeners();
110 
112  const std::string name() const;
113 
118  void flushTraces();
119 
127  void fetchReqTrace(const RequestPtr &req);
128 
135  void recordExecTick(const DynInstPtr &dyn_inst);
136 
144  void recordToCommTick(const DynInstPtr &dyn_inst);
145 
155  void updateRegDep(const DynInstPtr &dyn_inst);
156 
164  void removeRegDepMapEntry(const SeqNumRegPair &inst_reg_pair);
165 
172  void addSquashedInst(const DynInstPtr &head_inst);
173 
179  void addCommittedInst(const DynInstPtr &head_inst);
180 
182  void regStats();
183 
187 
188  private:
194  bool firstWin;
195 
201  {
217  std::set<InstSeqNum> physRegDepSet;
222  : executeTick(MaxTick),
224  { }
225  };
226 
234  std::unordered_map<InstSeqNum, InstExecInfo*> tempStore;
235 
241 
247  std::unordered_map<PhysRegIndex, InstSeqNum> physRegDepMap;
248 
259  struct TraceInfo
260  {
265  /* Instruction sequence number. */
269  /* Tick when instruction was in execute stage. */
271  /* Tick when instruction was marked ready and sent to commit stage. */
273  /* Tick when instruction was committed. */
275  /* If instruction was committed, as against squashed. */
276  bool commit;
277  /* List of order dependencies. */
279  /* List of physical register RAW dependencies. */
285  int64_t compDelay;
286  /* Number of dependents. */
287  uint32_t numDepts;
288  /* The instruction PC for a load, store or non load/store. */
290  /* Request flags in case of a load/store instruction */
292  /* Request physical address in case of a load/store instruction */
294  /* Request virtual address in case of a load/store instruction */
296  /* Address space id in case of a load/store instruction */
297  uint32_t asid;
298  /* Request size in case of a load/store instruction */
299  unsigned size;
302  : type(Record::INVALID)
303  { }
305  bool isLoad() const { return (type == Record::LOAD); }
307  bool isStore() const { return (type == Record::STORE); }
309  bool isComp() const { return (type == Record::COMP); }
311  const std::string& typeToStr() const;
319  Tick getExecuteTick() const;
320  };
321 
335 
340  std::unordered_map<InstSeqNum, TraceInfo*> traceInfoMap;
341 
344 
346  typedef typename std::reverse_iterator<depTraceItr> depTraceRevItr;
347 
354  uint32_t depWindowSize;
355 
358 
361 
364 
372 
374  const bool traceVirtAddr;
375 
378 
389  void addDepTraceRecord(const DynInstPtr &head_inst,
390  InstExecInfo* exec_info_ptr, bool commit);
391 
398  void clearTempStoreUntil(const DynInstPtr head_inst);
399 
410  void compDelayRob(TraceInfo* past_record, TraceInfo* new_record);
411 
423  void compDelayPhysRegDep(TraceInfo* past_record, TraceInfo* new_record);
424 
432  void writeDepTrace(uint32_t num_to_write);
433 
446  void updateCommitOrderDep(TraceInfo* new_record, bool find_load_not_store);
447 
459  void updateIssueOrderDep(TraceInfo* new_record);
460 
470  void assignRobDep(TraceInfo* past_record, TraceInfo* new_record);
471 
480  bool hasStoreCommitted(TraceInfo* past_record, Tick execute_tick) const;
481 
492  bool hasLoadCompleted(TraceInfo* past_record, Tick execute_tick) const;
493 
502  bool hasLoadBeenSent(TraceInfo* past_record, Tick execute_tick) const;
503 
514  bool hasCompCompleted(TraceInfo* past_record, Tick execute_tick) const;
515 
518 
524 
530 
536 
542 
545 
548 
554 
560 
561 };
562 #endif//__CPU_O3_PROBE_ELASTIC_TRACE_HH__
int64_t compDelay
Computational delay after the last dependent inst.
Stats::Scalar numIssueOrderDepOther
Number of non load/store insts that got assigned an issue order dependency because they were dependen...
void compDelayPhysRegDep(TraceInfo *past_record, TraceInfo *new_record)
Calculate the computational delay between an instruction and a subsequent instruction that has a Phys...
void flushTraces()
Process any outstanding trace records, flush them out to the protobuf output streams and delete the s...
void regProbeListeners()
Register the probe listeners that is the methods called on a probe point notify() call...
ElasticTrace(const ElasticTraceParams *params)
Constructor.
O3CPUImpl::DynInstPtr DynInstPtr
A ProtoOutputStream wraps a coded stream, potentially with compression, based on looking at the file ...
Definition: protoio.hh:92
bool isComp() const
Is the record a fetch triggering an Icache request.
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...
FullO3CPU< O3CPUImpl > * cpu
Pointer to the O3CPU that is this listener's parent a.k.a.
void regEtraceListeners()
Register all listeners.
The elastic trace is a type of probe listener and listens to probe points in multiple stages of the O...
STL pair class.
Definition: stl.hh:61
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 ...
uint32_t FlagsType
Definition: request.hh:90
std::unordered_map< InstSeqNum, InstExecInfo * > tempStore
Temporary store of InstExecInfo objects.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
bool isStore() const
Is the record a store.
std::pair< InstSeqNum, PhysRegIndex > SeqNumRegPair
const Params * params() const
Definition: sim_object.hh:111
void addDepTraceRecord(const DynInstPtr &head_inst, InstExecInfo *exec_info_ptr, bool commit)
Add a record to the dependency trace depTrace which is a sequential container.
bool allProbesReg
Whther the elastic trace listener has been registered for all probes.
uint32_t depWindowSize
The maximum distance for a dependency and is set by a top level level parameter.
std::vector< TraceInfo * >::iterator depTraceItr
Typedef of iterator to the instruction dependency trace.
std::vector< TraceInfo * > depTrace
The instruction dependency trace containing TraceInfo objects.
TraceInfo()
Default Constructor.
void addSquashedInst(const DynInstPtr &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 ...
If you want a reference counting pointer to a mutable object, create it like this: ...
Definition: refcnt.hh:106
EventWrapper< ElasticTrace,&ElasticTrace::regEtraceListeners > regEtraceListenersEvent
Event to trigger registering this listener for all probe points.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
void updateRegDep(const DynInstPtr &dyn_inst)
Record a Read After Write physical register dependency if there has been a write to the source regist...
STL vector class.
Definition: stl.hh:40
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 ...
Stats::Scalar numIssueOrderDepStores
Number of store insts that got assigned an issue order dependency because they were dependency-free...
ProtoMessage::InstDepRecord::RecordType RecordType
Trace record types corresponding to instruction node types.
void recordExecTick(const DynInstPtr &dyn_inst)
Populate the execute timestamp field in an InstExecInfo object for an instruction in flight...
Stats::Scalar numOrderDepStores
Number of stores that got assigned a commit order dependency on a past load/store.
const Tick MaxTick
Definition: types.hh:65
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...
Stats::Scalar numIssueOrderDepLoads
Number of load insts that got assigned an issue order dependency because they were dependency-free...
Stats::Scalar maxPhysRegDepMapSize
Maximum size of the map that holds the last writer to a physical register.
void recordToCommTick(const DynInstPtr &dyn_inst)
Populate the timestamp field in an InstExecInfo object for an instruction in flight when it is execut...
uint64_t Tick
Tick count type.
Definition: types.hh:63
ProtoOutputStream * dataTraceStream
Protobuf output stream for data dependency trace.
This class is a minimal wrapper around SimObject.
Definition: probe.hh:100
std::unordered_map< InstSeqNum, TraceInfo * > traceInfoMap
Map where the instruction sequence number is mapped to the pointer to the TraceInfo object...
bool hasLoadCompleted(TraceInfo *past_record, Tick execute_tick) const
Check if past record is a load that completed earlier than the execute tick.
uint64_t InstSeqNum
Definition: inst_seq.hh:40
std::list< InstSeqNum > physRegDepList
Tick getExecuteTick() const
Get the execute tick of the instruction.
Tick toCommitTick
Timestamp when instruction execution is completed in execute stage and instruction is marked as ready...
void regStats()
Register statistics for the elastic trace.
void updateIssueOrderDep(TraceInfo *new_record)
Reverse iterate through the graph, search for an issue order dependency for a new node and update the...
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Request::FlagsType reqFlags
bool hasStoreCommitted(TraceInfo *past_record, Tick execute_tick) const
Check if past record is a store sent earlier than the execute tick.
const std::string & typeToStr() const
Return string specifying the type of the node.
ProtoOutputStream * instTraceStream
Protobuf output stream for instruction fetch trace.
bool hasCompCompleted(TraceInfo *past_record, Tick execute_tick) const
Check if past record is a comp node that completed earlier than the execute tick. ...
void clearTempStoreUntil(const DynInstPtr head_inst)
Clear entries in the temporary store of execution info objects to free allocated memory until the pre...
bool hasLoadBeenSent(TraceInfo *past_record, Tick execute_tick) const
Check if past record is a load sent earlier than the execute tick.
void fetchReqTrace(const RequestPtr &req)
Take the fields of the request class object that are relevant to create an instruction fetch request...
bool isLoad() const
Is the record a load.
Stats::Scalar maxTempStoreSize
Maximum size of the temporary store mostly useful as a check that it is not growing.
std::set< InstSeqNum > physRegDepSet
Set of instruction sequence numbers that this instruction depends on due to Read After Write data dep...
std::list< InstSeqNum > robDepList
Stats::Scalar maxNumDependents
Maximum number of dependents on any instruction.
bool firstWin
Used for checking the first window for processing and writing of dependency trace.
ProtoMessage::InstDepRecord Record
const bool traceVirtAddr
Whether to trace virtual addresses for memory requests.
Tick executeTick
Timestamp when instruction was first processed by execute stage.
std::reverse_iterator< depTraceItr > depTraceRevItr
Typedef of the reverse iterator to the instruction dependency trace.
std::unordered_map< PhysRegIndex, InstSeqNum > physRegDepMap
Map for recording the producer of a physical register to check Read After Write dependencies.
const InstSeqNum startTraceInst
Number of instructions after which to enable tracing.
InstSeqNum lastClearedSeqNum
The last cleared instruction sequence number used to free up the memory allocated in the temporary st...
void addCommittedInst(const DynInstPtr &head_inst)
Add an instruction that is at the head of the ROB and is committed.
Stats::Scalar numRegDep
Number of register dependencies recorded during tracing.
RecordType type
The type of trace record for the instruction node.
Stats::Scalar numFilteredNodes
Number of filtered nodes.
Declaration of a wrapper for protobuf output streams and input streams.
const std::string name() const
Returns the name of the trace probe listener.
void compDelayRob(TraceInfo *past_record, TraceInfo *new_record)
Calculate the computational delay between an instruction and a subsequent instruction that has an ROB...

Generated on Fri Jun 9 2017 13:03:43 for gem5 by doxygen 1.8.6