gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
46namespace 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
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
133 };
134
135 // the unique global id of this thread
137 // width of this thread (1 for cpu thread & wf size for gpu wavefront)
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)
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,
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
206 std::stringstream& ss) const;
207};
208
209} // namespace gem5
210
211#endif /* CPU_TESTERS_PROTOCOL_TESTER_TESTER_THREAD_HH_ */
static const int INVALID_VALUE
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
DeadlockCheckEvent(TesterThread *_thread)
const std::string name() const override
void setDesc(std::string _description)
const std::string name() const override
TesterThreadEvent(TesterThread *_thread, std::string _description)
TesterThread(const Params &p)
AddressManager * addrManager
AddressManager::Value Value
void attachTesterThreadToPorts(ProtocolTester *_tester, ProtocolTester::SeqPort *_port, ProtocolTester::GMTokenPort *_tokenPort=nullptr, ProtocolTester::SeqPort *_sqcPort=nullptr, ProtocolTester::SeqPort *_scalarPort=nullptr)
virtual void issueReleaseOp()=0
OutstandingReqTable outstandingAtomics
AddressManager::Location Location
void scheduleDeadlockCheckEvent()
void validateAtomicResp(Location loc, int lane, Value ret_val)
ProtocolTester * tester
ProtocolTester::SeqPort * port
bool checkDRF(Location atomic_loc, Location loc, bool isStore) const
int getNumLanes() const
void printAllOutstandingReqs(std::stringstream &ss) const
DeadlockCheckEvent deadlockCheckEvent
virtual void issueAcquireOp()=0
ProtocolTester::SeqPort * scalarPort
OutstandingReqTable outstandingStores
void addOutstandingReqs(OutstandingReqTable &req_table, Addr addr, int lane, Location loc, Value stored_val=AddressManager::INVALID_VALUE)
virtual void issueStoreOps()=0
OutstandingReqTable outstandingLoads
ProtocolTester::GMTokenPort * tokenPort
EpisodeHistory episodeHistory
OutstandingReq popOutstandingReq(OutstandingReqTable &req_table, Addr address)
const Episode::Action * curAction
virtual void issueAtomicOps()=0
ProtocolTester::SeqPort * sqcPort
void printOutstandingReqs(const OutstandingReqTable &table, std::stringstream &ss) const
TesterThreadParams Params
virtual void issueLoadOps()=0
std::unordered_map< Addr, OutstandingReqList > OutstandingReqTable
std::vector< Episode * > EpisodeHistory
virtual void hitCallback(PacketPtr pkt)=0
TesterThreadEvent threadEvent
std::vector< OutstandingReq > OutstandingReqList
const std::string & getName() const
int getTesterThreadId() const
void validateLoadResp(Location loc, int lane, Value ret_val)
STL vector class.
Definition stl.hh:37
ClockedObject declaration and implementation.
static const Priority CPU_Tick_Pri
CPU ticks must come after other associated CPU events (such as writebacks).
Definition eventq.hh:207
Bitfield< 21 > ss
Definition misc_types.hh:60
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
OutstandingReq(int _lane, Location _loc, Value _val, Cycles _cycle)

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0