gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * For use for simulation and test purposes only
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
35 
36 #include <sstream>
37 #include <string>
38 
39 #include "base/intmath.hh"
40 #include "base/logging.hh"
41 #include "debug/GPURF.hh"
44 #include "gpu-compute/shader.hh"
45 #include "gpu-compute/wavefront.hh"
46 #include "params/RegisterFile.hh"
47 
48 RegisterFile::RegisterFile(const RegisterFileParams &p)
49  : SimObject(p), simdId(p.simd_id), _numRegs(p.num_regs), stats(this)
50 {
51  fatal_if((_numRegs % 2) != 0, "VRF size is illegal\n");
52  fatal_if(simdId < 0, "Illegal SIMD id for VRF");
53 
54  busy.clear();
55  busy.resize(_numRegs, 0);
56 }
57 
59 {
60 }
61 
62 void
64 {
65  computeUnit = _computeUnit;
66 }
67 
68 std::string
70 {
71  std::stringstream ss;
72  ss << "Busy: ";
73  for (int i = 0; i < busy.size(); i++) {
74  ss << (int)busy[i];
75  }
76  ss << "\n";
77  return ss.str();
78 }
79 
80 // Scoreboard functions
81 
82 bool
84 {
85  return true;
86 }
87 
88 bool
89 RegisterFile::regBusy(int idx) const
90 {
91  return busy.at(idx);
92 }
93 
94 void
95 RegisterFile::markReg(int regIdx, bool value)
96 {
97  DPRINTF(GPURF, "SIMD[%d] markReg(): physReg[%d] = %d\n",
98  simdId, regIdx, (int)value);
99  busy.at(regIdx) = value;
100 }
101 
102 void
103 RegisterFile::enqRegFreeEvent(uint32_t regIdx, uint64_t delay)
104 {
105  DPRINTF(GPURF, "SIMD[%d] enqRegFreeEvent physReg[%d] at %llu\n",
106  simdId, regIdx, curTick() + delay);
107  schedule(new MarkRegFreeScbEvent(this, regIdx),
108  curTick() + delay);
109 }
110 
111 void
112 RegisterFile::enqRegBusyEvent(uint32_t regIdx, uint64_t delay)
113 {
114  DPRINTF(GPURF, "SIMD[%d] enqRegBusyEvent physReg[%d] at %llu\n",
115  simdId, regIdx, curTick() + delay);
116  schedule(new MarkRegBusyScbEvent(this, regIdx),
117  curTick() + delay);
118 }
119 
120 // Schedule functions
121 bool
123 {
124  return true;
125 }
126 
127 void
129 {
130 }
131 
132 bool
134 {
135  return true;
136 }
137 
138 void
140 {
141 }
142 
143 bool
145 {
146  return true;
147 }
148 
149 void
151 {
152 }
153 
154 bool
156 {
157  return true;
158 }
159 
160 // Exec functions
161 void
163 {
164 }
165 
166 void
168 {
169 }
170 
171 // Events
172 
173 // Mark a register as free in the scoreboard/busy vector
174 void
176 {
177  rf->markReg(regIdx, false);
178 }
179 
180 // Mark a register as busy in the scoreboard/busy vector
181 void
183 {
184  rf->markReg(regIdx, true);
185 }
186 
187 void
189 {
190 }
191 
193  : Stats::Group(parent),
194  ADD_STAT(registerReads,
195  "Total number of DWORDs read from register file"),
196  ADD_STAT(registerWrites,
197  "Total number of DWORDS written to register file"),
198  ADD_STAT(sramReads,
199  "Total number of register file bank SRAM activations for reads"),
200  ADD_STAT(sramWrites,
201  "Total number of register file bank SRAM activations for writes")
202 {
203 }
RegisterFile::operandReadComplete
virtual bool operandReadComplete(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:155
RegisterFile::enqRegBusyEvent
virtual void enqRegBusyEvent(uint32_t regIdx, uint64_t delay)
Definition: register_file.cc:112
shader.hh
RegisterFile::waveExecuteInst
virtual void waveExecuteInst(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:167
RegisterFile::RegisterEvent::rf
RegisterFile * rf
Definition: register_file.hh:74
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
RegisterFile::MarkRegBusyScbEvent
Definition: register_file.hh:92
compute_unit.hh
RegisterFile::busy
std::vector< bool > busy
Definition: register_file.hh:149
Stats::Group::Group
Group()=delete
RegisterFile::MarkRegBusyScbEvent::process
void process()
Definition: register_file.cc:182
RegisterFile::MarkRegFreeScbEvent
Definition: register_file.hh:83
RegisterFile::scheduleReadOperands
virtual void scheduleReadOperands(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:128
RegisterFile::operandsReady
virtual bool operandsReady(Wavefront *w, GPUDynInstPtr ii) const
Definition: register_file.cc:83
wavefront.hh
ComputeUnit
Definition: compute_unit.hh:200
RegisterFile::scheduleWriteOperands
virtual void scheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:139
EventManager::schedule
void schedule(Event &event, Tick when)
Definition: eventq.hh:1016
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
register_file.hh
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:237
ADD_STAT
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition: group.hh:71
RegisterFile::dump
virtual std::string dump() const
Definition: register_file.cc:69
RegisterFile::regBusy
virtual bool regBusy(int idx) const
Definition: register_file.cc:89
RegisterFile::~RegisterFile
virtual ~RegisterFile()
Definition: register_file.cc:58
gpu_dyn_inst.hh
X86ISA::rf
Bitfield< 16 > rf
Definition: misc.hh:563
RegisterFile::canScheduleWriteOperandsFromLoad
virtual bool canScheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:144
RegisterFile::simdId
int simdId
Definition: register_file.hh:146
RegisterFile::_numRegs
int _numRegs
Definition: register_file.hh:152
RegisterFile::scheduleWriteOperandsFromLoad
virtual void scheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:150
RegisterFile::canScheduleReadOperands
virtual bool canScheduleReadOperands(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:122
RegisterFile::markReg
virtual void markReg(int regIdx, bool value)
Definition: register_file.cc:95
Wavefront
Definition: wavefront.hh:59
RegisterFile::enqRegFreeEvent
virtual void enqRegFreeEvent(uint32_t regIdx, uint64_t delay)
Definition: register_file.cc:103
Stats::Group
Statistics container.
Definition: group.hh:87
GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:48
logging.hh
RegisterFile::RegisterFile
RegisterFile(const RegisterFileParams &p)
Definition: register_file.cc:48
RegisterFile::canScheduleWriteOperands
virtual bool canScheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:133
Stats
Definition: statistics.cc:53
curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:43
RegisterFile::RegisterFileStats::RegisterFileStats
RegisterFileStats(Stats::Group *parent)
Definition: register_file.cc:192
RegisterFile::RegisterEvent::regIdx
int regIdx
Definition: register_file.hh:75
RegisterFile::computeUnit
ComputeUnit * computeUnit
Definition: register_file.hh:145
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
intmath.hh
fatal_if
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:219
RegisterFile::setParent
virtual void setParent(ComputeUnit *_computeUnit)
Definition: register_file.cc:63
RegisterFile::MarkRegFreeScbEvent::process
void process()
Definition: register_file.cc:175
RegisterFile::dispatchInstruction
virtual void dispatchInstruction(GPUDynInstPtr ii)
Definition: register_file.cc:188
RegisterFile::exec
virtual void exec()
Definition: register_file.cc:162
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:141

Generated on Tue Mar 23 2021 19:41:27 for gem5 by doxygen 1.8.17