gem5 v24.0.0.0
Loading...
Searching...
No Matches
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 * 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
32#ifndef __REGISTER_FILE_HH__
33#define __REGISTER_FILE_HH__
34
35#include <limits>
36#include <vector>
37
38#include "base/statistics.hh"
39#include "base/types.hh"
40#include "gpu-compute/misc.hh"
41#include "sim/sim_object.hh"
42
43namespace gem5
44{
45
46class ComputeUnit;
47class Shader;
48class PoolManager;
49class Wavefront;
50
51struct RegisterFileParams;
52
53// Abstract Register File
54// This register file class can be inherited from to create both
55// scalar and vector register files.
56class RegisterFile : public SimObject
57{
58 public:
59 RegisterFile(const RegisterFileParams &p);
60 virtual ~RegisterFile();
61 virtual void setParent(ComputeUnit *_computeUnit);
62 int numRegs() const { return _numRegs; }
63
64 // State functions
65
66 // Scoreboard functions
67 virtual bool operandsReady(Wavefront *w, GPUDynInstPtr ii) const;
68 virtual bool regBusy(int idx) const;
69 virtual void markReg(int regIdx, bool value);
70
71 // Abstract Register Event
72 class RegisterEvent : public Event
73 {
74 protected:
76 int regIdx;
77
78 public:
79 RegisterEvent(RegisterFile *_rf, int _regIdx)
80 : rf(_rf), regIdx(_regIdx) { setFlags(AutoDelete); }
81 };
82
83 // Register Event to mark a register as free in the scoreboard/busy vector
85 {
86 public:
88 : RegisterEvent(_rf, _regIdx) { }
89 void process();
90 };
91
92 // Register Event to mark a register as busy in the scoreboard/busy vector
94 {
95 public:
97 : RegisterEvent(_rf, _regIdx) { }
98 void process();
99 };
100
101 // Schedule an event to mark a register as free/busy in
102 // the scoreboard/busy vector. Delay is already in Ticks
103 virtual void enqRegFreeEvent(uint32_t regIdx, uint64_t delay);
104 virtual void enqRegBusyEvent(uint32_t regIdx, uint64_t delay);
105
106 // Schedule functions
107
108 // The following functions are called by the SCH stage when attempting
109 // to move a wave from the readyList to the schList.
110 // canSchedule* checks if the RF is ready to provide operands for
111 // the instruction, while schedule* requests the RF to begin reading
112 // and writing of operands. Calling schedule* may only occur
113 // immediately after canSchedule* was called and returned True
118
119 // The following function is called to check if all operands
120 // have been read for the given instruction
121 virtual bool operandReadComplete(Wavefront *w, GPUDynInstPtr ii);
122
123 // The following two functions are only called by returning loads to
124 // check if the register file can support the incoming writes
126 GPUDynInstPtr ii);
127 // Queue the register writes. Assumes canScheduleWriteOperandsFromLoad
128 // was called immediately prior and returned True
130 GPUDynInstPtr ii);
131
132 // ExecRF is invoked every cycle by the compute unit and may be
133 // used to model detailed timing of the register file.
134 virtual void exec();
135
136 // Called to inform RF that an instruction is executing
137 // to schedule events for writeback, etc., as needed
138 virtual void waveExecuteInst(Wavefront *w, GPUDynInstPtr ii);
139
140 // Debug functions
141 virtual std::string dump() const;
142
143 virtual void dispatchInstruction(GPUDynInstPtr ii);
144
145 protected:
148
149 // flag indicating if a register is busy
151
152 // numer of registers in this register file
154
156 {
158
159 // Total number of register reads per DWORD per thread
161
164
165 // Total number of register writes per DWORD per thread
167
168 // Number of register file SRAM activations for reads.
169 // The register file may be implemented with multiple SRAMs. This stat
170 // tracks how many times the SRAMs are accessed for reads.
172 // Number of register file SRAM activations for writes
175};
176
177} // namespace gem5
178
179#endif // __REGISTER_FILE_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
static const FlagsType AutoDelete
Definition eventq.hh:110
void setFlags(Flags _flags)
Definition eventq.hh:331
MarkRegBusyScbEvent(RegisterFile *_rf, int _regIdx)
MarkRegFreeScbEvent(RegisterFile *_rf, int _regIdx)
RegisterEvent(RegisterFile *_rf, int _regIdx)
gem5::RegisterFile::RegisterFileStats stats
virtual bool regBusy(int idx) const
virtual void markReg(int regIdx, bool value)
virtual bool operandsReady(Wavefront *w, GPUDynInstPtr ii) const
std::vector< bool > busy
virtual void scheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii)
virtual bool canScheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii)
virtual void dispatchInstruction(GPUDynInstPtr ii)
virtual bool canScheduleWriteOperandsFromLoad(Wavefront *w, GPUDynInstPtr ii)
virtual void waveExecuteInst(Wavefront *w, GPUDynInstPtr ii)
virtual void enqRegBusyEvent(uint32_t regIdx, uint64_t delay)
RegisterFile(const RegisterFileParams &p)
virtual void exec()
virtual std::string dump() const
virtual void scheduleReadOperands(Wavefront *w, GPUDynInstPtr ii)
virtual void scheduleWriteOperands(Wavefront *w, GPUDynInstPtr ii)
virtual bool operandReadComplete(Wavefront *w, GPUDynInstPtr ii)
virtual void enqRegFreeEvent(uint32_t regIdx, uint64_t delay)
virtual void setParent(ComputeUnit *_computeUnit)
ComputeUnit * computeUnit
virtual bool canScheduleReadOperands(Wavefront *w, GPUDynInstPtr ii)
Abstract superclass for simulation objects.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
STL vector class.
Definition stl.hh:37
Bitfield< 0 > p
Bitfield< 0 > w
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition misc.hh:49
Declaration of Statistics objects.
RegisterFileStats(statistics::Group *parent)

Generated on Tue Jun 18 2024 16:24:04 for gem5 by doxygen 1.11.0