gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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/types.hh"
57 #include "mem/packet.hh"
59 #include "mem/token_port.hh"
60 #include "params/ProtocolTester.hh"
61 
62 namespace gem5
63 {
64 
65 class TesterThread;
66 class CpuThread;
67 class GpuWavefront;
68 
70 {
71  public:
72  class SeqPort : public RequestPort
73  {
74  public:
75  SeqPort(const std::string &_name, ProtocolTester *_tester, PortID _id,
76  PortID _index)
77  : RequestPort(_name, _id)
78  {}
79 
80  protected:
81  virtual bool recvTimingResp(PacketPtr pkt);
82  virtual void recvReqRetry()
83  { panic("%s does not expect a retry\n", name()); }
84  };
85 
87  {
88  public:
89  GMTokenPort(const std::string& name, ProtocolTester *_tester,
90  PortID id = InvalidPortID)
91  : TokenRequestPort(name, _tester, id)
92  {}
94 
95  protected:
96  bool recvTimingResp(PacketPtr) { return false; }
97  void recvReqRetry() {}
98  };
99 
101  {
104  {
105  assert(_th);
106  th = _th;
107  }
108 
110  {}
111  };
112 
113  public:
114  typedef ProtocolTesterParams Params;
115  ProtocolTester(const Params &p);
116  ~ProtocolTester();
117 
120 
121  void init() override;
123  Port& getPort(const std::string &if_name,
124  PortID idx=InvalidPortID) override;
125 
126  int getEpisodeLength() const { return episodeLength; }
127  // return pointer to the address manager
129  // return true if the tester should stop issuing new episodes
130  bool checkExit();
131  // verify if a location to be picked for LD/ST will satisfy
132  // data race free requirement
133  bool checkDRF(Location atomic_loc, Location loc, bool isStore) const;
134  // return the next episode id and increment it
135  int getNextEpisodeID() { return nextEpisodeId++; }
136  // get action sequence number
137  int getActionSeqNum() { return actionCount++; }
138 
139  // dump error log into a file and exit the simulation
140  void dumpErrorLog(std::stringstream& ss);
141 
142  private:
144 
145  // list of parameters taken from python scripts
157  // parameters controlling the address range that the tester can access
160  // the number of actions in an episode (episodeLength +- random number)
162  // the maximum number of episodes to be completed by this tester
164  // are we debuggin the tester
166 
167  // all available requestor ports connected to Ruby
170  std::vector<RequestPort*> cuVectorPorts; // ports to GPU vector cache
171  std::vector<RequestPort*> cuSqcPorts; // ports to GPU inst cache
172  std::vector<RequestPort*> cuScalarPorts; // ports to GPU scalar cache
175  // all CPU, DMA, and GPU threads
179 
180  // address manager that (1) generates DRF sequences of requests,
181  // (2) manages an internal log table and
182  // (3) validate response data
184 
185  // number of CPUs and CUs
186  int numCpus;
187  int numDmas;
188  int numCus;
189  // unique id of the next episode
191 
192  // global action count. Overflow is fine. It's used to uniquely identify
193  // per-wave & per-instruction memory requests in the coalescer
195 
196  // if an exit signal was already sent
198 
200 };
201 
202 } // namespace gem5
203 
204 #endif /* CPU_TESTERS_PROTOCOL_TESTER_PROTOCOL_TESTER_HH_ */
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
gem5::ProtocolTester::dmaThreads
std::vector< DmaThread * > dmaThreads
Definition: protocol_tester.hh:177
gem5::ProtocolTester::sentExitSignal
bool sentExitSignal
Definition: protocol_tester.hh:197
gem5::Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
gem5::ProtocolTester::numCusPerScalar
int numCusPerScalar
Definition: protocol_tester.hh:153
gem5::ProtocolTester::nextEpisodeId
int nextEpisodeId
Definition: protocol_tester.hh:190
gem5::ProtocolTester::ProtocolTester
ProtocolTester(const Params &p)
Definition: protocol_tester.cc:51
gem5::ProtocolTester::cuTokenPorts
std::vector< GMTokenPort * > cuTokenPorts
Definition: protocol_tester.hh:174
gem5::ProtocolTester::numAtomicLocs
int numAtomicLocs
Definition: protocol_tester.hh:158
gem5::AddressManager
Definition: address_manager.hh:120
gem5::ProtocolTester::debugTester
bool debugTester
Definition: protocol_tester.hh:165
gem5::ProtocolTester::cuTokenManagers
std::vector< TokenManager * > cuTokenManagers
Definition: protocol_tester.hh:173
gem5::ProtocolTester::numCus
int numCus
Definition: protocol_tester.hh:188
gem5::Port::id
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
gem5::ProtocolTester::GMTokenPort::~GMTokenPort
~GMTokenPort()
Definition: protocol_tester.hh:93
gem5::ProtocolTester::dmaPorts
std::vector< RequestPort * > dmaPorts
Definition: protocol_tester.hh:169
gem5::ProtocolTester::cpuPorts
std::vector< RequestPort * > cpuPorts
Definition: protocol_tester.hh:168
gem5::ProtocolTester::cuSqcPorts
std::vector< RequestPort * > cuSqcPorts
Definition: protocol_tester.hh:171
gem5::ProtocolTester::numScalarPorts
int numScalarPorts
Definition: protocol_tester.hh:150
gem5::ProtocolTester::numCpuPorts
int numCpuPorts
Definition: protocol_tester.hh:146
gem5::ProtocolTester::numCusPerSqc
int numCusPerSqc
Definition: protocol_tester.hh:152
std::vector
STL vector class.
Definition: stl.hh:37
gem5::ProtocolTester::maxNumEpisodes
int maxNumEpisodes
Definition: protocol_tester.hh:163
gem5::ProtocolTester::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: protocol_tester.cc:197
gem5::ProtocolTester::SenderState::~SenderState
~SenderState()
Definition: protocol_tester.hh:109
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:246
gem5::TesterThread
Definition: tester_thread.hh:49
gem5::ProtocolTester::SeqPort
Definition: protocol_tester.hh:72
gem5::ProtocolTester::numDmas
int numDmas
Definition: protocol_tester.hh:187
packet.hh
gem5::RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:118
gem5::ProtocolTester::requestorId
RequestorID requestorId()
Definition: protocol_tester.hh:122
gem5::ProtocolTester::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: protocol_tester.cc:242
gem5::ProtocolTester::logFile
OutputStream * logFile
Definition: protocol_tester.hh:199
gem5::ProtocolTester::getEpisodeLength
int getEpisodeLength() const
Definition: protocol_tester.hh:126
gem5::ProtocolTester::cpuThreads
std::vector< CpuThread * > cpuThreads
Definition: protocol_tester.hh:176
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::ProtocolTester::numTokenPorts
int numTokenPorts
Definition: protocol_tester.hh:151
gem5::ProtocolTester::SenderState
Definition: protocol_tester.hh:100
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
gem5::ProtocolTester::GMTokenPort::recvReqRetry
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: protocol_tester.hh:97
gem5::ProtocolTester::numSqcPorts
int numSqcPorts
Definition: protocol_tester.hh:149
gem5::ProtocolTester
Definition: protocol_tester.hh:69
gem5::ProtocolTester::cuScalarPorts
std::vector< RequestPort * > cuScalarPorts
Definition: protocol_tester.hh:172
gem5::ProtocolTester::numDmaPorts
int numDmaPorts
Definition: protocol_tester.hh:147
gem5::ProtocolTester::numWisPerWf
int numWisPerWf
Definition: protocol_tester.hh:155
gem5::ProtocolTester::SenderState::th
TesterThread * th
Definition: protocol_tester.hh:102
gem5::ProtocolTester::getActionSeqNum
int getActionSeqNum()
Definition: protocol_tester.hh:137
gem5::ProtocolTester::checkExit
bool checkExit()
Definition: protocol_tester.cc:282
gem5::ProtocolTester::numCuTokens
int numCuTokens
Definition: protocol_tester.hh:156
ss
std::stringstream ss
Definition: trace.test.cc:45
gem5::AddressManager::Location
int32_t Location
Definition: address_manager.hh:127
gem5::ProtocolTester::GMTokenPort::GMTokenPort
GMTokenPort(const std::string &name, ProtocolTester *_tester, PortID id=InvalidPortID)
Definition: protocol_tester.hh:89
gem5::ProtocolTester::dumpErrorLog
void dumpErrorLog(std::stringstream &ss)
Definition: protocol_tester.cc:322
gem5::Packet::SenderState
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition: packet.hh:468
gem5::ProtocolTester::checkDRF
bool checkDRF(Location atomic_loc, Location loc, bool isStore) const
Definition: protocol_tester.cc:297
gem5::ProtocolTester::numWfsPerCu
int numWfsPerCu
Definition: protocol_tester.hh:154
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
gem5::ProtocolTester::numNormalLocsPerAtomic
int numNormalLocsPerAtomic
Definition: protocol_tester.hh:159
gem5::AddressManager::Value
int32_t Value
Definition: address_manager.hh:126
gem5::ProtocolTester::GMTokenPort
Definition: protocol_tester.hh:86
gem5::ProtocolTester::Params
ProtocolTesterParams Params
Definition: protocol_tester.hh:114
gem5::ProtocolTester::SeqPort::recvReqRetry
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: protocol_tester.hh:82
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
types.hh
gem5::ProtocolTester::SenderState::SenderState
SenderState(TesterThread *_th)
Definition: protocol_tester.hh:103
address_manager.hh
token_port.hh
gem5::ProtocolTester::getNextEpisodeID
int getNextEpisodeID()
Definition: protocol_tester.hh:135
gem5::ProtocolTester::numVectorPorts
int numVectorPorts
Definition: protocol_tester.hh:148
gem5::ProtocolTester::SeqPort::recvTimingResp
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: protocol_tester.cc:350
gem5::ProtocolTester::Location
AddressManager::Location Location
Definition: protocol_tester.hh:118
gem5::ProtocolTester::getAddressManager
AddressManager * getAddressManager() const
Definition: protocol_tester.hh:128
gem5::RequestorID
uint16_t RequestorID
Definition: request.hh:95
gem5::ProtocolTester::numCpus
int numCpus
Definition: protocol_tester.hh:186
gem5::ProtocolTester::GMTokenPort::recvTimingResp
bool recvTimingResp(PacketPtr)
Receive a timing response from the peer.
Definition: protocol_tester.hh:96
gem5::ProtocolTester::episodeLength
int episodeLength
Definition: protocol_tester.hh:161
gem5::ProtocolTester::~ProtocolTester
~ProtocolTester()
Definition: protocol_tester.cc:178
gem5::ProtocolTester::Value
AddressManager::Value Value
Definition: protocol_tester.hh:119
gem5::ProtocolTester::SeqPort::SeqPort
SeqPort(const std::string &_name, ProtocolTester *_tester, PortID _id, PortID _index)
Definition: protocol_tester.hh:75
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
RubyPort.hh
gem5::OutputStream
Definition: output.hh:56
gem5::ProtocolTester::_requestorId
RequestorID _requestorId
Definition: protocol_tester.hh:143
gem5::ProtocolTester::actionCount
int actionCount
Definition: protocol_tester.hh:194
gem5::ProtocolTester::addrManager
AddressManager * addrManager
Definition: protocol_tester.hh:183
gem5::Named::_name
const std::string _name
Definition: named.hh:41
gem5::ProtocolTester::cuVectorPorts
std::vector< RequestPort * > cuVectorPorts
Definition: protocol_tester.hh:170
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:188
gem5::TokenRequestPort
Definition: token_port.hh:44
gem5::ProtocolTester::wfs
std::vector< GpuWavefront * > wfs
Definition: protocol_tester.hh:178

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