gem5  v21.0.1.0
scalar_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 "base/logging.hh"
37 #include "debug/GPUSRF.hh"
40 #include "gpu-compute/shader.hh"
41 #include "gpu-compute/wavefront.hh"
42 #include "params/ScalarRegisterFile.hh"
43 
44 ScalarRegisterFile::ScalarRegisterFile(const ScalarRegisterFileParams &p)
45  : RegisterFile(p)
46 {
47  regFile.resize(numRegs(), 0);
48 }
49 
50 bool
52 {
53  for (int i = 0; i < ii->getNumOperands(); ++i) {
54  if (ii->isScalarRegister(i) && ii->isSrcOperand(i)) {
55 
56  int sgprIdx = ii->getRegisterIndex(i, ii);
57  int nRegs = ii->getOperandSize(i) <= 4 ? 1 :
58  ii->getOperandSize(i) / 4;
59 
60  for (int j = 0; j < nRegs; ++j) {
61  int pSgpr =
62  computeUnit->registerManager->mapSgpr(w, sgprIdx + j);
63 
64  if (regBusy(pSgpr)) {
65  if (ii->isDstOperand(i)) {
66  w->stats.numTimesBlockedDueWAXDependencies++;
67  } else if (ii->isSrcOperand(i)) {
68  DPRINTF(GPUSRF, "RAW stall: WV[%d]: %s: physReg[%d]\n",
69  w->wfDynId, ii->disassemble(), pSgpr);
70  w->stats.numTimesBlockedDueRAWDependencies++;
71  }
72  return false;
73  }
74  } // nRegs
75  } // isScalar
76  } // operand
77  return true;
78 }
79 
80 void
82 {
83  // iterate over all register destination operands
84  for (int i = 0; i < ii->getNumOperands(); ++i) {
85  if (ii->isScalarRegister(i) && ii->isDstOperand(i)) {
86 
87  int sgprIdx = ii->getRegisterIndex(i, ii);
88  int nRegs = ii->getOperandSize(i) <= 4 ? 1 :
89  ii->getOperandSize(i) / 4;
90 
91  for (int j = 0; j < nRegs; ++j) {
92  int physReg =
93  computeUnit->registerManager->mapSgpr(w, sgprIdx + j);
94 
95  // mark the destination scalar register as busy
96  markReg(physReg, true);
97  }
98  }
99  }
100 }
101 
102 void
104 {
105  for (int i = 0; i < ii->getNumOperands(); i++) {
106  if (ii->isScalarRegister(i) && ii->isSrcOperand(i)) {
107  int DWORDs = ii->getOperandSize(i) <= 4 ? 1
108  : ii->getOperandSize(i) / 4;
109  stats.registerReads += DWORDs;
110  }
111  }
112 
113  if (!ii->isLoad() && !(ii->isAtomic() || ii->isMemSync())) {
115  Tick tickDelay = computeUnit->cyclesToTicks(delay);
116 
117  for (int i = 0; i < ii->getNumOperands(); i++) {
118  if (ii->isScalarRegister(i) && ii->isDstOperand(i)) {
119  int sgprIdx = ii->getRegisterIndex(i, ii);
120  int nRegs = ii->getOperandSize(i) <= 4 ? 1
121  : ii->getOperandSize(i) / 4;
122  for (int j = 0; j < nRegs; j++) {
123  int physReg = computeUnit->registerManager->
124  mapSgpr(w, sgprIdx + j);
125  enqRegFreeEvent(physReg, tickDelay);
126  }
127 
128  stats.registerWrites += nRegs;
129  }
130  }
131  }
132 }
133 
134 void
136  GPUDynInstPtr ii)
137 {
138  assert(ii->isLoad() || ii->isAtomicRet());
139  for (int i = 0; i < ii->getNumOperands(); ++i) {
140  if (ii->isScalarRegister(i) && ii->isDstOperand(i)) {
141 
142  int sgprIdx = ii->getRegisterIndex(i, ii);
143  int nRegs = ii->getOperandSize(i) <= 4 ? 1 :
144  ii->getOperandSize(i) / 4;
145 
146  for (int j = 0; j < nRegs; ++j) {
147  int physReg = computeUnit->registerManager->
148  mapSgpr(w, sgprIdx + j);
150  }
151 
152  stats.registerWrites += nRegs;
153  }
154  }
155 }
shader.hh
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
RegisterFile::RegisterFileStats::registerWrites
Stats::Scalar registerWrites
Definition: register_file.hh:161
ScalarRegisterFile::regFile
std::vector< ScalarRegU32 > regFile
Definition: scalar_register_file.hh:98
compute_unit.hh
ScalarRegisterFile::ScalarRegisterFile
ScalarRegisterFile(const ScalarRegisterFileParams &p)
Definition: scalar_register_file.cc:44
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
RegisterManager::mapSgpr
int mapSgpr(Wavefront *w, int sgprIndex)
Definition: register_manager.cc:101
ComputeUnit::registerManager
RegisterManager * registerManager
Definition: compute_unit.hh:277
ComputeUnit::scalarPipeLength
int scalarPipeLength() const
Definition: compute_unit.hh:390
RegisterFile::numRegs
int numRegs() const
Definition: register_file.hh:61
wavefront.hh
ArmISA::j
Bitfield< 24 > j
Definition: miscregs_types.hh:54
Clocked::cyclesToTicks
Tick cyclesToTicks(Cycles c) const
Definition: clocked_object.hh:224
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:237
ScalarRegisterFile::waveExecuteInst
virtual void waveExecuteInst(Wavefront *w, GPUDynInstPtr ii) override
Definition: scalar_register_file.cc:103
ScalarRegisterFile::operandsReady
virtual bool operandsReady(Wavefront *w, GPUDynInstPtr ii) const override
Definition: scalar_register_file.cc:51
RegisterFile::RegisterFileStats::registerReads
Stats::Scalar registerReads
Definition: register_file.hh:159
RegisterFile::regBusy
virtual bool regBusy(int idx) const
Definition: register_file.cc:89
scalar_register_file.hh
gpu_dyn_inst.hh
ScalarRegisterFile::scheduleWriteOperands
virtual void scheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii) override
Definition: scalar_register_file.cc:81
Clocked::clockPeriod
Tick clockPeriod() const
Definition: clocked_object.hh:214
RegisterFile::stats
RegisterFile::RegisterFileStats stats
RegisterFile::markReg
virtual void markReg(int regIdx, bool value)
Definition: register_file.cc:95
ScalarRegisterFile::scheduleWriteOperandsFromLoad
virtual void scheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii) override
Definition: scalar_register_file.cc:135
Wavefront
Definition: wavefront.hh:59
RegisterFile::enqRegFreeEvent
virtual void enqRegFreeEvent(uint32_t regIdx, uint64_t delay)
Definition: register_file.cc:103
GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:48
logging.hh
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
RegisterFile
Definition: register_file.hh:55
RegisterFile::computeUnit
ComputeUnit * computeUnit
Definition: register_file.hh:145
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323

Generated on Tue Jun 22 2021 15:28:28 for gem5 by doxygen 1.8.17