Revert "performance: Prefer to assign new gpu va rather than reuse"

This reverts commit 0f2f3c3764.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2024-10-31 04:39:39 +01:00
committed by Compute-Runtime-Automation
parent 45a26c22dd
commit aca7875dfd
3 changed files with 122 additions and 50 deletions

View File

@@ -36,34 +36,32 @@ uint64_t HeapAllocator::allocateWithCustomAlignment(size_t &sizeToAllocate, size
uint32_t defragmentCount = 0;
for (;;) {
uint64_t ptrReturn = 0llu;
if (sizeToAllocate > sizeThreshold) {
const uint64_t misalignment = alignUp(pLeftBound, alignment) - pLeftBound;
if (pLeftBound + misalignment + sizeToAllocate <= pRightBound) {
if (misalignment) {
storeInFreedChunks(pLeftBound, static_cast<size_t>(misalignment), freedChunks);
pLeftBound += misalignment;
}
ptrReturn = pLeftBound;
pLeftBound += sizeToAllocate;
}
} else {
const uint64_t pStart = pRightBound - sizeToAllocate;
const uint64_t misalignment = pStart - alignDown(pStart, alignment);
if (pLeftBound + sizeToAllocate + misalignment <= pRightBound) {
if (misalignment) {
pRightBound -= misalignment;
storeInFreedChunks(pRightBound, static_cast<size_t>(misalignment), freedChunks);
}
pRightBound -= sizeToAllocate;
ptrReturn = pRightBound;
}
}
size_t sizeOfFreedChunk = 0;
uint64_t ptrReturn = getFromFreedChunks(sizeToAllocate, freedChunks, sizeOfFreedChunk, alignment);
if (ptrReturn == 0llu) {
ptrReturn = getFromFreedChunks(sizeToAllocate, freedChunks, sizeOfFreedChunk, alignment);
if (sizeToAllocate > sizeThreshold) {
const uint64_t misalignment = alignUp(pLeftBound, alignment) - pLeftBound;
if (pLeftBound + misalignment + sizeToAllocate <= pRightBound) {
if (misalignment) {
storeInFreedChunks(pLeftBound, static_cast<size_t>(misalignment), freedChunks);
pLeftBound += misalignment;
}
ptrReturn = pLeftBound;
pLeftBound += sizeToAllocate;
}
} else {
const uint64_t pStart = pRightBound - sizeToAllocate;
const uint64_t misalignment = pStart - alignDown(pStart, alignment);
if (pLeftBound + sizeToAllocate + misalignment <= pRightBound) {
if (misalignment) {
pRightBound -= misalignment;
storeInFreedChunks(pRightBound, static_cast<size_t>(misalignment), freedChunks);
}
pRightBound -= sizeToAllocate;
ptrReturn = pRightBound;
}
}
}
if (ptrReturn != 0llu) {