gem5 v24.0.0.0
Loading...
Searching...
No Matches
register_file.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015-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
33
34#include <sstream>
35#include <string>
36
37#include "base/intmath.hh"
38#include "base/logging.hh"
39#include "debug/GPURF.hh"
42#include "gpu-compute/shader.hh"
44#include "params/RegisterFile.hh"
45
46namespace gem5
47{
48
49RegisterFile::RegisterFile(const RegisterFileParams &p)
50 : SimObject(p), simdId(p.simd_id), _numRegs(p.num_regs), stats(this)
51{
52 fatal_if((_numRegs % 2) != 0, "VRF size is illegal\n");
53 fatal_if(simdId < 0, "Illegal SIMD id for VRF");
54
55 busy.clear();
56 busy.resize(_numRegs, 0);
57}
58
62
63void
65{
66 computeUnit = _computeUnit;
67}
68
69std::string
71{
72 std::stringstream ss;
73 ss << "Busy: ";
74 for (int i = 0; i < busy.size(); i++) {
75 ss << (int)busy[i];
76 }
77 ss << "\n";
78 return ss.str();
79}
80
81// Scoreboard functions
82
83bool
85{
86 return true;
87}
88
89bool
91{
92 return busy.at(idx);
93}
94
95void
96RegisterFile::markReg(int regIdx, bool value)
97{
98 DPRINTF(GPURF, "SIMD[%d] markReg(): physReg[%d] = %d\n",
99 simdId, regIdx, (int)value);
100 busy.at(regIdx) = value;
101}
102
103void
104RegisterFile::enqRegFreeEvent(uint32_t regIdx, uint64_t delay)
105{
106 DPRINTF(GPURF, "SIMD[%d] enqRegFreeEvent physReg[%d] at %llu\n",
107 simdId, regIdx, curTick() + delay);
108 schedule(new MarkRegFreeScbEvent(this, regIdx),
109 curTick() + delay);
110}
111
112void
113RegisterFile::enqRegBusyEvent(uint32_t regIdx, uint64_t delay)
114{
115 DPRINTF(GPURF, "SIMD[%d] enqRegBusyEvent physReg[%d] at %llu\n",
116 simdId, regIdx, curTick() + delay);
117 schedule(new MarkRegBusyScbEvent(this, regIdx),
118 curTick() + delay);
119}
120
121// Schedule functions
122bool
127
128void
132
133bool
138
139void
143
144bool
149
150void
154
155bool
160
161// Exec functions
162void
166
167void
171
172// Events
173
174// Mark a register as free in the scoreboard/busy vector
175void
180
181// Mark a register as busy in the scoreboard/busy vector
182void
184{
185 rf->markReg(regIdx, true);
186}
187
188void
192
194 : statistics::Group(parent),
195 ADD_STAT(registerReads,
196 "Total number of DWORDs read from register file"),
197 ADD_STAT(rfc_cache_read_hits,
198 "Total number of DWORDs read from register file cache"),
199 ADD_STAT(rfc_cache_write_hits,
200 "Total number of writes to existing registers in the rfc"),
201 ADD_STAT(registerWrites,
202 "Total number of DWORDS written to register file"),
203 ADD_STAT(sramReads,
204 "Total number of register file bank SRAM activations for reads"),
205 ADD_STAT(sramWrites,
206 "Total number of register file bank SRAM activations for writes")
207{
208}
209
210} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
virtual bool regBusy(int idx) const
virtual void markReg(int regIdx, bool value)
virtual bool operandsReady(Wavefront *w, GPUDynInstPtr ii) const
std::vector< bool > busy
virtual void scheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii)
virtual bool canScheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii)
virtual void dispatchInstruction(GPUDynInstPtr ii)
virtual bool canScheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii)
virtual void waveExecuteInst(Wavefront *w, GPUDynInstPtr ii)
virtual void enqRegBusyEvent(uint32_t regIdx, uint64_t delay)
RegisterFile(const RegisterFileParams &p)
virtual void exec()
virtual std::string dump() const
virtual void scheduleReadOperands(Wavefront *w, GPUDynInstPtr ii)
virtual void scheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii)
virtual bool operandReadComplete(Wavefront *w, GPUDynInstPtr ii)
virtual void enqRegFreeEvent(uint32_t regIdx, uint64_t delay)
virtual void setParent(ComputeUnit *_computeUnit)
ComputeUnit * computeUnit
virtual bool canScheduleReadOperands(Wavefront *w, GPUDynInstPtr ii)
Abstract superclass for simulation objects.
Statistics container.
Definition group.hh:93
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition group.hh:75
void schedule(Event &event, Tick when)
Definition eventq.hh:1012
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition logging.hh:236
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 21 > ss
Definition misc_types.hh:60
Bitfield< 0 > p
Bitfield< 0 > w
Bitfield< 16 > rf
Definition misc.hh:578
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition misc.hh:49
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
RegisterFileStats(statistics::Group *parent)

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