gem5 v24.0.0.0
Loading...
Searching...
No Matches
spatter_gen.hh
Go to the documentation of this file.
1/*
2* Copyright (c) 2024 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_SPATTER_GEN_SPATTER_GEN_HH__
30#define __CPU_TESTERS_SPATTER_GEN_SPATTER_GEN_HH__
31
32#include <queue>
33#include <unordered_map>
34#include <vector>
35
36#include "base/statistics.hh"
37#include "base/stats/group.hh"
39#include "enums/SpatterKernelType.hh"
40#include "enums/SpatterProcessingMode.hh"
41#include "mem/packet.hh"
42#include "mem/port.hh"
43#include "params/SpatterGen.hh"
44#include "sim/clocked_object.hh"
45#include "sim/eventq.hh"
46
47namespace gem5
48{
49
50
79{
80 private:
81 typedef enums::SpatterKernelType SpatterKernelType;
82 typedef enums::SpatterProcessingMode SpatterProcessingMode;
83
85 {
86 private:
87 // TODO: split pending into pendingInput and pendingOutput
88 enum class SleepState
89 {
90 AWAKE,
91 ASLEEP
92 };
93
95
96 public:
97 SpatterGenEvent(const std::function<void(void)> &callback,
98 const std::string &name):
100 {}
101 // a SpatterGenEvent will only be asleep if it is pending output
102 bool pending() const { return _state == SleepState::ASLEEP; }
105 };
106
108 {
109 private:
112
113 public:
114 SpatterGenPort(SpatterGen* owner, const std::string& name):
116
117 void sendPacket(PacketPtr pkt);
118 bool blocked() const { return blockedPacket != nullptr; }
119
120 protected:
121 virtual bool recvTimingResp(PacketPtr pkt) override;
122 virtual void recvReqRetry() override;
123 };
124
126 {
128
129 // TODO: When we enable multiple levels of indirection, we should
130 // convert this to a vector with one stat for each level of index
132 // TODO: When we enable multiple levels of indirection, we should
133 // convert this to a vector with one stat for each level of index
136
143
144 // TODO: When we enable multiple levels of indirection, we should
145 // convert this to a vector with one stat for each level of index
149
150 virtual void regStats() override;
151
152 SpatterGenStats(SpatterGen* spatter_gen);
153 };
154
156 {
157 // waiting for all other cores to get to WAITING state, no accesses
158 WAITING,
159 // only creating intermediate and ultimate accesses, i.e. wrapping up
160 DRAINING,
161 // creating all kinds of accesses, initial, intermediate, and ultimate
162 RUNNING
163 };
164
165 // non param related members
167 std::queue<SpatterKernel> kernels;
168 std::unordered_map<RequestPtr, Tick> requestDepartureTime;
169
172
174
175 void checkForSimExit();
176
177 bool initAccessOk(int int_regs, int fp_regs, Tick when) const;
178 bool interAccessOk(int int_regs, int fp_regs, Tick when) const;
179 bool ultAccessOk(int int_regs, int fp_regs, Tick when) const;
180
181 // param related members (not necessarily one-to-one with params)
184 // size of the register files,
185 // for every memory instruction we need to allocate one register.
190 // laterncy to generate A request
192 // number of requests generated per event
194 // tracking smallest tick when at least one "AGU" is available;
196 // tracking the busy state of our so called "AGU"s.
199 void processNextGenEvent();
200 // put requests to the cache in the request buffer.
202 // store request packet along with their insertion time into this queue.
204 // if nextGenEvent has to be schedule at tick when then schedule it.
205 // this function should only be called when nextGenEvent is not pending.
206 void scheduleNextGenEvent(Tick when);
207
208 // bandwidth to issue memory requests to cache,
209 // this is supposed to model the number of cache ports
210 // we will assume it takes 1 cycle to issue memory requests
216 // if nextSendEvent has to be schedule at tick when then schedule it.
217 // this function should only be called when nextSendEvent is not pending.
218 void scheduleNextSendEvent(Tick when);
219
220 // put the memory responses here.
221 // no need to limit the size of this buffer.
222 // it's a response buffer and it will automatically
223 // be limited by requestBufferEntries, intRegFileSize, fpRegFileSize
225
226 public:
228 SpatterGen(const Params& params);
229
230 Port&
231 getPort(const std::string& if_name, PortID idx = InvalidPortID) override;
232
233 virtual void startup() override;
234
235 void recvReqRetry();
236 bool recvTimingResp(PacketPtr pkt);
237
238 // PyBindMethod to interface adding a kernel with python JSON frontend.
239 void addKernel(
240 uint32_t id, uint32_t delta, uint32_t count,
242 size_t index_size, Addr base_index_addr,
243 size_t value_size, Addr base_value_addr,
244 const std::vector<uint32_t>& indices
245 );
246
248};
249
250} // namespace gem5
251
252#endif // __CPU_TESTERS_SPATTER_GEN_SPATTER_GEN_HH__
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
ClockedObjectParams Params
Parameters of ClockedObject.
std::function< void(void)> callback
Definition eventq.hh:1139
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
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
SpatterGenEvent(const std::function< void(void)> &callback, const std::string &name)
virtual void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
void sendPacket(PacketPtr pkt)
virtual bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
SpatterGenPort(SpatterGen *owner, const std::string &name)
Spatter Kernel Player.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
bool initAccessOk(int int_regs, int fp_regs, Tick when) const
bool recvTimingResp(PacketPtr pkt)
TimedQueue< SpatterAccess * > receiveBuffer
void processNextGenEvent()
SpatterProcessingMode mode
std::vector< Tick > portBusyUntil
bool ultAccessOk(int int_regs, int fp_regs, Tick when) const
SpatterGenEvent nextSendEvent
void processNextSendEvent()
SpatterGen(const Params &params)
enums::SpatterKernelType SpatterKernelType
Tick firstGeneratorAvailableTime
virtual void startup() override
startup() is the final initialization call before simulation.
void proceedPastSyncPoint()
SpatterGenPort port
void addKernel(uint32_t id, uint32_t delta, uint32_t count, SpatterKernelType type, size_t index_size, Addr base_index_addr, size_t value_size, Addr base_value_addr, const std::vector< uint32_t > &indices)
RequestorID requestorId
SpatterGenState state
bool interAccessOk(int int_regs, int fp_regs, Tick when) const
SpatterGenEvent nextGenEvent
std::queue< SpatterKernel > kernels
enums::SpatterProcessingMode SpatterProcessingMode
std::unordered_map< RequestPtr, Tick > requestDepartureTime
TimedQueue< PacketPtr > requestBuffer
std::vector< Tick > generatorBusyUntil
void scheduleNextSendEvent(Tick when)
PARAMS(SpatterGen)
void scheduleNextGenEvent(Tick when)
SpatterGenStats stats
Statistics container.
Definition group.hh:93
A simple histogram stat.
This is a simple scalar statistic, like a counter.
STL vector class.
Definition stl.hh:37
ClockedObject declaration and implementation.
const std::string name() const
Definition eventq.hh:1168
const Params & params() const
Port Object Declaration.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria 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
uint64_t Tick
Tick count type.
Definition types.hh:58
uint16_t RequestorID
Definition request.hh:95
Declaration of the Packet class.
Declaration of Statistics objects.
statistics::Scalar totalValueWriteLatency
virtual void regStats() override
Callback to set stat parameters.
statistics::Histogram totalIndirectAccessLatency
statistics::Histogram valueAccessLatency
statistics::Scalar totalValueReadLatency
statistics::Histogram indexAccessLatency
statistics::Scalar valueBytesWritten
statistics::Scalar totalIndexReadLatency
SpatterGenStats(SpatterGen *spatter_gen)

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0