gem5 v24.1.0.1
Loading...
Searching...
No Matches
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/random.hh"
45#include "base/statistics.hh"
46#include "mem/port.hh"
47#include "params/GUPSGen.hh"
48#include "sim/clocked_object.hh"
49#include "sim/system.hh"
50
51namespace gem5
52{
53
54class GUPSGen : public ClockedObject
55{
56 private:
57
64 class GenPort : public RequestPort
65 {
66 private:
67
72
80
87
88 public:
89
90 GenPort(const std::string& name, GUPSGen *owner) :
92 blockedPacket(nullptr)
93 {}
94
101 bool blocked(){
102 return _blocked;
103 }
104
110 void sendTimingPacket(PacketPtr pkt);
111
118
119 protected:
120
121 bool recvTimingResp(PacketPtr pkt) override;
122
123 void recvReqRetry() override;
124 };
125
126 virtual void init() override;
127
128 virtual void startup() override;
129
136 Addr indexToAddr (uint64_t index);
137
146 PacketPtr getReadPacket(Addr addr, unsigned int size);
147
157 PacketPtr getWritePacket(Addr addr, unsigned int size, uint8_t* data);
158
163 void handleResponse(PacketPtr pkt);
164
170 void wakeUp();
171
175 void createNextReq();
176
182
186 void sendNextReq();
187
193
200 std::unordered_map<RequestPtr, uint64_t> updateTable;
201
207 std::unordered_map<RequestPtr, Tick> exitTimes;
208
214 std::queue<PacketPtr> requestPool;
215
222 std::queue<PacketPtr> responsePool;
223
228 int64_t numUpdates;
229
233 int64_t tableSize;
234
240
246
251
256
260 const uint64_t memSize;
261
266
271 const int elementSize;
272
278
285
292
299
304
306
327
328 public:
329
330 GUPSGen(const GUPSGenParams &params);
331
332 Port &getPort(const std::string &if_name,
333 PortID idx=InvalidPortID) override;
334};
335
336}
337
338#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:65
void sendTimingPacket(PacketPtr pkt)
This function send a timing request to the port's peer responsePort.
Definition gups_gen.cc:282
GenPort(const std::string &name, GUPSGen *owner)
Definition gups_gen.hh:90
GUPSGen * owner
Pointer to the GUPSGen this port belongs to.
Definition gups_gen.hh:71
bool blocked()
Return whether the port is blocked.
Definition gups_gen.hh:101
PacketPtr blockedPacket
Pointer to the blocked packet in the port.
Definition gups_gen.hh:86
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:303
void sendFunctionalPacket(PacketPtr pkt)
This function send a functional request to the port's peer responsePort.
Definition gups_gen.cc:297
bool _blocked
Boolean value to remember if the port is previously blocked and is occupied by a previous request,...
Definition gups_gen.hh:79
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
Definition gups_gen.cc:320
std::queue< PacketPtr > requestPool
A queue to store the outstanding requests whether read or write.
Definition gups_gen.hh:214
const uint64_t memSize
Size of the memory in bytes that will be allocated for the array.
Definition gups_gen.hh:260
int64_t tableSize
Number of elements in the allocated array.
Definition gups_gen.hh:233
void handleResponse(PacketPtr pkt)
Handles the incoming responses from the outside.
Definition gups_gen.cc:139
EventFunctionWrapper nextSendEvent
Corresponding event to the sendNextReq function.
Definition gups_gen.hh:192
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:182
virtual void startup() override
startup() is the final initialization call before simulation.
Definition gups_gen.cc:78
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:239
bool doneReading
Boolean to indicate whether the generator is done creating read requests, which means number of reads...
Definition gups_gen.hh:291
Addr startAddr
The beginning address for allocating the array.
Definition gups_gen.hh:255
int updateLimit
The number of updates to do before creating an exit event.
Definition gups_gen.hh:265
void sendNextReq()
Send outstanding requests from requestPool to the port.
Definition gups_gen.cc:244
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:207
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition gups_gen.cc:57
virtual void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition gups_gen.cc:67
int readRequests
The number of read requests currently created.
Definition gups_gen.hh:303
GenPort port
An instance of GenPort to communicate with the outside.
Definition gups_gen.hh:250
const RequestorID requestorId
Used to identify each requestor in a system object.
Definition gups_gen.hh:245
int reqQueueSize
The maximum number of outstanding requests (i.e.
Definition gups_gen.hh:277
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:200
const int elementSize
size of each element in the array (in bytes).
Definition gups_gen.hh:271
PacketPtr getReadPacket(Addr addr, unsigned int size)
Generate a read request to be sent to the outside.
Definition gups_gen.cc:108
Addr indexToAddr(uint64_t index)
Convert and index from array to its physical address in the memory.
Definition gups_gen.cc:101
void createNextReq()
Create the next request and store in the requestPool.
Definition gups_gen.cc:190
int onTheFlyRequests
The number of requests that have existed this GUPSGen and have no corresponding response (they are be...
Definition gups_gen.hh:298
PacketPtr getWritePacket(Addr addr, unsigned int size, uint8_t *data)
Generate a write request to be sent to the outside.
Definition gups_gen.cc:123
std::queue< PacketPtr > responsePool
A queue to store response packets from reads.
Definition gups_gen.hh:222
Random::RandomPtr rng
Definition gups_gen.hh:305
bool initMemory
Boolean value to determine whether we need to initialize the array with the right values,...
Definition gups_gen.hh:284
EventFunctionWrapper nextCreateEvent
Corresponding event to the createNextReq function.
Definition gups_gen.hh:181
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:228
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
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
std::shared_ptr< Random > RandomPtr
Definition random.hh:65
static RandomPtr genRandom()
Definition random.hh:68
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
ClockedObject declaration and implementation.
const Params & params() const
Port Object Declaration.
Bitfield< 30, 0 > index
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
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:323
statistics::Scalar totalWriteLat
Definition gups_gen.hh:324
statistics::Scalar totalUpdates
Definition gups_gen.hh:312
void regStats() override
Callback to set stat parameters.
Definition gups_gen.cc:358
statistics::Scalar totalReadLat
Definition gups_gen.hh:318
statistics::Scalar totalReads
Definition gups_gen.hh:315
statistics::Scalar totalBytesRead
Definition gups_gen.hh:316
statistics::Formula avgReadBW
Definition gups_gen.hh:317
statistics::Formula GUPS
Definition gups_gen.hh:313
statistics::Scalar totalWrites
Definition gups_gen.hh:321
statistics::Scalar totalBytesWritten
Definition gups_gen.hh:322
statistics::Formula avgReadLat
Definition gups_gen.hh:319
statistics::Formula avgWriteLat
Definition gups_gen.hh:325

Generated on Mon Jan 13 2025 04:28:32 for gem5 by doxygen 1.9.8