gem5 v24.1.0.1
Loading...
Searching...
No Matches
protocol_tester.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#ifndef CPU_TESTERS_PROTOCOL_TESTER_PROTOCOL_TESTER_HH_
33#define CPU_TESTERS_PROTOCOL_TESTER_PROTOCOL_TESTER_HH_
34
35/*
36 * The tester includes the main ProtocolTester that manages all ports to the
37 * memory system.
38 * TesterThreads are mapped to certain data port(s)
39 *
40 * TesterThreads inject memory requests through their data ports.
41 * The tester receives and validates responses from the memory.
42 *
43 * Main components
44 * - AddressManager: generate DRF request streams &
45 * validate data response against an internal log_table
46 * - Episode: a sequence of requests
47 * - Thread: either GPU wavefront or CPU thread
48 */
49
50#include <iostream>
51#include <map>
52#include <string>
53#include <vector>
54
55#include "base/random.hh"
56#include "base/types.hh"
58#include "mem/packet.hh"
60#include "mem/token_port.hh"
61#include "params/ProtocolTester.hh"
62
63namespace gem5
64{
65
66class TesterThread;
67class CpuThread;
68class GpuWavefront;
69
71{
72 public:
73 class SeqPort : public RequestPort
74 {
75 public:
76 SeqPort(const std::string &_name, ProtocolTester *_tester, PortID _id,
77 PortID _index)
78 : RequestPort(_name, _id)
79 {}
80
81 protected:
82 virtual bool recvTimingResp(PacketPtr pkt);
83 virtual void recvReqRetry()
84 { panic("%s does not expect a retry\n", name()); }
85 };
86
88 {
89 public:
90 GMTokenPort(const std::string& name, ProtocolTester *_tester,
92 : TokenRequestPort(name, _tester, id)
93 {}
95
96 protected:
97 bool recvTimingResp(PacketPtr) { return false; }
98 void recvReqRetry() {}
99 };
100
102 {
105 {
106 assert(_th);
107 th = _th;
108 }
109
111 {}
112 };
113
114 public:
115 typedef ProtocolTesterParams Params;
116 ProtocolTester(const Params &p);
118
121
122 void init() override;
124 Port& getPort(const std::string &if_name,
125 PortID idx=InvalidPortID) override;
126
127 int getEpisodeLength() const { return episodeLength; }
128 // return pointer to the address manager
130 // return true if the tester should stop issuing new episodes
131 bool checkExit();
132 // verify if a location to be picked for LD/ST will satisfy
133 // data race free requirement
134 bool checkDRF(Location atomic_loc, Location loc, bool isStore) const;
135 // return the next episode id and increment it
136 int getNextEpisodeID() { return nextEpisodeId++; }
137 // get action sequence number
138 int getActionSeqNum() { return actionCount++; }
139
140 // dump error log into a file and exit the simulation
141 void dumpErrorLog(std::stringstream& ss);
142
143 private:
145
146 // list of parameters taken from python scripts
158 // parameters controlling the address range that the tester can access
161 // the number of actions in an episode (episodeLength +- random number)
163 // the maximum number of episodes to be completed by this tester
165 // are we debuggin the tester
167
168 // all available requestor ports connected to Ruby
171 std::vector<RequestPort*> cuVectorPorts; // ports to GPU vector cache
172 std::vector<RequestPort*> cuSqcPorts; // ports to GPU inst cache
173 std::vector<RequestPort*> cuScalarPorts; // ports to GPU scalar cache
176 // all CPU, DMA, and GPU threads
180
181 // address manager that (1) generates DRF sequences of requests,
182 // (2) manages an internal log table and
183 // (3) validate response data
185
186 // number of CPUs and CUs
190 // unique id of the next episode
192
193 // global action count. Overflow is fine. It's used to uniquely identify
194 // per-wave & per-instruction memory requests in the coalescer
196
197 // if an exit signal was already sent
199
201
203};
204
205} // namespace gem5
206
207#endif /* CPU_TESTERS_PROTOCOL_TESTER_PROTOCOL_TESTER_HH_ */
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
const std::string _name
Definition named.hh:41
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Ports are used to interface objects to each other.
Definition port.hh:62
const PortID id
A numeric identifier to distinguish ports in a vector, and set to InvalidPortID in case this port is ...
Definition port.hh:79
const std::string name() const
Return port name (for DPRINTF).
Definition port.hh:111
GMTokenPort(const std::string &name, ProtocolTester *_tester, PortID id=InvalidPortID)
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
bool recvTimingResp(PacketPtr)
Receive a timing response from the peer.
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
SeqPort(const std::string &_name, ProtocolTester *_tester, PortID _id, PortID _index)
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
std::vector< GpuWavefront * > wfs
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
std::vector< RequestPort * > cuVectorPorts
AddressManager * addrManager
AddressManager::Location Location
std::vector< RequestPort * > cuSqcPorts
ProtocolTesterParams Params
std::vector< DmaThread * > dmaThreads
bool checkDRF(Location atomic_loc, Location loc, bool isStore) const
std::vector< GMTokenPort * > cuTokenPorts
std::vector< CpuThread * > cpuThreads
std::vector< RequestPort * > cuScalarPorts
std::vector< RequestPort * > dmaPorts
Random::RandomPtr rng
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
std::vector< TokenManager * > cuTokenManagers
std::vector< RequestPort * > cpuPorts
AddressManager * getAddressManager() const
AddressManager::Value Value
void dumpErrorLog(std::stringstream &ss)
std::shared_ptr< Random > RandomPtr
Definition random.hh:65
static RandomPtr genRandom()
Definition random.hh:68
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
STL vector class.
Definition stl.hh:37
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 21 > ss
Definition misc_types.hh:60
Bitfield< 0 > p
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
const PortID InvalidPortID
Definition types.hh:246
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
uint16_t RequestorID
Definition request.hh:95
Declaration of the Packet class.
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469

Generated on Mon Jan 13 2025 04:28:32 for gem5 by doxygen 1.9.8