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

Generated on Sun Jul 30 2023 01:56:53 for gem5 by doxygen 1.8.17