gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tester_thread.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * For use for simulation and test purposes only
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Tester thread issues requests to and receives responses from Ruby memory
36  */
37 
38 #ifndef CPU_TESTERS_PROTOCOL_TESTER_TESTER_THREAD_HH_
39 #define CPU_TESTERS_PROTOCOL_TESTER_TESTER_THREAD_HH_
40 
45 #include "mem/token_port.hh"
46 #include "sim/clocked_object.hh"
47 
49 {
50  public:
51  typedef TesterThreadParams Params;
52  TesterThread(const Params &p);
53  virtual ~TesterThread();
54 
57 
58  void wakeup();
59  void scheduleWakeup();
60  void checkDeadlock();
62 
65  ProtocolTester::GMTokenPort *_tokenPort = nullptr,
66  ProtocolTester::SeqPort *_sqcPort = nullptr,
67  ProtocolTester::SeqPort *_scalarPort = nullptr);
68 
69  const std::string& getName() const { return threadName; }
70 
71  // must be implemented by a child class
72  virtual void hitCallback(PacketPtr pkt) = 0;
73 
74  int getTesterThreadId() const { return threadId; }
75  int getNumLanes() const { return numLanes; }
76  // check if the input location would satisfy DRF constraint
77  bool checkDRF(Location atomic_loc, Location loc, bool isStore) const;
78 
79  void printAllOutstandingReqs(std::stringstream& ss) const;
80 
81  protected:
82  class TesterThreadEvent : public Event
83  {
84  private:
86  std::string desc;
87 
88  public:
89  TesterThreadEvent(TesterThread* _thread, std::string _description)
90  : Event(CPU_Tick_Pri), thread(_thread), desc(_description)
91  {}
92  void setDesc(std::string _description) { desc = _description; }
93  void process() override { thread->wakeup(); }
94  const std::string name() const override { return desc; }
95  };
96 
98 
99  class DeadlockCheckEvent : public Event
100  {
101  private:
103 
104  public:
106  : Event(CPU_Tick_Pri), thread(_thread)
107  {}
108  void process() override { thread->checkDeadlock(); }
109 
110  const std::string
111  name() const override
112  {
113  return "Tester deadlock check";
114  }
115  };
116 
118 
120  {
121  int lane;
125 
126  OutstandingReq(int _lane, Location _loc, Value _val, Cycles _cycle)
127  : lane(_lane), origLoc(_loc), storedValue(_val), issueCycle(_cycle)
128  {}
129 
131  {}
132  };
133 
134  // the unique global id of this thread
135  int threadId;
136  // width of this thread (1 for cpu thread & wf size for gpu wavefront)
137  int numLanes;
138  // thread name
139  std::string threadName;
140  // pointer to the main tester
142  // pointer to the address manager
144 
145  ProtocolTester::SeqPort *port; // main data port (GPU-vector data)
147  ProtocolTester::SeqPort *scalarPort; // nullptr for CPU
148  ProtocolTester::SeqPort *sqcPort; // nullptr for CPU
149 
150  // a list of issued episodes sorted by time
151  // the last episode in the list is the current episode
154  // pointer to the current episode
156  // pointer to the current action
158 
159  // number of outstanding requests that are waiting for their responses
163 
164  // last cycle when there is an event in this thread
167 
168  // a per-address list of outstanding requests
170  typedef std::unordered_map<Addr, OutstandingReqList> OutstandingReqTable;
174 
175  void issueNewEpisode();
176  // check if the next action in the current episode satisfies all wait_cnt
177  // constraints and is ready to issue
178  bool isNextActionReady();
179  void issueNextAction();
180 
181  // issue Ops to Ruby memory
182  // must be implemented by a child class
183  virtual void issueLoadOps() = 0;
184  virtual void issueStoreOps() = 0;
185  virtual void issueAtomicOps() = 0;
186  virtual void issueAcquireOp() = 0;
187  virtual void issueReleaseOp() = 0;
188 
189  // add an outstanding request to its corresponding table
191  int lane, Location loc,
192  Value stored_val = AddressManager::INVALID_VALUE);
193 
194  // pop an outstanding request from the input table
196  Addr address);
197 
198  // validate all atomic responses
199  void validateAtomicResp(Location loc, int lane, Value ret_val);
200  // validate all Load responses
201  void validateLoadResp(Location loc, int lane, Value ret_val);
202 
203  void printOutstandingReqs(const OutstandingReqTable& table,
204  std::stringstream& ss) const;
205 };
206 
207 #endif /* CPU_TESTERS_PROTOCOL_TESTER_TESTER_THREAD_HH_ */
TesterThread::outstandingStores
OutstandingReqTable outstandingStores
Definition: tester_thread.hh:172
TesterThread::TesterThreadEvent::thread
TesterThread * thread
Definition: tester_thread.hh:85
TesterThread::OutstandingReq::issueCycle
Cycles issueCycle
Definition: tester_thread.hh:124
TesterThread::Value
AddressManager::Value Value
Definition: tester_thread.hh:56
TesterThread::EpisodeHistory
std::vector< Episode * > EpisodeHistory
Definition: tester_thread.hh:152
episode.hh
TesterThread::pendingFenceCount
int pendingFenceCount
Definition: tester_thread.hh:161
AddressManager::Location
int32_t Location
Definition: address_manager.hh:126
EventBase::CPU_Tick_Pri
static const Priority CPU_Tick_Pri
CPU ticks must come after other associated CPU events (such as writebacks).
Definition: eventq.hh:201
TesterThread::issueStoreOps
virtual void issueStoreOps()=0
AddressManager::Value
int32_t Value
Definition: address_manager.hh:125
TesterThread::TesterThreadEvent::process
void process() override
Definition: tester_thread.hh:93
TesterThread::wakeup
void wakeup()
Definition: tester_thread.cc:63
TesterThread::TesterThreadEvent::setDesc
void setDesc(std::string _description)
Definition: tester_thread.hh:92
TesterThread::scalarPort
ProtocolTester::SeqPort * scalarPort
Definition: tester_thread.hh:147
TesterThread
Definition: tester_thread.hh:48
TesterThread::printAllOutstandingReqs
void printAllOutstandingReqs(std::stringstream &ss) const
Definition: tester_thread.cc:435
TesterThread::issueReleaseOp
virtual void issueReleaseOp()=0
TesterThread::TesterThreadEvent::desc
std::string desc
Definition: tester_thread.hh:86
TesterThread::numLanes
int numLanes
Definition: tester_thread.hh:137
TesterThread::OutstandingReq::origLoc
Location origLoc
Definition: tester_thread.hh:122
ProtocolTester::SeqPort
Definition: protocol_tester.hh:71
TesterThread::pendingAtomicCount
int pendingAtomicCount
Definition: tester_thread.hh:162
TesterThread::OutstandingReqTable
std::unordered_map< Addr, OutstandingReqList > OutstandingReqTable
Definition: tester_thread.hh:170
std::vector< Episode * >
TesterThread::issueNewEpisode
void issueNewEpisode()
Definition: tester_thread.cc:144
TesterThread::addrManager
AddressManager * addrManager
Definition: tester_thread.hh:143
TesterThread::~TesterThread
virtual ~TesterThread()
Definition: tester_thread.cc:54
TesterThread::issueNextAction
void issueNextAction()
Definition: tester_thread.cc:247
TesterThread::OutstandingReq::lane
int lane
Definition: tester_thread.hh:121
TesterThread::scheduleDeadlockCheckEvent
void scheduleDeadlockCheckEvent()
Definition: tester_thread.cc:118
TesterThread::OutstandingReqList
std::vector< OutstandingReq > OutstandingReqList
Definition: tester_thread.hh:169
TesterThread::checkDeadlock
void checkDeadlock()
Definition: tester_thread.cc:395
TesterThread::DeadlockCheckEvent
Definition: tester_thread.hh:99
TesterThread::TesterThreadEvent::name
const std::string name() const override
Definition: tester_thread.hh:94
ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:231
TesterThread::outstandingLoads
OutstandingReqTable outstandingLoads
Definition: tester_thread.hh:171
Episode::Action
Definition: episode.hh:50
TesterThread::issueAtomicOps
virtual void issueAtomicOps()=0
TesterThread::OutstandingReq
Definition: tester_thread.hh:119
TesterThread::threadName
std::string threadName
Definition: tester_thread.hh:139
TesterThread::checkDRF
bool checkDRF(Location atomic_loc, Location loc, bool isStore) const
Definition: tester_thread.cc:384
AddressManager
Definition: address_manager.hh:119
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
TesterThread::issueAcquireOp
virtual void issueAcquireOp()=0
Event
Definition: eventq.hh:248
TesterThread::curEpisode
Episode * curEpisode
Definition: tester_thread.hh:155
TesterThread::TesterThreadEvent::TesterThreadEvent
TesterThreadEvent(TesterThread *_thread, std::string _description)
Definition: tester_thread.hh:89
TesterThread::DeadlockCheckEvent::process
void process() override
Definition: tester_thread.hh:108
gpu_dyn_inst.hh
TesterThread::lastActiveCycle
Cycles lastActiveCycle
Definition: tester_thread.hh:165
Episode
Definition: episode.hh:44
TesterThread::deadlockCheckEvent
DeadlockCheckEvent deadlockCheckEvent
Definition: tester_thread.hh:117
TesterThread::deadlockThreshold
Cycles deadlockThreshold
Definition: tester_thread.hh:166
TesterThread::OutstandingReq::OutstandingReq
OutstandingReq(int _lane, Location _loc, Value _val, Cycles _cycle)
Definition: tester_thread.hh:126
TesterThread::curAction
const Episode::Action * curAction
Definition: tester_thread.hh:157
TesterThread::popOutstandingReq
OutstandingReq popOutstandingReq(OutstandingReqTable &req_table, Addr address)
Definition: tester_thread.cc:307
TesterThread::sqcPort
ProtocolTester::SeqPort * sqcPort
Definition: tester_thread.hh:148
TesterThread::DeadlockCheckEvent::name
const std::string name() const override
Definition: tester_thread.hh:111
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
TesterThread::validateAtomicResp
void validateAtomicResp(Location loc, int lane, Value ret_val)
Definition: tester_thread.cc:333
TesterThread::printOutstandingReqs
void printOutstandingReqs(const OutstandingReqTable &table, std::stringstream &ss) const
Definition: tester_thread.cc:420
ProtocolTester
Definition: protocol_tester.hh:68
TesterThread::issueLoadOps
virtual void issueLoadOps()=0
TesterThread::hitCallback
virtual void hitCallback(PacketPtr pkt)=0
TesterThread::Params
TesterThreadParams Params
Definition: tester_thread.hh:51
X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:80
TesterThread::threadId
int threadId
Definition: tester_thread.hh:135
TesterThread::TesterThreadEvent
Definition: tester_thread.hh:82
TesterThread::TesterThread
TesterThread(const Params &p)
Definition: tester_thread.cc:40
TesterThread::outstandingAtomics
OutstandingReqTable outstandingAtomics
Definition: tester_thread.hh:173
TesterThread::getTesterThreadId
int getTesterThreadId() const
Definition: tester_thread.hh:74
TesterThread::OutstandingReq::storedValue
Value storedValue
Definition: tester_thread.hh:123
TesterThread::scheduleWakeup
void scheduleWakeup()
Definition: tester_thread.cc:111
clocked_object.hh
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
TesterThread::isNextActionReady
bool isNextActionReady()
Definition: tester_thread.cc:155
address_manager.hh
protocol_tester.hh
token_port.hh
TesterThread::episodeHistory
EpisodeHistory episodeHistory
Definition: tester_thread.hh:153
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
TesterThread::threadEvent
TesterThreadEvent threadEvent
Definition: tester_thread.hh:97
TesterThread::attachTesterThreadToPorts
void attachTesterThreadToPorts(ProtocolTester *_tester, ProtocolTester::SeqPort *_port, ProtocolTester::GMTokenPort *_tokenPort=nullptr, ProtocolTester::SeqPort *_sqcPort=nullptr, ProtocolTester::SeqPort *_scalarPort=nullptr)
Definition: tester_thread.cc:126
TesterThread::getNumLanes
int getNumLanes() const
Definition: tester_thread.hh:75
TesterThread::DeadlockCheckEvent::DeadlockCheckEvent
DeadlockCheckEvent(TesterThread *_thread)
Definition: tester_thread.hh:105
TesterThread::pendingLdStCount
int pendingLdStCount
Definition: tester_thread.hh:160
TesterThread::Location
AddressManager::Location Location
Definition: tester_thread.hh:55
TesterThread::DeadlockCheckEvent::thread
TesterThread * thread
Definition: tester_thread.hh:102
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
TesterThread::addOutstandingReqs
void addOutstandingReqs(OutstandingReqTable &req_table, Addr addr, int lane, Location loc, Value stored_val=AddressManager::INVALID_VALUE)
Definition: tester_thread.cc:290
TesterThread::getName
const std::string & getName() const
Definition: tester_thread.hh:69
ProtocolTester::GMTokenPort
Definition: protocol_tester.hh:85
TesterThread::tokenPort
ProtocolTester::GMTokenPort * tokenPort
Definition: tester_thread.hh:146
TesterThread::tester
ProtocolTester * tester
Definition: tester_thread.hh:141
TesterThread::port
ProtocolTester::SeqPort * port
Definition: tester_thread.hh:145
TesterThread::validateLoadResp
void validateLoadResp(Location loc, int lane, Value ret_val)
Definition: tester_thread.cc:357
AddressManager::INVALID_VALUE
static const int INVALID_VALUE
Definition: address_manager.hh:150
TesterThread::OutstandingReq::~OutstandingReq
~OutstandingReq()
Definition: tester_thread.hh:130

Generated on Tue Mar 23 2021 19:41:25 for gem5 by doxygen 1.8.17