35#include "debug/GPUVRF.hh"
57 uint32_t reservedEntries = 0;
67 reservedEntries += it_free->first;
72 if (reservedEntries == 0)
73 _cout =
"VRF is empty\n";
75 _cout =
"VRF reserves " + std::to_string(reservedEntries) +
" VGPRs\n";
96 uint32_t numAvailChunks = 0;
97 DPRINTF(GPUVRF,
"Checking if we can allocate %d regions of size %d "
98 "registers\n", numRegions, actualSize);
100 numAvailChunks += (it.second - it.first)/actualSize;
103 if (numAvailChunks >= numRegions) {
104 DPRINTF(GPUVRF,
"Able to allocate %d regions of size %d; "
105 "number of available regions: %d\n",
106 numRegions, actualSize, numAvailChunks);
109 DPRINTF(GPUVRF,
"Unable to allocate %d regions of size %d; "
110 "number of available regions: %d\n",
111 numRegions, actualSize, numAvailChunks);
118 uint32_t *reservedPoolSize)
120 uint32_t startIdx = (unsigned)-1;
124 uint32_t curChunkSize = it->second - it->first;
125 if (curChunkSize >= actualSize) {
127 startIdx = it->first;
129 *reservedPoolSize = actualSize;
135 if (curChunkSize == actualSize) {
141 it->first += actualSize;
147 DPRINTF(GPUVRF,
"totRegSpace %d allocating Register at %d and"
157 DPRINTF(GPUVRF,
"freeing Region at %d %d, size %d\n",
158 firstIdx,lastIdx,lastIdx-firstIdx);
161 assert(firstIdx < lastIdx);
166 auto firstIt = std::find_if(
170 return element.second == firstIdx;} );
172 auto lastIt = std::find_if(
176 return element.first == lastIdx;} );
179 firstIt->second = lastIt->second;
182 firstIt->second = lastIdx;
184 lastIt->first = firstIdx;
196 bool wrapAround = (region.first > region.second);
198 return region.second - region.first + 1;
200 return region.second +
poolSize() - region.first + 1;
void resetRegion(const int ®sPerSimd) override
std::string printRegion() override
std::list< std::pair< int, int > > freeSpaceRecord
uint32_t allocateRegion(const uint32_t size, uint32_t *reservedPoolSize) override
uint32_t minAllocatedElements(uint32_t size)
uint32_t regionSize(std::pair< uint32_t, uint32_t > ®ion) override
uint32_t _totRegSpaceAvailable
void freeRegion(uint32_t firstIdx, uint32_t lastIdx) override
bool canAllocate(uint32_t numRegions, uint32_t size) override
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.