gem5 v24.0.0.0
Loading...
Searching...
No Matches
fetch_unit.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014-2017 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 __FETCH_UNIT_HH__
33#define __FETCH_UNIT_HH__
34
35#include <cassert>
36#include <cstdint>
37#include <deque>
38#include <map>
39#include <utility>
40#include <vector>
41
42#include "arch/gpu_decoder.hh"
43#include "base/types.hh"
44#include "config/the_gpu_isa.hh"
46#include "mem/packet.hh"
47#include "sim/eventq.hh"
48
49namespace gem5
50{
51
52class ComputeUnit;
53class Wavefront;
54
56{
57 public:
58 FetchUnit(const ComputeUnitParams &p, ComputeUnit &cu);
59 ~FetchUnit();
60 void init();
61 void exec();
63 void initiateFetch(Wavefront *wavefront);
64 void fetch(PacketPtr pkt, Wavefront *wavefront);
66 void flushBuf(int wfSlotId);
67 static uint32_t globalFetchUnitID;
68
69 private:
75 {
76 public:
77 FetchBufDesc() : bufStart(nullptr), bufEnd(nullptr),
78 readPtr(nullptr), fetchDepth(0), maxIbSize(0), maxFbSize(0),
79 cacheLineSize(0), restartFromBranch(false), wavefront(nullptr),
80 _decoder(nullptr)
81 {
82 }
83
85 {
86 delete[] bufStart;
87 }
88
94 void allocateBuf(int fetch_depth, int cache_line_size, Wavefront *wf);
95
96 int
98 {
99 return bufferedLines() + reservedLines();
100 }
101
102 int bufferedLines() const { return bufferedPCs.size(); }
103 int bufferedBytes() const { return bufferedLines() * cacheLineSize; }
104 int reservedLines() const { return reservedPCs.size(); }
105 bool hasFreeSpace() const { return !freeList.empty(); }
106 void flushBuf();
108
112 void reserveBuf(Addr vaddr);
113
119 uint8_t*
121 {
122 auto reserved_pc = reservedPCs.find(vaddr);
123 assert(reserved_pc != reservedPCs.end());
124 assert(reserved_pc == reservedPCs.begin());
125
126 return reserved_pc->second;
127 }
128
133 bool
135 {
136 auto reserved_pc = reservedPCs.find(vaddr);
137 bool is_reserved = (reserved_pc != reservedPCs.end());
138 return is_reserved;
139 }
140
141 void fetchDone(PacketPtr ptr);
142
148 bool hasFetchDataToProcess() const;
149
158 void decodeInsts();
159
165 void checkWaveReleaseBuf();
166
167 void
168 decoder(TheGpuISA::Decoder *dec)
169 {
170 _decoder = dec;
171 }
172
173 bool
175 {
176 bool buffered = bufferedPCs.find(pc) != bufferedPCs.end()
177 && reservedPCs.find(pc) != reservedPCs.end();
178
179 return buffered;
180 }
181
186 int fetchBytesRemaining() const;
187
188 private:
189 void decodeSplitInst();
190
196 bool splitDecode() const;
197
204 std::map<Addr, uint8_t*> bufferedPCs;
205 std::map<Addr, uint8_t*> reservedPCs;
206
216
221 uint8_t *bufStart;
222 uint8_t *bufEnd;
227 uint8_t *readPtr;
228 // how many lines the fetch unit may buffer
230 // maximum size (in number of insts) of the WF's IB
232 // maximum size (in bytes) of this fetch buffer
237 // wavefront whose IB is serviced by this fetch buffer
239 TheGpuISA::Decoder *_decoder;
240 };
241
242 class SystemHubEvent : public Event
243 {
246
247 public:
249 : fetchUnit(fetch_unit), reqPkt(pkt)
250 {
252 }
253
254 void process();
255 };
256
259 TheGpuISA::Decoder decoder;
260
261 // Fetch scheduler; Selects one wave from
262 // the fetch queue for instruction fetching.
263 // The selection is made according to
264 // a scheduling policy
266
267 // Stores the list of waves that are
268 // ready to be fetched this cycle
270
271 // Stores the fetch status of all waves dispatched to this SIMD.
272 // TRUE implies the wave is ready to fetch and is already
273 // moved to fetchQueue
275
276 // Pointer to list of waves dispatched on to this SIMD unit
278 // holds the fetch buffers. each wave has 1 entry.
287};
288
289} // namespace gem5
290
291#endif // __FETCH_UNIT_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
static const FlagsType AutoDelete
Definition eventq.hh:110
void setFlags(Flags _flags)
Definition eventq.hh:331
fetch buffer descriptor.
Definition fetch_unit.hh:75
std::map< Addr, uint8_t * > reservedPCs
void reserveBuf(Addr vaddr)
reserve an entry in the fetch buffer for PC = vaddr,
void decoder(TheGpuISA::Decoder *dec)
uint8_t * readPtr
pointer that points to the next chunk of inst data to be decoded.
int fetchBytesRemaining() const
calculates the number of fetched bytes that have yet to be decoded.
void checkWaveReleaseBuf()
checks if the wavefront can release any of its fetch buffer entries.
bool hasFetchDataToProcess() const
checks if the buffer contains valid data.
std::map< Addr, uint8_t * > bufferedPCs
the set of PCs (fetch addresses) that are currently buffered.
bool isReserved(Addr vaddr) const
returns true if there is an entry reserved for this address, and false otherwise
void allocateBuf(int fetch_depth, int cache_line_size, Wavefront *wf)
allocate the fetch buffer space, and set the fetch depth (number of lines that may be buffered),...
void fetchDone(PacketPtr ptr)
uint8_t * reservedBuf(Addr vaddr) const
return a pointer to the raw fetch buffer data.
bool pcBuffered(Addr pc) const
bool splitDecode() const
check if the next instruction to be processed out of the fetch buffer is split across the end/beginni...
void decodeInsts()
each time the fetch stage is ticked, we check if there are any data in the fetch buffer that may be d...
uint8_t * bufStart
raw instruction buffer.
TheGpuISA::Decoder * _decoder
std::deque< uint8_t * > freeList
represents the fetch buffer free list.
SystemHubEvent(PacketPtr pkt, FetchUnit *fetch_unit)
static uint32_t globalFetchUnitID
Definition fetch_unit.hh:67
Scheduler fetchScheduler
std::vector< Wavefront * > * waveList
void bindWaveList(std::vector< Wavefront * > *list)
FetchUnit(const ComputeUnitParams &p, ComputeUnit &cu)
Definition fetch_unit.cc:52
void fetch(PacketPtr pkt, Wavefront *wavefront)
std::vector< Wavefront * > fetchQueue
void initiateFetch(Wavefront *wavefront)
int fetchDepth
number of cache lines we can fetch and buffer.
TheGpuISA::Decoder decoder
ComputeUnit & computeUnit
void processFetchReturn(PacketPtr pkt)
std::vector< FetchBufDesc > fetchBuf
void flushBuf(int wfSlotId)
std::vector< std::pair< Wavefront *, bool > > fetchStatusQueue
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
STL deque class.
Definition stl.hh:44
STL vector class.
Definition stl.hh:37
Bitfield< 4 > pc
Bitfield< 0 > p
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
Declaration of the Packet class.

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