gem5  v22.1.0.0
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, _tester, _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_ */
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:294
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...
AddressManager * getAddressManager() const
int getEpisodeLength() const
ProtocolTester(const Params &p)
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
RequestorID requestorId()
std::vector< RequestPort * > dmaPorts
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
OutputStream * logFile
AddressManager::Value Value
void dumpErrorLog(std::stringstream &ss)
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:79
STL vector class.
Definition: stl.hh:37
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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:468
std::stringstream ss
Definition: trace.test.cc:45

Generated on Wed Dec 21 2022 10:22:31 for gem5 by doxygen 1.9.1