35#include "debug/GUPSGen.hh"
44 nextSendEvent([
this]{ sendNextReq(); },
name()),
46 requestorId(
system->getRequestorId(
this)),
47 port(
name() +
".port",
this),
48 startAddr(params.start_addr),
49 memSize(params.mem_size),
50 updateLimit(params.update_limit),
51 elementSize(
sizeof(uint64_t)),
52 reqQueueSize(params.request_queue_size),
53 initMemory(params.init_memory),
60 if (if_name !=
"port") {
84 for (uint64_t start_index = 0; start_index <
tableSize;
85 start_index += stride_size) {
86 uint8_t write_data[block_size];
88 uint64_t value = start_index +
offset;
146 DPRINTF(
GUPSGen,
"%s: received a write resp. pkt->addr_range: %s,"
147 " pkt->data: %d\n", __func__,
149 *pkt->
getPtr<uint64_t>());
158 DPRINTF(
GUPSGen,
"%s: received a read resp. pkt->addr_range: %s\n",
199 uint64_t *updated_value = pkt->
getPtr<uint64_t>();
253 "%s, pkt->data: %lu.\n", __func__,
255 *pkt->
getPtr<uint64_t>());
309 assert(_blocked && (blockedPacket !=
nullptr));
312 sendTimingPacket(blockedPacket);
314 blockedPacket =
nullptr;
323 owner->handleResponse(pkt);
328 statistics::
Group(parent),
329 ADD_STAT(totalUpdates, statistics::units::Count::get(),
330 "Total number of updates the generator made in the memory"),
331 ADD_STAT(GUPS, statistics::units::Rate<statistics::units::Count,
332 statistics::units::Second>::get(),
333 "Rate of billion updates per second"),
334 ADD_STAT(totalReads, statistics::units::Count::get(),
335 "Total number of read requests"),
336 ADD_STAT(totalBytesRead, statistics::units::Byte::get(),
337 "Total number of bytes read"),
338 ADD_STAT(avgReadBW, statistics::units::Rate<statistics::units::Byte,
339 statistics::units::Second>::get(),
340 "Average read bandwidth received from memory"),
342 "Total latency of read requests."),
344 "Average latency for read requests"),
345 ADD_STAT(totalWrites, statistics::units::Count::get(),
346 "Total number of write requests"),
347 ADD_STAT(totalBytesWritten, statistics::units::Byte::get(),
348 "Total number of bytes written"),
349 ADD_STAT(avgWriteBW, statistics::units::Rate<statistics::units::Byte,
350 statistics::units::Second>::get(),
351 "Average write bandwidth received from memory"),
353 "Total latency of write requests."),
355 "Average latency for write requests")
362 avgReadBW.precision(2);
363 avgReadLat.precision(2);
364 avgWriteBW.precision(2);
365 avgWriteLat.precision(2);
370 avgReadLat = (totalReadLat) / totalReads;
373 avgWriteLat = (totalWriteLat) / totalWrites;
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
void sendTimingPacket(PacketPtr pkt)
This function send a timing request to the port's peer responsePort.
bool blocked()
Return whether the port is blocked.
PacketPtr blockedPacket
Pointer to the blocked packet in the port.
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
void sendFunctionalPacket(PacketPtr pkt)
This function send a functional request to the port's peer responsePort.
bool _blocked
Boolean value to remember if the port is previously blocked and is occupied by a previous request,...
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
std::queue< PacketPtr > requestPool
A queue to store the outstanding requests whether read or write.
const uint64_t memSize
Size of the memory in bytes that will be allocated for the array.
int64_t tableSize
Number of elements in the allocated array.
void handleResponse(PacketPtr pkt)
Handles the incoming responses from the outside.
GUPSGen(const GUPSGenParams ¶ms)
EventFunctionWrapper nextSendEvent
Corresponding event to the sendNextReq function.
void wakeUp()
This function allows the port to wake its owner GUPSGen object in case it has stopped working due to ...
virtual void startup() override
startup() is the final initialization call before simulation.
gem5::GUPSGen::GUPSGenStat stats
bool doneReading
Boolean to indicate whether the generator is done creating read requests, which means number of reads...
Addr startAddr
The beginning address for allocating the array.
int updateLimit
The number of updates to do before creating an exit event.
void sendNextReq()
Send outstanding requests from requestPool to the port.
std::unordered_map< RequestPtr, Tick > exitTimes
Use an unordered map to track the time at which each request exits the GUPSGen.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
virtual void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
int readRequests
The number of read requests currently created.
GenPort port
An instance of GenPort to communicate with the outside.
const RequestorID requestorId
Used to identify each requestor in a system object.
int reqQueueSize
The maximum number of outstanding requests (i.e.
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...
const int elementSize
size of each element in the array (in bytes).
PacketPtr getReadPacket(Addr addr, unsigned int size)
Generate a read request to be sent to the outside.
Addr indexToAddr(uint64_t index)
Convert and index from array to its physical address in the memory.
void createNextReq()
Create the next request and store in the requestPool.
int onTheFlyRequests
The number of requests that have existed this GUPSGen and have no corresponding response (they are be...
PacketPtr getWritePacket(Addr addr, unsigned int size, uint8_t *data)
Generate a write request to be sent to the outside.
std::queue< PacketPtr > responsePool
A queue to store response packets from reads.
bool initMemory
Boolean value to determine whether we need to initialize the array with the right values,...
EventFunctionWrapper nextCreateEvent
Corresponding event to the createNextReq function.
int64_t numUpdates
The total number of updates (one read and one write) to do for running the benchmark to completion.
virtual std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
AddrRange getAddrRange() const
Get address range to which this packet belongs.
T * getPtr()
get a pointer to the data ptr.
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
RequestPtr req
A pointer to the original request.
void allocate()
Allocate memory for the packet.
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
std::string to_string() const
Get a string representation of the range.
std::enable_if_t< std::is_integral_v< T >, T > random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
bool scheduled() const
Determine if the current event is scheduled.
void schedule(Event &event, Tick when)
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Contatins the description of the class GUPSGen.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::shared_ptr< Request > RequestPtr
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
statistics::Formula & simSeconds
statistics::Scalar totalWriteLat
statistics::Scalar totalUpdates
GUPSGenStat(GUPSGen *parent)
void regStats() override
Callback to set stat parameters.
statistics::Scalar totalReadLat
statistics::Scalar totalReads
statistics::Scalar totalBytesRead
statistics::Scalar totalWrites
statistics::Scalar totalBytesWritten
const std::string & name()