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

Generated on Tue Mar 23 2021 19:41:25 for gem5 by doxygen 1.8.17