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