gem5  v21.1.0.2
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  * 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 #ifndef CPU_TESTERS_PROTOCOL_TESTER_PROTOCOL_TESTER_HH_
35 #define CPU_TESTERS_PROTOCOL_TESTER_PROTOCOL_TESTER_HH_
36 
37 /*
38  * The tester includes the main ProtocolTester that manages all ports to the
39  * memory system.
40  * TesterThreads are mapped to certain data port(s)
41  *
42  * TesterThreads inject memory requests through their data ports.
43  * The tester receives and validates responses from the memory.
44  *
45  * Main components
46  * - AddressManager: generate DRF request streams &
47  * validate data response against an internal log_table
48  * - Episode: a sequence of requests
49  * - Thread: either GPU wavefront or CPU thread
50  */
51 
52 #include <iostream>
53 #include <map>
54 #include <string>
55 #include <vector>
56 
57 #include "base/types.hh"
59 #include "mem/packet.hh"
61 #include "mem/token_port.hh"
62 #include "params/ProtocolTester.hh"
63 
64 namespace gem5
65 {
66 
67 class TesterThread;
68 class CpuThread;
69 class GpuWavefront;
70 
72 {
73  public:
74  class SeqPort : public RequestPort
75  {
76  public:
77  SeqPort(const std::string &_name, ProtocolTester *_tester, PortID _id,
78  PortID _index)
79  : RequestPort(_name, _tester, _id)
80  {}
81 
82  protected:
83  virtual bool recvTimingResp(PacketPtr pkt);
84  virtual void recvReqRetry()
85  { panic("%s does not expect a retry\n", name()); }
86  };
87 
89  {
90  public:
91  GMTokenPort(const std::string& name, ProtocolTester *_tester,
92  PortID id = InvalidPortID)
93  : TokenRequestPort(name, _tester, id)
94  {}
96 
97  protected:
98  bool recvTimingResp(PacketPtr) { return false; }
99  void recvReqRetry() {}
100  };
101 
103  {
106  {
107  assert(_th);
108  th = _th;
109  }
110 
112  {}
113  };
114 
115  public:
116  typedef ProtocolTesterParams Params;
117  ProtocolTester(const Params &p);
118  ~ProtocolTester();
119 
122 
123  void init() override;
125  Port& getPort(const std::string &if_name,
126  PortID idx=InvalidPortID) override;
127 
128  int getEpisodeLength() const { return episodeLength; }
129  // return pointer to the address manager
131  // return true if the tester should stop issuing new episodes
132  bool checkExit();
133  // verify if a location to be picked for LD/ST will satisfy
134  // data race free requirement
135  bool checkDRF(Location atomic_loc, Location loc, bool isStore) const;
136  // return the next episode id and increment it
137  int getNextEpisodeID() { return nextEpisodeId++; }
138  // get action sequence number
139  int getActionSeqNum() { return actionCount++; }
140 
141  // dump error log into a file and exit the simulation
142  void dumpErrorLog(std::stringstream& ss);
143 
144  private:
146 
147  // list of parameters taken from python scripts
159  // parameters controlling the address range that the tester can access
162  // the number of actions in an episode (episodeLength +- random number)
164  // the maximum number of episodes to be completed by this tester
166  // are we debuggin the tester
168 
169  // all available requestor ports connected to Ruby
172  std::vector<RequestPort*> cuVectorPorts; // ports to GPU vector cache
173  std::vector<RequestPort*> cuSqcPorts; // ports to GPU inst cache
174  std::vector<RequestPort*> cuScalarPorts; // ports to GPU scalar cache
177  // all CPU, DMA, and GPU threads
181 
182  // address manager that (1) generates DRF sequences of requests,
183  // (2) manages an internal log table and
184  // (3) validate response data
186 
187  // number of CPUs and CUs
188  int numCpus;
189  int numDmas;
190  int numCus;
191  // unique id of the next episode
193 
194  // global action count. Overflow is fine. It's used to uniquely identify
195  // per-wave & per-instruction memory requests in the coalescer
197 
198  // if an exit signal was already sent
200 
202 };
203 
204 } // namespace gem5
205 
206 #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:252
gem5::ProtocolTester::dmaThreads
std::vector< DmaThread * > dmaThreads
Definition: protocol_tester.hh:179
gem5::ProtocolTester::sentExitSignal
bool sentExitSignal
Definition: protocol_tester.hh:199
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:155
gem5::ProtocolTester::nextEpisodeId
int nextEpisodeId
Definition: protocol_tester.hh:192
gem5::ProtocolTester::ProtocolTester
ProtocolTester(const Params &p)
Definition: protocol_tester.cc:53
gem5::ProtocolTester::cuTokenPorts
std::vector< GMTokenPort * > cuTokenPorts
Definition: protocol_tester.hh:176
gem5::ProtocolTester::numAtomicLocs
int numAtomicLocs
Definition: protocol_tester.hh:160
gem5::AddressManager
Definition: address_manager.hh:122
gem5::ProtocolTester::debugTester
bool debugTester
Definition: protocol_tester.hh:167
gem5::ProtocolTester::cuTokenManagers
std::vector< TokenManager * > cuTokenManagers
Definition: protocol_tester.hh:175
gem5::ProtocolTester::numCus
int numCus
Definition: protocol_tester.hh:190
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:95
gem5::ProtocolTester::dmaPorts
std::vector< RequestPort * > dmaPorts
Definition: protocol_tester.hh:171
gem5::ProtocolTester::cpuPorts
std::vector< RequestPort * > cpuPorts
Definition: protocol_tester.hh:170
gem5::ProtocolTester::cuSqcPorts
std::vector< RequestPort * > cuSqcPorts
Definition: protocol_tester.hh:173
gem5::ProtocolTester::numScalarPorts
int numScalarPorts
Definition: protocol_tester.hh:152
gem5::ProtocolTester::numCpuPorts
int numCpuPorts
Definition: protocol_tester.hh:148
gem5::ProtocolTester::numCusPerSqc
int numCusPerSqc
Definition: protocol_tester.hh:154
std::vector
STL vector class.
Definition: stl.hh:37
gem5::ProtocolTester::maxNumEpisodes
int maxNumEpisodes
Definition: protocol_tester.hh:165
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:199
gem5::ProtocolTester::SenderState::~SenderState
~SenderState()
Definition: protocol_tester.hh:111
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:253
gem5::TesterThread
Definition: tester_thread.hh:51
gem5::ProtocolTester::SeqPort
Definition: protocol_tester.hh:74
gem5::ProtocolTester::numDmas
int numDmas
Definition: protocol_tester.hh:189
packet.hh
gem5::RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:77
gem5::ProtocolTester::requestorId
RequestorID requestorId()
Definition: protocol_tester.hh:124
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:244
gem5::ProtocolTester::logFile
OutputStream * logFile
Definition: protocol_tester.hh:201
gem5::ProtocolTester::getEpisodeLength
int getEpisodeLength() const
Definition: protocol_tester.hh:128
gem5::ProtocolTester::cpuThreads
std::vector< CpuThread * > cpuThreads
Definition: protocol_tester.hh:178
gem5::ProtocolTester::numTokenPorts
int numTokenPorts
Definition: protocol_tester.hh:153
gem5::ProtocolTester::SenderState
Definition: protocol_tester.hh:102
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
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:99
gem5::ProtocolTester::numSqcPorts
int numSqcPorts
Definition: protocol_tester.hh:151
gem5::ProtocolTester
Definition: protocol_tester.hh:71
gem5::ProtocolTester::cuScalarPorts
std::vector< RequestPort * > cuScalarPorts
Definition: protocol_tester.hh:174
gem5::ProtocolTester::numDmaPorts
int numDmaPorts
Definition: protocol_tester.hh:149
gem5::ProtocolTester::numWisPerWf
int numWisPerWf
Definition: protocol_tester.hh:157
gem5::ProtocolTester::SenderState::th
TesterThread * th
Definition: protocol_tester.hh:104
gem5::ProtocolTester::getActionSeqNum
int getActionSeqNum()
Definition: protocol_tester.hh:139
gem5::ProtocolTester::checkExit
bool checkExit()
Definition: protocol_tester.cc:284
gem5::ProtocolTester::numCuTokens
int numCuTokens
Definition: protocol_tester.hh:158
ss
std::stringstream ss
Definition: trace.test.cc:45
gem5::AddressManager::Location
int32_t Location
Definition: address_manager.hh:129
gem5::ProtocolTester::GMTokenPort::GMTokenPort
GMTokenPort(const std::string &name, ProtocolTester *_tester, PortID id=InvalidPortID)
Definition: protocol_tester.hh:91
gem5::ProtocolTester::dumpErrorLog
void dumpErrorLog(std::stringstream &ss)
Definition: protocol_tester.cc:324
gem5::Packet::SenderState
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition: packet.hh:457
gem5::ProtocolTester::checkDRF
bool checkDRF(Location atomic_loc, Location loc, bool isStore) const
Definition: protocol_tester.cc:299
gem5::ProtocolTester::numWfsPerCu
int numWfsPerCu
Definition: protocol_tester.hh:156
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:161
gem5::AddressManager::Value
int32_t Value
Definition: address_manager.hh:128
gem5::ProtocolTester::GMTokenPort
Definition: protocol_tester.hh:88
gem5::ProtocolTester::Params
ProtocolTesterParams Params
Definition: protocol_tester.hh:116
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:84
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:105
address_manager.hh
token_port.hh
gem5::ProtocolTester::getNextEpisodeID
int getNextEpisodeID()
Definition: protocol_tester.hh:137
gem5::ProtocolTester::numVectorPorts
int numVectorPorts
Definition: protocol_tester.hh:150
gem5::ProtocolTester::SeqPort::recvTimingResp
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: protocol_tester.cc:352
gem5::ProtocolTester::Location
AddressManager::Location Location
Definition: protocol_tester.hh:120
gem5::ProtocolTester::getAddressManager
AddressManager * getAddressManager() const
Definition: protocol_tester.hh:130
gem5::RequestorID
uint16_t RequestorID
Definition: request.hh:95
gem5::ProtocolTester::numCpus
int numCpus
Definition: protocol_tester.hh:188
gem5::ProtocolTester::GMTokenPort::recvTimingResp
bool recvTimingResp(PacketPtr)
Receive a timing response from the peer.
Definition: protocol_tester.hh:98
gem5::ProtocolTester::episodeLength
int episodeLength
Definition: protocol_tester.hh:163
gem5::ProtocolTester::~ProtocolTester
~ProtocolTester()
Definition: protocol_tester.cc:180
gem5::ProtocolTester::Value
AddressManager::Value Value
Definition: protocol_tester.hh:121
gem5::ProtocolTester::SeqPort::SeqPort
SeqPort(const std::string &_name, ProtocolTester *_tester, PortID _id, PortID _index)
Definition: protocol_tester.hh:77
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
RubyPort.hh
gem5::OutputStream
Definition: output.hh:56
gem5::ProtocolTester::_requestorId
RequestorID _requestorId
Definition: protocol_tester.hh:145
gem5::ProtocolTester::actionCount
int actionCount
Definition: protocol_tester.hh:196
gem5::ProtocolTester::addrManager
AddressManager * addrManager
Definition: protocol_tester.hh:185
gem5::Named::_name
const std::string _name
Definition: named.hh:41
gem5::ProtocolTester::cuVectorPorts
std::vector< RequestPort * > cuVectorPorts
Definition: protocol_tester.hh:172
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177
gem5::TokenRequestPort
Definition: token_port.hh:46
gem5::ProtocolTester::wfs
std::vector< GpuWavefront * > wfs
Definition: protocol_tester.hh:180

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