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

Generated on Wed Sep 30 2020 14:02:12 for gem5 by doxygen 1.8.17