gem5  v22.1.0.0
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"
43 #include "gpu-compute/wavefront.hh"
44 #include "params/RegisterFile.hh"
45 
46 namespace gem5
47 {
48 
49 RegisterFile::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 
60 {
61 }
62 
63 void
65 {
66  computeUnit = _computeUnit;
67 }
68 
69 std::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 
83 bool
85 {
86  return true;
87 }
88 
89 bool
90 RegisterFile::regBusy(int idx) const
91 {
92  return busy.at(idx);
93 }
94 
95 void
96 RegisterFile::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 
103 void
104 RegisterFile::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 
112 void
113 RegisterFile::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
122 bool
124 {
125  return true;
126 }
127 
128 void
130 {
131 }
132 
133 bool
135 {
136  return true;
137 }
138 
139 void
141 {
142 }
143 
144 bool
146 {
147  return true;
148 }
149 
150 void
152 {
153 }
154 
155 bool
157 {
158  return true;
159 }
160 
161 // Exec functions
162 void
164 {
165 }
166 
167 void
169 {
170 }
171 
172 // Events
173 
174 // Mark a register as free in the scoreboard/busy vector
175 void
177 {
178  rf->markReg(regIdx, false);
179 }
180 
181 // Mark a register as busy in the scoreboard/busy vector
182 void
184 {
185  rf->markReg(regIdx, true);
186 }
187 
188 void
190 {
191 }
192 
194  : statistics::Group(parent),
195  ADD_STAT(registerReads,
196  "Total number of DWORDs read from register file"),
197  ADD_STAT(registerWrites,
198  "Total number of DWORDS written to register file"),
199  ADD_STAT(sramReads,
200  "Total number of register file bank SRAM activations for reads"),
201  ADD_STAT(sramWrites,
202  "Total number of register file bank SRAM activations for writes")
203 {
204 }
205 
206 } // namespace gem5
#define DPRINTF(x,...)
Definition: trace.hh:186
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 ~RegisterFile()
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.
Definition: sim_object.hh:148
Statistics container.
Definition: group.hh:94
#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:1019
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:226
Bitfield< 7 > i
Definition: misc_types.hh:67
Bitfield< 6 > w
Definition: pagetable.hh:59
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 16 > rf
Definition: misc.hh:568
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:49
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
RegisterFileStats(statistics::Group *parent)
std::stringstream ss
Definition: trace.test.cc:45

Generated on Wed Dec 21 2022 10:22:35 for gem5 by doxygen 1.9.1