38 #include "config/the_gpu_isa.hh"
39 #include "debug/GPURename.hh"
59 panic_if((vgprIndex >=
w->reservedVectorRegs)
60 || (
w->reservedVectorRegs < 0),
61 "VGPR index %d is out of range: VGPR range=[0,%d]",
62 vgprIndex,
w->reservedVectorRegs);
65 int physicalVgprIndex =
w->startVgprIndex + vgprIndex;
67 panic_if(!((
w->startVgprIndex <= physicalVgprIndex) &&
68 (
w->startVgprIndex +
w->reservedVectorRegs - 1)
69 >= physicalVgprIndex),
70 "Invalid VGPR index %d\n", physicalVgprIndex);
73 return physicalVgprIndex %
w->computeUnit->vrf[
w->simdId]->numRegs();
79 panic_if(!((sgprIndex < w->reservedScalarRegs)
80 && (
w->reservedScalarRegs > 0)),
81 "SGPR index %d is out of range: SGPR range=[0,%d]\n",
82 sgprIndex,
w->reservedScalarRegs);
85 int physicalSgprIndex =
w->startSgprIndex + sgprIndex;
87 panic_if(!((
w->startSgprIndex <= physicalSgprIndex) &&
88 (
w->startSgprIndex +
w->reservedScalarRegs - 1)
89 >= physicalSgprIndex),
90 "Invalid SGPR index %d\n", physicalSgprIndex);
93 return physicalSgprIndex %
w->computeUnit->srf[
w->simdId]->numRegs();
101 canAllocate(nWfs, demandPerWf);
109 canAllocate(nWfs, demandPerWf);
116 uint32_t allocatedSize = 0;
118 allocateRegion(vectorDemand, &allocatedSize);
119 w->reservedVectorRegs = allocatedSize;
122 "VRF[%d] has been overallocated %d > %d\n",
128 allocateRegion(scalarDemand, &allocatedSize);
129 w->reservedScalarRegs = allocatedSize;
132 "SRF[%d] has been overallocated %d > %d\n",
142 w->computeUnit->vectorRegsReserved[
w->simdId] -=
w->reservedVectorRegs;
144 w->computeUnit->scalarRegsReserved[
w->simdId] -=
w->reservedScalarRegs;
146 panic_if(
w->computeUnit->vectorRegsReserved[
w->simdId] < 0,
147 "Freeing VRF[%d] registers left %d registers reserved\n",
149 w->computeUnit->vectorRegsReserved[
w->simdId]);
150 panic_if(
w->computeUnit->scalarRegsReserved[
w->simdId] < 0,
151 "Freeing SRF[%d] registers left %d registers reserved\n",
153 w->computeUnit->scalarRegsReserved[
w->simdId]);
155 int endIndex = (
w->startVgprIndex +
w->reservedVectorRegs - 1) %
156 w->computeUnit->vrf[
w->simdId]->numRegs();
158 w->computeUnit->registerManager->vrfPoolMgrs[
w->simdId]->
159 freeRegion(
w->startVgprIndex, endIndex);
162 for (
int i = 0;
i <
w->reservedVectorRegs;
i++) {
164 w->computeUnit->vrf[
w->simdId]->markReg(physVgprIdx,
false);
167 w->reservedVectorRegs = 0;
168 w->startVgprIndex = 0;
170 endIndex = (
w->startSgprIndex +
w->reservedScalarRegs - 1) %
171 w->computeUnit->srf[
w->simdId]->numRegs();
172 w->computeUnit->registerManager->srfPoolMgrs[
w->simdId]->
173 freeRegion(
w->startSgprIndex, endIndex);
176 for (
int i = 0;
i <
w->reservedScalarRegs;
i++) {
178 w->computeUnit->srf[
w->simdId]->markReg(physSgprIdx,
false);
181 w->reservedScalarRegs = 0;
182 w->startSgprIndex = 0;