gem5  v20.1.0.0
register_file.hh
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 
37 #ifndef __REGISTER_FILE_HH__
38 #define __REGISTER_FILE_HH__
39 
40 #include <limits>
41 #include <vector>
42 
43 #include "base/statistics.hh"
44 #include "base/types.hh"
45 #include "gpu-compute/misc.hh"
46 #include "sim/sim_object.hh"
47 
48 class ComputeUnit;
49 class Shader;
50 class PoolManager;
51 class Wavefront;
52 
53 struct RegisterFileParams;
54 
55 // Abstract Register File
56 // This register file class can be inherited from to create both
57 // scalar and vector register files.
58 class RegisterFile : public SimObject
59 {
60  public:
61  RegisterFile(const RegisterFileParams *p);
62  virtual ~RegisterFile();
63  virtual void setParent(ComputeUnit *_computeUnit);
64  int numRegs() const { return _numRegs; }
65  virtual void regStats() override;
66 
67  // State functions
68 
69  // Scoreboard functions
70  virtual bool operandsReady(Wavefront *w, GPUDynInstPtr ii) const;
71  virtual bool regBusy(int idx) const;
72  virtual void markReg(int regIdx, bool value);
73 
74  // Abstract Register Event
75  class RegisterEvent : public Event
76  {
77  protected:
79  int regIdx;
80 
81  public:
82  RegisterEvent(RegisterFile *_rf, int _regIdx)
83  : rf(_rf), regIdx(_regIdx) { setFlags(AutoDelete); }
84  };
85 
86  // Register Event to mark a register as free in the scoreboard/busy vector
88  {
89  public:
90  MarkRegFreeScbEvent(RegisterFile *_rf, int _regIdx)
91  : RegisterEvent(_rf, _regIdx) { }
92  void process();
93  };
94 
95  // Register Event to mark a register as busy in the scoreboard/busy vector
97  {
98  public:
99  MarkRegBusyScbEvent(RegisterFile *_rf, int _regIdx)
100  : RegisterEvent(_rf, _regIdx) { }
101  void process();
102  };
103 
104  // Schedule an event to mark a register as free/busy in
105  // the scoreboard/busy vector. Delay is already in Ticks
106  virtual void enqRegFreeEvent(uint32_t regIdx, uint64_t delay);
107  virtual void enqRegBusyEvent(uint32_t regIdx, uint64_t delay);
108 
109  // Schedule functions
110 
111  // The following functions are called by the SCH stage when attempting
112  // to move a wave from the readyList to the schList.
113  // canSchedule* checks if the RF is ready to provide operands for
114  // the instruction, while schedule* requests the RF to begin reading
115  // and writing of operands. Calling schedule* may only occur
116  // immediately after canSchedule* was called and returned True
119  virtual void scheduleReadOperands(Wavefront *w, GPUDynInstPtr ii);
120  virtual void scheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii);
121 
122  // The following function is called to check if all operands
123  // have been read for the given instruction
124  virtual bool operandReadComplete(Wavefront *w, GPUDynInstPtr ii);
125 
126  // The following two functions are only called by returning loads to
127  // check if the register file can support the incoming writes
129  GPUDynInstPtr ii);
130  // Queue the register writes. Assumes canScheduleWriteOperandsFromLoad
131  // was called immediately prior and returned True
133  GPUDynInstPtr ii);
134 
135  // ExecRF is invoked every cycle by the compute unit and may be
136  // used to model detailed timing of the register file.
137  virtual void exec();
138 
139  // Called to inform RF that an instruction is executing
140  // to schedule events for writeback, etc., as needed
141  virtual void waveExecuteInst(Wavefront *w, GPUDynInstPtr ii);
142 
143  // Debug functions
144  virtual std::string dump() const;
145 
146  virtual void dispatchInstruction(GPUDynInstPtr ii);
147 
148  protected:
150  int simdId;
151 
152  // flag indicating if a register is busy
154 
155  // numer of registers in this register file
156  int _numRegs;
157  // Stats
158  // Total number of register reads, incremented once per DWORD per thread
160  // Total number of register writes, incremented once per DWORD per thread
162 
163  // Number of register file SRAM activations for reads.
164  // The register file may be implemented with multiple SRAMs. This stat
165  // tracks how many times the SRAMs are accessed for reads.
167  // Number of register file SRAM activations for writes
169 };
170 
171 #endif // __REGISTER_FILE_HH__
RegisterFile::MarkRegFreeScbEvent::MarkRegFreeScbEvent
MarkRegFreeScbEvent(RegisterFile *_rf, int _regIdx)
Definition: register_file.hh:90
EventBase::AutoDelete
static const FlagsType AutoDelete
Definition: eventq.hh:102
RegisterFile::registerReads
Stats::Scalar registerReads
Definition: register_file.hh:159
RegisterFile::operandReadComplete
virtual bool operandReadComplete(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:158
RegisterFile::enqRegBusyEvent
virtual void enqRegBusyEvent(uint32_t regIdx, uint64_t delay)
Definition: register_file.cc:115
Shader
Definition: shader.hh:87
RegisterFile::waveExecuteInst
virtual void waveExecuteInst(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:170
RegisterFile::RegisterEvent::rf
RegisterFile * rf
Definition: register_file.hh:78
RegisterFile::RegisterFile
RegisterFile(const RegisterFileParams *p)
Definition: register_file.cc:51
RegisterFile::MarkRegBusyScbEvent
Definition: register_file.hh:96
RegisterFile::busy
std::vector< bool > busy
Definition: register_file.hh:153
RegisterFile::sramWrites
Stats::Scalar sramWrites
Definition: register_file.hh:168
RegisterFile::RegisterEvent::RegisterEvent
RegisterEvent(RegisterFile *_rf, int _regIdx)
Definition: register_file.hh:82
misc.hh
std::vector< bool >
RegisterFile::MarkRegBusyScbEvent::process
void process()
Definition: register_file.cc:191
RegisterFile::numRegs
int numRegs() const
Definition: register_file.hh:64
RegisterFile::MarkRegFreeScbEvent
Definition: register_file.hh:87
RegisterFile::scheduleReadOperands
virtual void scheduleReadOperands(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:131
RegisterFile::operandsReady
virtual bool operandsReady(Wavefront *w, GPUDynInstPtr ii) const
Definition: register_file.cc:86
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
ComputeUnit
Definition: compute_unit.hh:198
PoolManager
Definition: pool_manager.hh:45
RegisterFile::scheduleWriteOperands
virtual void scheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:142
Event
Definition: eventq.hh:246
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
sim_object.hh
RegisterFile::dump
virtual std::string dump() const
Definition: register_file.cc:72
statistics.hh
RegisterFile::regBusy
virtual bool regBusy(int idx) const
Definition: register_file.cc:92
Event::setFlags
void setFlags(Flags _flags)
Definition: eventq.hh:323
RegisterFile::~RegisterFile
virtual ~RegisterFile()
Definition: register_file.cc:61
RegisterFile::RegisterEvent
Definition: register_file.hh:75
RegisterFile::canScheduleWriteOperandsFromLoad
virtual bool canScheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:147
RegisterFile::simdId
int simdId
Definition: register_file.hh:150
RegisterFile::_numRegs
int _numRegs
Definition: register_file.hh:156
RegisterFile::scheduleWriteOperandsFromLoad
virtual void scheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:153
RegisterFile::canScheduleReadOperands
virtual bool canScheduleReadOperands(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:125
RegisterFile::markReg
virtual void markReg(int regIdx, bool value)
Definition: register_file.cc:98
RegisterFile::regStats
virtual void regStats() override
Callback to set stat parameters.
Definition: register_file.cc:202
types.hh
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
RegisterFile::canScheduleWriteOperands
virtual bool canScheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii)
Definition: register_file.cc:136
RegisterFile::sramReads
Stats::Scalar sramReads
Definition: register_file.hh:166
RegisterFile
Definition: register_file.hh:58
RegisterFile::RegisterEvent::regIdx
int regIdx
Definition: register_file.hh:79
RegisterFile::computeUnit
ComputeUnit * computeUnit
Definition: register_file.hh:149
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
RegisterFile::setParent
virtual void setParent(ComputeUnit *_computeUnit)
Definition: register_file.cc:66
RegisterFile::MarkRegBusyScbEvent::MarkRegBusyScbEvent
MarkRegBusyScbEvent(RegisterFile *_rf, int _regIdx)
Definition: register_file.hh:99
RegisterFile::MarkRegFreeScbEvent::process
void process()
Definition: register_file.cc:184
RegisterFile::dispatchInstruction
virtual void dispatchInstruction(GPUDynInstPtr ii)
Definition: register_file.cc:197
RegisterFile::exec
virtual void exec()
Definition: register_file.cc:165
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

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