gem5  v22.1.0.0
gups_gen.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 The Regents of the University of California.
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
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __CPU_TESTERS_TRAFFIC_GEN_GUPS_GEN_HH__
30 #define __CPU_TESTERS_TRAFFIC_GEN_GUPS_GEN_HH__
31 
40 #include <queue>
41 #include <unordered_map>
42 #include <vector>
43 
44 #include "base/statistics.hh"
45 #include "mem/port.hh"
46 #include "params/GUPSGen.hh"
47 #include "sim/clocked_object.hh"
48 #include "sim/system.hh"
49 
50 namespace gem5
51 {
52 
53 class GUPSGen : public ClockedObject
54 {
55  private:
56 
63  class GenPort : public RequestPort
64  {
65  private:
66 
71 
78  bool _blocked;
79 
86 
87  public:
88 
89  GenPort(const std::string& name, GUPSGen *owner) :
91  blockedPacket(nullptr)
92  {}
93 
100  bool blocked(){
101  return _blocked;
102  }
103 
109  void sendTimingPacket(PacketPtr pkt);
110 
117 
118  protected:
119 
120  bool recvTimingResp(PacketPtr pkt) override;
121 
122  void recvReqRetry() override;
123  };
124 
125  virtual void init() override;
126 
127  virtual void startup() override;
128 
135  Addr indexToAddr (uint64_t index);
136 
145  PacketPtr getReadPacket(Addr addr, unsigned int size);
146 
156  PacketPtr getWritePacket(Addr addr, unsigned int size, uint8_t* data);
157 
162  void handleResponse(PacketPtr pkt);
163 
169  void wakeUp();
170 
174  void createNextReq();
175 
181 
185  void sendNextReq();
186 
192 
199  std::unordered_map<RequestPtr, uint64_t> updateTable;
200 
206  std::unordered_map<RequestPtr, Tick> exitTimes;
207 
213  std::queue<PacketPtr> requestPool;
214 
221  std::queue<PacketPtr> responsePool;
222 
227  int64_t numUpdates;
228 
232  int64_t tableSize;
233 
238  System *const system;
239 
245 
250 
255 
259  const uint64_t memSize;
260 
265 
270  const int elementSize;
271 
277 
284 
291 
298 
303 
305  {
306  GUPSGenStat(GUPSGen* parent);
307  void regStats() override;
308 
311 
317 
323  } stats;
324 
325  public:
326 
327  GUPSGen(const GUPSGenParams &params);
328 
329  Port &getPort(const std::string &if_name,
330  PortID idx=InvalidPortID) override;
331 };
332 
333 }
334 
335 #endif // __CPU_TESTERS_TRAFFIC_GEN_GUPS_GEN_HH__
const char data[]
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
definition of the GenPort class which is of the type RequestPort.
Definition: gups_gen.hh:64
void sendTimingPacket(PacketPtr pkt)
This function send a timing request to the port's peer responsePort.
Definition: gups_gen.cc:283
GenPort(const std::string &name, GUPSGen *owner)
Definition: gups_gen.hh:89
GUPSGen * owner
Pointer to the GUPSGen this port belongs to.
Definition: gups_gen.hh:70
bool blocked()
Return whether the port is blocked.
Definition: gups_gen.hh:100
PacketPtr blockedPacket
Pointer to the blocked packet in the port.
Definition: gups_gen.hh:85
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: gups_gen.cc:304
void sendFunctionalPacket(PacketPtr pkt)
This function send a functional request to the port's peer responsePort.
Definition: gups_gen.cc:298
bool _blocked
Boolean value to remember if the port is previously blocked and is occupied by a previous request,...
Definition: gups_gen.hh:78
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
Definition: gups_gen.cc:321
std::queue< PacketPtr > requestPool
A queue to store the outstanding requests whether read or write.
Definition: gups_gen.hh:213
const uint64_t memSize
Size of the memory in bytes that will be allocated for the array.
Definition: gups_gen.hh:259
int64_t tableSize
Number of elements in the allocated array.
Definition: gups_gen.hh:232
void handleResponse(PacketPtr pkt)
Handles the incoming responses from the outside.
Definition: gups_gen.cc:140
GUPSGen(const GUPSGenParams &params)
Definition: gups_gen.cc:41
EventFunctionWrapper nextSendEvent
Corresponding event to the sendNextReq function.
Definition: gups_gen.hh:191
void wakeUp()
This function allows the port to wake its owner GUPSGen object in case it has stopped working due to ...
Definition: gups_gen.cc:183
virtual void startup() override
startup() is the final initialization call before simulation.
Definition: gups_gen.cc:79
gem5::GUPSGen::GUPSGenStat stats
System *const system
Pointer to the system object this GUPSGen belongs to, the system object is used to acquire a requesto...
Definition: gups_gen.hh:238
bool doneReading
Boolean to indicate whether the generator is done creating read requests, which means number of reads...
Definition: gups_gen.hh:290
Addr startAddr
The beginning address for allocating the array.
Definition: gups_gen.hh:254
int updateLimit
The number of updates to do before creating an exit event.
Definition: gups_gen.hh:264
void sendNextReq()
Send outstanding requests from requestPool to the port.
Definition: gups_gen.cc:245
std::unordered_map< RequestPtr, Tick > exitTimes
Use an unordered map to track the time at which each request exits the GUPSGen.
Definition: gups_gen.hh:206
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: gups_gen.cc:58
virtual void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: gups_gen.cc:68
int readRequests
The number of read requests currently created.
Definition: gups_gen.hh:302
GenPort port
An instance of GenPort to communicate with the outside.
Definition: gups_gen.hh:249
const RequestorID requestorId
Used to identify each requestor in a system object.
Definition: gups_gen.hh:244
int reqQueueSize
The maximum number of outstanding requests (i.e.
Definition: gups_gen.hh:276
std::unordered_map< RequestPtr, uint64_t > updateTable
Use an unordered map to store future updates on current reads as the updated value depends on the ind...
Definition: gups_gen.hh:199
const int elementSize
size of each element in the array (in bytes).
Definition: gups_gen.hh:270
PacketPtr getReadPacket(Addr addr, unsigned int size)
Generate a read request to be sent to the outside.
Definition: gups_gen.cc:109
Addr indexToAddr(uint64_t index)
Convert and index from array to its physical address in the memory.
Definition: gups_gen.cc:102
void createNextReq()
Create the next request and store in the requestPool.
Definition: gups_gen.cc:191
int onTheFlyRequests
The number of requests that have existed this GUPSGen and have no corresponding response (they are be...
Definition: gups_gen.hh:297
PacketPtr getWritePacket(Addr addr, unsigned int size, uint8_t *data)
Generate a write request to be sent to the outside.
Definition: gups_gen.cc:124
std::queue< PacketPtr > responsePool
A queue to store response packets from reads.
Definition: gups_gen.hh:221
bool initMemory
Boolean value to determine whether we need to initialize the array with the right values,...
Definition: gups_gen.hh:283
EventFunctionWrapper nextCreateEvent
Corresponding event to the createNextReq function.
Definition: gups_gen.hh:180
int64_t numUpdates
The total number of updates (one read and one write) to do for running the benchmark to completion.
Definition: gups_gen.hh:227
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 std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:79
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2540
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
ClockedObject declaration and implementation.
const Params & params() const
Definition: sim_object.hh:176
Port Object Declaration.
Bitfield< 30, 0 > index
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
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 Statistics objects.
statistics::Formula avgWriteBW
Definition: gups_gen.hh:320
statistics::Scalar totalWriteLat
Definition: gups_gen.hh:321
statistics::Scalar totalUpdates
Definition: gups_gen.hh:309
GUPSGenStat(GUPSGen *parent)
Definition: gups_gen.cc:327
void regStats() override
Callback to set stat parameters.
Definition: gups_gen.cc:359
statistics::Scalar totalReadLat
Definition: gups_gen.hh:315
statistics::Scalar totalReads
Definition: gups_gen.hh:312
statistics::Scalar totalBytesRead
Definition: gups_gen.hh:313
statistics::Formula avgReadBW
Definition: gups_gen.hh:314
statistics::Formula GUPS
Definition: gups_gen.hh:310
statistics::Scalar totalWrites
Definition: gups_gen.hh:318
statistics::Scalar totalBytesWritten
Definition: gups_gen.hh:319
statistics::Formula avgReadLat
Definition: gups_gen.hh:316
statistics::Formula avgWriteLat
Definition: gups_gen.hh:322

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