gem5  v21.1.0.2
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 
48 namespace gem5
49 {
50 
52 {
53  public:
54  typedef TesterThreadParams Params;
55  TesterThread(const Params &p);
56  virtual ~TesterThread();
57 
60 
61  void wakeup();
62  void scheduleWakeup();
63  void checkDeadlock();
65 
68  ProtocolTester::GMTokenPort *_tokenPort = nullptr,
69  ProtocolTester::SeqPort *_sqcPort = nullptr,
70  ProtocolTester::SeqPort *_scalarPort = nullptr);
71 
72  const std::string& getName() const { return threadName; }
73 
74  // must be implemented by a child class
75  virtual void hitCallback(PacketPtr pkt) = 0;
76 
77  int getTesterThreadId() const { return threadId; }
78  int getNumLanes() const { return numLanes; }
79  // check if the input location would satisfy DRF constraint
80  bool checkDRF(Location atomic_loc, Location loc, bool isStore) const;
81 
82  void printAllOutstandingReqs(std::stringstream& ss) const;
83 
84  protected:
85  class TesterThreadEvent : public Event
86  {
87  private:
89  std::string desc;
90 
91  public:
92  TesterThreadEvent(TesterThread* _thread, std::string _description)
93  : Event(CPU_Tick_Pri), thread(_thread), desc(_description)
94  {}
95  void setDesc(std::string _description) { desc = _description; }
96  void process() override { thread->wakeup(); }
97  const std::string name() const override { return desc; }
98  };
99 
101 
102  class DeadlockCheckEvent : public Event
103  {
104  private:
106 
107  public:
109  : Event(CPU_Tick_Pri), thread(_thread)
110  {}
111  void process() override { thread->checkDeadlock(); }
112 
113  const std::string
114  name() const override
115  {
116  return "Tester deadlock check";
117  }
118  };
119 
121 
123  {
124  int lane;
128 
129  OutstandingReq(int _lane, Location _loc, Value _val, Cycles _cycle)
130  : lane(_lane), origLoc(_loc), storedValue(_val), issueCycle(_cycle)
131  {}
132 
134  {}
135  };
136 
137  // the unique global id of this thread
138  int threadId;
139  // width of this thread (1 for cpu thread & wf size for gpu wavefront)
140  int numLanes;
141  // thread name
142  std::string threadName;
143  // pointer to the main tester
145  // pointer to the address manager
147 
148  ProtocolTester::SeqPort *port; // main data port (GPU-vector data)
150  ProtocolTester::SeqPort *scalarPort; // nullptr for CPU
151  ProtocolTester::SeqPort *sqcPort; // nullptr for CPU
152 
153  // a list of issued episodes sorted by time
154  // the last episode in the list is the current episode
157  // pointer to the current episode
159  // pointer to the current action
161 
162  // number of outstanding requests that are waiting for their responses
166 
167  // last cycle when there is an event in this thread
170 
171  // a per-address list of outstanding requests
173  typedef std::unordered_map<Addr, OutstandingReqList> OutstandingReqTable;
177 
178  void issueNewEpisode();
179  // check if the next action in the current episode satisfies all wait_cnt
180  // constraints and is ready to issue
181  bool isNextActionReady();
182  void issueNextAction();
183 
184  // issue Ops to Ruby memory
185  // must be implemented by a child class
186  virtual void issueLoadOps() = 0;
187  virtual void issueStoreOps() = 0;
188  virtual void issueAtomicOps() = 0;
189  virtual void issueAcquireOp() = 0;
190  virtual void issueReleaseOp() = 0;
191 
192  // add an outstanding request to its corresponding table
194  int lane, Location loc,
195  Value stored_val = AddressManager::INVALID_VALUE);
196 
197  // pop an outstanding request from the input table
199  Addr address);
200 
201  // validate all atomic responses
202  void validateAtomicResp(Location loc, int lane, Value ret_val);
203  // validate all Load responses
204  void validateLoadResp(Location loc, int lane, Value ret_val);
205 
206  void printOutstandingReqs(const OutstandingReqTable& table,
207  std::stringstream& ss) const;
208 };
209 
210 } // namespace gem5
211 
212 #endif /* CPU_TESTERS_PROTOCOL_TESTER_TESTER_THREAD_HH_ */
gem5::TesterThread::tokenPort
ProtocolTester::GMTokenPort * tokenPort
Definition: tester_thread.hh:149
gem5::TesterThread::Params
TesterThreadParams Params
Definition: tester_thread.hh:54
gem5::TesterThread::TesterThreadEvent::setDesc
void setDesc(std::string _description)
Definition: tester_thread.hh:95
gem5::TesterThread::deadlockCheckEvent
DeadlockCheckEvent deadlockCheckEvent
Definition: tester_thread.hh:120
episode.hh
gem5::TesterThread::OutstandingReq::~OutstandingReq
~OutstandingReq()
Definition: tester_thread.hh:133
gem5::TesterThread::isNextActionReady
bool isNextActionReady()
Definition: tester_thread.cc:158
gem5::TesterThread::issueLoadOps
virtual void issueLoadOps()=0
gem5::TesterThread::OutstandingReq::OutstandingReq
OutstandingReq(int _lane, Location _loc, Value _val, Cycles _cycle)
Definition: tester_thread.hh:129
gem5::TesterThread::issueAtomicOps
virtual void issueAtomicOps()=0
gem5::TesterThread::checkDeadlock
void checkDeadlock()
Definition: tester_thread.cc:398
gem5::TesterThread::TesterThreadEvent::thread
TesterThread * thread
Definition: tester_thread.hh:88
gem5::TesterThread::port
ProtocolTester::SeqPort * port
Definition: tester_thread.hh:148
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:105
gem5::AddressManager
Definition: address_manager.hh:122
gem5::TesterThread::EpisodeHistory
std::vector< Episode * > EpisodeHistory
Definition: tester_thread.hh:155
gem5::TesterThread::getNumLanes
int getNumLanes() const
Definition: tester_thread.hh:78
gem5::TesterThread::curAction
const Episode::Action * curAction
Definition: tester_thread.hh:160
gem5::TesterThread::pendingAtomicCount
int pendingAtomicCount
Definition: tester_thread.hh:165
gem5::TesterThread::issueNextAction
void issueNextAction()
Definition: tester_thread.cc:250
gem5::TesterThread::pendingFenceCount
int pendingFenceCount
Definition: tester_thread.hh:164
gem5::TesterThread::outstandingAtomics
OutstandingReqTable outstandingAtomics
Definition: tester_thread.hh:176
gem5::TesterThread::TesterThreadEvent::process
void process() override
Definition: tester_thread.hh:96
gem5::TesterThread::threadEvent
TesterThreadEvent threadEvent
Definition: tester_thread.hh:100
std::vector< Episode * >
gem5::TesterThread::OutstandingReq::origLoc
Location origLoc
Definition: tester_thread.hh:125
gem5::TesterThread::lastActiveCycle
Cycles lastActiveCycle
Definition: tester_thread.hh:168
gem5::TesterThread::DeadlockCheckEvent::name
const std::string name() const override
Definition: tester_thread.hh:114
gem5::TesterThread
Definition: tester_thread.hh:51
gem5::ProtocolTester::SeqPort
Definition: protocol_tester.hh:74
gem5::TesterThread::pendingLdStCount
int pendingLdStCount
Definition: tester_thread.hh:163
gem5::TesterThread::TesterThreadEvent::desc
std::string desc
Definition: tester_thread.hh:89
gem5::TesterThread::issueStoreOps
virtual void issueStoreOps()=0
gem5::TesterThread::TesterThreadEvent::TesterThreadEvent
TesterThreadEvent(TesterThread *_thread, std::string _description)
Definition: tester_thread.hh:92
gem5::TesterThread::TesterThreadEvent::name
const std::string name() const override
Definition: tester_thread.hh:97
gem5::TesterThread::episodeHistory
EpisodeHistory episodeHistory
Definition: tester_thread.hh:156
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:129
gem5::TesterThread::getName
const std::string & getName() const
Definition: tester_thread.hh:72
gem5::TesterThread::outstandingStores
OutstandingReqTable outstandingStores
Definition: tester_thread.hh:175
gem5::TesterThread::popOutstandingReq
OutstandingReq popOutstandingReq(OutstandingReqTable &req_table, Addr address)
Definition: tester_thread.cc:310
gem5::TesterThread::OutstandingReq::issueCycle
Cycles issueCycle
Definition: tester_thread.hh:127
gem5::Event
Definition: eventq.hh:251
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::TesterThread::threadId
int threadId
Definition: tester_thread.hh:138
gem5::TesterThread::numLanes
int numLanes
Definition: tester_thread.hh:140
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::TesterThread::validateLoadResp
void validateLoadResp(Location loc, int lane, Value ret_val)
Definition: tester_thread.cc:360
gem5::ProtocolTester
Definition: protocol_tester.hh:71
gem5::TesterThread::issueAcquireOp
virtual void issueAcquireOp()=0
gem5::TesterThread::sqcPort
ProtocolTester::SeqPort * sqcPort
Definition: tester_thread.hh:151
gem5::TesterThread::TesterThreadEvent
Definition: tester_thread.hh:85
gpu_dyn_inst.hh
gem5::TesterThread::OutstandingReqList
std::vector< OutstandingReq > OutstandingReqList
Definition: tester_thread.hh:172
ss
std::stringstream ss
Definition: trace.test.cc:45
gem5::AddressManager::Location
int32_t Location
Definition: address_manager.hh:129
gem5::AddressManager::INVALID_VALUE
static const int INVALID_VALUE
Definition: address_manager.hh:153
gem5::TesterThread::getTesterThreadId
int getTesterThreadId() const
Definition: tester_thread.hh:77
gem5::TesterThread::printOutstandingReqs
void printOutstandingReqs(const OutstandingReqTable &table, std::stringstream &ss) const
Definition: tester_thread.cc:423
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:58
gem5::TesterThread::addrManager
AddressManager * addrManager
Definition: tester_thread.hh:146
gem5::TesterThread::scalarPort
ProtocolTester::SeqPort * scalarPort
Definition: tester_thread.hh:150
gem5::TesterThread::OutstandingReq::storedValue
Value storedValue
Definition: tester_thread.hh:126
gem5::TesterThread::OutstandingReq::lane
int lane
Definition: tester_thread.hh:124
gem5::TesterThread::DeadlockCheckEvent::DeadlockCheckEvent
DeadlockCheckEvent(TesterThread *_thread)
Definition: tester_thread.hh:108
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:293
gem5::TesterThread::outstandingLoads
OutstandingReqTable outstandingLoads
Definition: tester_thread.hh:174
gem5::TesterThread::wakeup
void wakeup()
Definition: tester_thread.cc:66
gem5::TesterThread::scheduleDeadlockCheckEvent
void scheduleDeadlockCheckEvent()
Definition: tester_thread.cc:121
gem5::TesterThread::~TesterThread
virtual ~TesterThread()
Definition: tester_thread.cc:57
gem5::AddressManager::Value
int32_t Value
Definition: address_manager.hh:128
gem5::ProtocolTester::GMTokenPort
Definition: protocol_tester.hh:88
gem5::TesterThread::curEpisode
Episode * curEpisode
Definition: tester_thread.hh:158
clocked_object.hh
address_manager.hh
protocol_tester.hh
token_port.hh
gem5::TesterThread::issueNewEpisode
void issueNewEpisode()
Definition: tester_thread.cc:147
gem5::TesterThread::printAllOutstandingReqs
void printAllOutstandingReqs(std::stringstream &ss) const
Definition: tester_thread.cc:438
gem5::TesterThread::DeadlockCheckEvent
Definition: tester_thread.hh:102
gem5::TesterThread::DeadlockCheckEvent::process
void process() override
Definition: tester_thread.hh:111
gem5::TesterThread::deadlockThreshold
Cycles deadlockThreshold
Definition: tester_thread.hh:169
gem5::TesterThread::checkDRF
bool checkDRF(Location atomic_loc, Location loc, bool isStore) const
Definition: tester_thread.cc:387
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:204
gem5::TesterThread::validateAtomicResp
void validateAtomicResp(Location loc, int lane, Value ret_val)
Definition: tester_thread.cc:336
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::TesterThread::OutstandingReqTable
std::unordered_map< Addr, OutstandingReqList > OutstandingReqTable
Definition: tester_thread.hh:173
gem5::TesterThread::OutstandingReq
Definition: tester_thread.hh:122
gem5::TesterThread::tester
ProtocolTester * tester
Definition: tester_thread.hh:144
gem5::TesterThread::TesterThread
TesterThread(const Params &p)
Definition: tester_thread.cc:43
gem5::TesterThread::threadName
std::string threadName
Definition: tester_thread.hh:142
gem5::TesterThread::scheduleWakeup
void scheduleWakeup()
Definition: tester_thread.cc:114
gem5::TesterThread::Value
AddressManager::Value Value
Definition: tester_thread.hh:59
gem5::Episode
Definition: episode.hh:47
gem5::Episode::Action
Definition: episode.hh:53
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Tue Sep 21 2021 12:25:09 for gem5 by doxygen 1.8.17