gem5 v24.0.0.0
Loading...
Searching...
No Matches
register_manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016, 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 * Author: Mark Wyse
32 */
33
35
36#include "config/the_gpu_isa.hh"
37#include "debug/GPURename.hh"
43#include "params/RegisterManager.hh"
44
45namespace gem5
46{
47
48RegisterManager::RegisterManager(const RegisterManagerParams &p)
49 : SimObject(p), srfPoolMgrs(p.srf_pool_managers),
50 vrfPoolMgrs(p.vrf_pool_managers)
51{
52 if (p.policy == "static") {
54 } else {
55 fatal("Unimplemented Register Manager Policy");
56 }
57
58}
59
61{
62 for (auto mgr : srfPoolMgrs) {
63 delete mgr;
64 }
65 for (auto mgr : vrfPoolMgrs) {
66 delete mgr;
67 }
68}
69
70void
75
76void
78{
79 computeUnit = cu;
81 for (int i = 0; i < srfPoolMgrs.size(); i++) {
82 fatal_if(computeUnit->srf[i]->numRegs() %
83 srfPoolMgrs[i]->minAllocation(),
84 "Min SGPR allocation is not multiple of VRF size\n");
85 }
86 for (int i = 0; i < vrfPoolMgrs.size(); i++) {
87 fatal_if(computeUnit->vrf[i]->numRegs() %
88 vrfPoolMgrs[i]->minAllocation(),
89 "Min VGPG allocation is not multiple of VRF size\n");
90 }
91}
92
93// compute mapping for vector register
94int
96{
97 return policy->mapVgpr(w, vgprIndex);
98}
99
100// compute mapping for scalar register
101int
103{
104 return policy->mapSgpr(w, sgprIndex);
105}
106
107// check if we can allocate registers
108bool
109RegisterManager::canAllocateVgprs(int simdId, int nWfs, int demandPerWf)
110{
111 return policy->canAllocateVgprs(simdId, nWfs, demandPerWf);
112}
113
114bool
115RegisterManager::canAllocateSgprs(int simdId, int nWfs, int demandPerWf)
116{
117 return policy->canAllocateSgprs(simdId, nWfs, demandPerWf);
118}
119
120// allocate registers
121void
123 int scalarDemand)
124{
125 policy->allocateRegisters(w, vectorDemand, scalarDemand);
126}
127
128void
133
134} // namespace gem5
std::vector< ScalarRegisterFile * > srf
std::vector< VectorRegisterFile * > vrf
virtual int mapSgpr(Wavefront *w, int sgprIndex)=0
virtual bool canAllocateSgprs(int simdId, int nWfs, int demandPerWf)=0
virtual void setParent(ComputeUnit *_cu)
virtual bool canAllocateVgprs(int simdId, int nWfs, int demandPerWf)=0
virtual int mapVgpr(Wavefront *w, int vgprIndex)=0
virtual void allocateRegisters(Wavefront *w, int vectorDemand, int scalarDemand)=0
virtual void freeRegisters(Wavefront *w)=0
int mapVgpr(Wavefront *w, int vgprIndex)
RegisterManager(const RegisterManagerParams &params)
void allocateRegisters(Wavefront *w, int vectorDemand, int scalarDemand)
void freeRegisters(Wavefront *w)
std::vector< PoolManager * > vrfPoolMgrs
RegisterManagerPolicy * policy
int mapSgpr(Wavefront *w, int sgprIndex)
bool canAllocateSgprs(int simdId, int nWfs, int demandPerWf)
std::vector< PoolManager * > srfPoolMgrs
bool canAllocateVgprs(int simdId, int nWfs, int demandPerWf)
void setParent(ComputeUnit *cu)
Abstract superclass for simulation objects.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition logging.hh:236
#define fatal(...)
This implements a cprintf based fatal() function.
Definition logging.hh:200
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 0 > p
Bitfield< 0 > w
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36

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