gem5  v22.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  * 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 "base/logging.hh"
35 #include "debug/GPUSRF.hh"
38 #include "gpu-compute/shader.hh"
39 #include "gpu-compute/wavefront.hh"
40 #include "params/ScalarRegisterFile.hh"
41 
42 namespace gem5
43 {
44 
45 ScalarRegisterFile::ScalarRegisterFile(const ScalarRegisterFileParams &p)
46  : RegisterFile(p)
47 {
48  regFile.resize(numRegs(), 0);
49 }
50 
51 bool
53 {
54  for (const auto& srcScalarOp : ii->srcScalarRegOperands()) {
55  for (const auto& physIdx : srcScalarOp.physIndices()) {
56  if (regBusy(physIdx)) {
57  DPRINTF(GPUSRF, "RAW stall: WV[%d]: %s: physReg[%d]\n",
58  w->wfDynId, ii->disassemble(), physIdx);
59  w->stats.numTimesBlockedDueRAWDependencies++;
60  return false;
61  }
62  }
63  }
64 
65  for (const auto& dstScalarOp : ii->dstScalarRegOperands()) {
66  for (const auto& physIdx : dstScalarOp.physIndices()) {
67  if (regBusy(physIdx)) {
68  DPRINTF(GPUSRF, "WAX stall: WV[%d]: %s: physReg[%d]\n",
69  w->wfDynId, ii->disassemble(), physIdx);
70  w->stats.numTimesBlockedDueWAXDependencies++;
71  return false;
72  }
73  }
74  }
75 
76  return true;
77 }
78 
79 void
81 {
82  for (const auto& dstScalarOp : ii->dstScalarRegOperands()) {
83  for (const auto& physIdx : dstScalarOp.physIndices()) {
84  // mark the destination scalar register as busy
85  markReg(physIdx, true);
86  }
87  }
88 }
89 
90 void
92 {
93  stats.registerReads += ii->numSrcScalarDWords();
94 
95  if (!ii->isLoad() && !(ii->isAtomic() || ii->isMemSync())) {
97  Tick tickDelay = computeUnit->cyclesToTicks(delay);
98 
99  for (const auto& dstScalarOp : ii->dstScalarRegOperands()) {
100  for (const auto& physIdx : dstScalarOp.physIndices()) {
101  enqRegFreeEvent(physIdx, tickDelay);
102  }
103  }
104 
105  stats.registerWrites += ii->numDstScalarDWords();
106  }
107 }
108 
109 void
111  GPUDynInstPtr ii)
112 {
113  assert(ii->isLoad() || ii->isAtomicRet());
114  for (const auto& dstScalarOp : ii->dstScalarRegOperands()) {
115  for (const auto& physIdx : dstScalarOp.physIndices()) {
117  }
118  }
119 
120  stats.registerWrites += ii->numDstScalarDWords();
121 }
122 
123 } // namespace gem5
#define DPRINTF(x,...)
Definition: trace.hh:186
Tick cyclesToTicks(Cycles c) const
Tick clockPeriod() const
int scalarPipeLength() const
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
gem5::RegisterFile::RegisterFileStats stats
virtual bool regBusy(int idx) const
virtual void markReg(int regIdx, bool value)
int numRegs() const
virtual void enqRegFreeEvent(uint32_t regIdx, uint64_t delay)
ComputeUnit * computeUnit
virtual void scheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii) override
ScalarRegisterFile(const ScalarRegisterFileParams &p)
virtual bool operandsReady(Wavefront *w, GPUDynInstPtr ii) const override
virtual void scheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii) override
std::vector< ScalarRegU32 > regFile
virtual void waveExecuteInst(Wavefront *w, GPUDynInstPtr ii) override
Bitfield< 6 > w
Definition: pagetable.hh:59
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:49
uint64_t Tick
Tick count type.
Definition: types.hh:58

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