refactor: correct naming of HeapIndex enum values

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2023-12-12 08:58:42 +00:00
committed by Compute-Runtime-Automation
parent 895519db38
commit 0428c0acd1
36 changed files with 543 additions and 543 deletions

View File

@@ -37,17 +37,17 @@ bool HeapAssigner::useExternal32BitHeap(AllocationType allocType) {
}
bool HeapAssigner::heapTypeExternalWithFrontWindowPool(HeapIndex heap) {
return heap == HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY || heap == HeapIndex::HEAP_EXTERNAL;
return heap == HeapIndex::heapExternalDeviceMemory || heap == HeapIndex::heapExternal;
}
HeapIndex HeapAssigner::mapExternalWindowIndex(HeapIndex index) {
auto retIndex = HeapIndex::TOTAL_HEAPS;
auto retIndex = HeapIndex::totalHeaps;
switch (index) {
case HeapIndex::HEAP_EXTERNAL:
retIndex = HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW;
case HeapIndex::heapExternal:
retIndex = HeapIndex::heapExternalFrontWindow;
break;
case HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY:
retIndex = HeapIndex::HEAP_EXTERNAL_DEVICE_FRONT_WINDOW;
case HeapIndex::heapExternalDeviceMemory:
retIndex = HeapIndex::heapExternalDeviceFrontWindow;
break;
default:
UNRECOVERABLE_IF(true);
@@ -57,13 +57,13 @@ HeapIndex HeapAssigner::mapExternalWindowIndex(HeapIndex index) {
}
HeapIndex HeapAssigner::mapInternalWindowIndex(HeapIndex index) {
auto retIndex = HeapIndex::TOTAL_HEAPS;
auto retIndex = HeapIndex::totalHeaps;
switch (index) {
case HeapIndex::HEAP_INTERNAL:
retIndex = HeapIndex::HEAP_INTERNAL_FRONT_WINDOW;
case HeapIndex::heapInternal:
retIndex = HeapIndex::heapInternalFrontWindow;
break;
case HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY:
retIndex = HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW;
case HeapIndex::heapInternalDeviceMemory:
retIndex = HeapIndex::heapInternalDeviceFrontWindow;
break;
default:
UNRECOVERABLE_IF(true);
@@ -73,7 +73,7 @@ HeapIndex HeapAssigner::mapInternalWindowIndex(HeapIndex index) {
}
bool HeapAssigner::isInternalHeap(HeapIndex heap) {
return heap == HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY || heap == HeapIndex::HEAP_INTERNAL;
return heap == HeapIndex::heapInternalDeviceMemory || heap == HeapIndex::heapInternal;
}
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -21,7 +21,7 @@ bool operator==(const AlignmentSelector::CandidateAlignment &lhs, const Alignmen
}
void AlignmentSelector::addCandidateAlignment(size_t alignment, bool applyForSmallerSize, float maxMemoryWastage) {
this->addCandidateAlignment(alignment, applyForSmallerSize, maxMemoryWastage, HeapIndex::TOTAL_HEAPS);
this->addCandidateAlignment(alignment, applyForSmallerSize, maxMemoryWastage, HeapIndex::totalHeaps);
}
void AlignmentSelector::addCandidateAlignment(size_t alignment, bool applyForSmallerSize, float maxMemoryWastage, HeapIndex heap) {

View File

@@ -16,19 +16,19 @@
namespace NEO {
const std::array<HeapIndex, 4> GfxPartition::heap32Names{{HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_INTERNAL,
HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_EXTERNAL}};
const std::array<HeapIndex, 4> GfxPartition::heap32Names{{HeapIndex::heapInternalDeviceMemory,
HeapIndex::heapInternal,
HeapIndex::heapExternalDeviceMemory,
HeapIndex::heapExternal}};
const std::array<HeapIndex, 8> GfxPartition::heapNonSvmNames{{HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_INTERNAL,
HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_EXTERNAL,
HeapIndex::HEAP_STANDARD,
HeapIndex::HEAP_STANDARD64KB,
HeapIndex::HEAP_STANDARD2MB,
HeapIndex::HEAP_EXTENDED}};
const std::array<HeapIndex, 8> GfxPartition::heapNonSvmNames{{HeapIndex::heapInternalDeviceMemory,
HeapIndex::heapInternal,
HeapIndex::heapExternalDeviceMemory,
HeapIndex::heapExternal,
HeapIndex::heapStandard,
HeapIndex::heapStandard64KB,
HeapIndex::heapStandard2MB,
HeapIndex::heapExtended}};
static void reserveLow48BitRangeWithRetry(OSMemory *osMemory, OSMemory::ReservedCpuAddressRange &reservedCpuAddressRange) {
uint64_t reservationSize = 256 * MemoryConstants::gigaByte;
@@ -169,21 +169,21 @@ void GfxPartition::freeGpuAddressRange(uint64_t ptr, size_t size) {
}
uint64_t GfxPartition::getHeapMinimalAddress(HeapIndex heapIndex) {
if (heapIndex == HeapIndex::HEAP_SVM ||
heapIndex == HeapIndex::HEAP_EXTERNAL_DEVICE_FRONT_WINDOW ||
heapIndex == HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW ||
heapIndex == HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW ||
heapIndex == HeapIndex::HEAP_INTERNAL_FRONT_WINDOW) {
if (heapIndex == HeapIndex::heapSvm ||
heapIndex == HeapIndex::heapExternalDeviceFrontWindow ||
heapIndex == HeapIndex::heapExternalFrontWindow ||
heapIndex == HeapIndex::heapInternalDeviceFrontWindow ||
heapIndex == HeapIndex::heapInternalFrontWindow) {
return getHeapBase(heapIndex);
} else {
if ((heapIndex == HeapIndex::HEAP_EXTERNAL ||
heapIndex == HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY) &&
if ((heapIndex == HeapIndex::heapExternal ||
heapIndex == HeapIndex::heapExternalDeviceMemory) &&
(getHeapLimit(HeapAssigner::mapExternalWindowIndex(heapIndex)) != 0)) {
return getHeapBase(heapIndex) + GfxPartition::externalFrontWindowPoolSize;
} else if (heapIndex == HeapIndex::HEAP_INTERNAL ||
heapIndex == HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY) {
} else if (heapIndex == HeapIndex::heapInternal ||
heapIndex == HeapIndex::heapInternalDeviceMemory) {
return getHeapBase(heapIndex) + GfxPartition::internalFrontWindowPoolSize;
} else if (heapIndex == HeapIndex::HEAP_STANDARD2MB) {
} else if (heapIndex == HeapIndex::heapStandard2MB) {
return getHeapBase(heapIndex) + GfxPartition::heapGranularity2MB;
}
return getHeapBase(heapIndex) + GfxPartition::heapGranularity;
@@ -244,12 +244,12 @@ bool GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToRe
if (is32bit) {
gfxBase = maxNBitValue(32) + 1;
heapInit(HeapIndex::HEAP_SVM, 0ull, gfxBase);
heapInit(HeapIndex::heapSvm, 0ull, gfxBase);
} else {
auto cpuVirtualAddressSize = CpuInfo::getInstance().getVirtualAddressSize();
if (cpuVirtualAddressSize == 48 && gpuAddressSpace == maxNBitValue(48)) {
gfxBase = maxNBitValue(48 - 1) + 1;
heapInit(HeapIndex::HEAP_SVM, 0ull, gfxBase);
heapInit(HeapIndex::heapSvm, 0ull, gfxBase);
} else if (gpuAddressSpace == maxNBitValue(47)) {
if (reservedCpuAddressRangeForHeapSvm.alignedPtr == nullptr) {
if (cpuAddressRangeSizeToReserve == 0) {
@@ -265,10 +265,10 @@ bool GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToRe
}
gfxBase = reinterpret_cast<uint64_t>(reservedCpuAddressRangeForHeapSvm.alignedPtr);
gfxTop = gfxBase + cpuAddressRangeSizeToReserve;
heapInit(HeapIndex::HEAP_SVM, 0ull, gpuAddressSpace + 1);
heapInit(HeapIndex::heapSvm, 0ull, gpuAddressSpace + 1);
} else if (gpuAddressSpace < maxNBitValue(47)) {
gfxBase = 0ull;
heapInit(HeapIndex::HEAP_SVM, 0ull, 0ull);
heapInit(HeapIndex::heapSvm, 0ull, 0ull);
} else {
if (!initAdditionalRange(cpuVirtualAddressSize, gpuAddressSpace, gfxBase, gfxTop, rootDeviceIndex, numRootDevices, systemMemorySize)) {
return false;
@@ -291,29 +291,29 @@ bool GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToRe
gfxBase += gfxHeap32Size;
}
constexpr uint32_t numStandardHeaps = static_cast<uint32_t>(HeapIndex::HEAP_STANDARD2MB) - static_cast<uint32_t>(HeapIndex::HEAP_STANDARD) + 1;
constexpr uint32_t numStandardHeaps = static_cast<uint32_t>(HeapIndex::heapStandard2MB) - static_cast<uint32_t>(HeapIndex::heapStandard) + 1;
constexpr uint64_t maxStandardHeapGranularity = std::max(GfxPartition::heapGranularity, GfxPartition::heapGranularity2MB);
gfxBase = alignUp(gfxBase, maxStandardHeapGranularity);
uint64_t maxStandardHeapSize = alignDown((gfxTop - gfxBase) / numStandardHeaps, maxStandardHeapGranularity);
auto gfxStandardSize = maxStandardHeapSize;
heapInit(HeapIndex::HEAP_STANDARD, gfxBase, gfxStandardSize);
DEBUG_BREAK_IF(!isAligned<GfxPartition::heapGranularity>(getHeapBase(HeapIndex::HEAP_STANDARD)));
heapInit(HeapIndex::heapStandard, gfxBase, gfxStandardSize);
DEBUG_BREAK_IF(!isAligned<GfxPartition::heapGranularity>(getHeapBase(HeapIndex::heapStandard)));
gfxBase += maxStandardHeapSize;
// Split HEAP_STANDARD64K among root devices
auto gfxStandard64KBSize = alignDown(maxStandardHeapSize / numRootDevices, GfxPartition::heapGranularity);
heapInitWithAllocationAlignment(HeapIndex::HEAP_STANDARD64KB, gfxBase + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize, MemoryConstants::pageSize64k);
DEBUG_BREAK_IF(!isAligned<GfxPartition::heapGranularity>(getHeapBase(HeapIndex::HEAP_STANDARD64KB)));
heapInitWithAllocationAlignment(HeapIndex::heapStandard64KB, gfxBase + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize, MemoryConstants::pageSize64k);
DEBUG_BREAK_IF(!isAligned<GfxPartition::heapGranularity>(getHeapBase(HeapIndex::heapStandard64KB)));
gfxBase += maxStandardHeapSize;
// Split HEAP_STANDARD2MB among root devices
auto gfxStandard2MBSize = alignDown(maxStandardHeapSize / numRootDevices, GfxPartition::heapGranularity2MB);
heapInitWithAllocationAlignment(HeapIndex::HEAP_STANDARD2MB, gfxBase + rootDeviceIndex * gfxStandard2MBSize, gfxStandard2MBSize, 2 * MemoryConstants::megaByte);
DEBUG_BREAK_IF(!isAligned<GfxPartition::heapGranularity2MB>(getHeapBase(HeapIndex::HEAP_STANDARD2MB)));
heapInitWithAllocationAlignment(HeapIndex::heapStandard2MB, gfxBase + rootDeviceIndex * gfxStandard2MBSize, gfxStandard2MBSize, 2 * MemoryConstants::megaByte);
DEBUG_BREAK_IF(!isAligned<GfxPartition::heapGranularity2MB>(getHeapBase(HeapIndex::heapStandard2MB)));
return true;
}
@@ -360,30 +360,30 @@ bool GfxPartition::initAdditionalRange(uint32_t cpuVirtualAddressSize, uint64_t
gfxBase = castToUint64(reservedCpuAddressRangeForHeapSvm.alignedPtr);
gfxTop = gfxBase + reservedCpuAddressRangeForHeapSvm.sizeToReserve;
if (gpuAddressSpace == maxNBitValue(57)) {
heapInit(HeapIndex::HEAP_SVM, 0ull, maxNBitValue(57 - 1) + 1);
heapInit(HeapIndex::heapSvm, 0ull, maxNBitValue(57 - 1) + 1);
} else {
heapInit(HeapIndex::HEAP_SVM, 0ull, maxNBitValue(48) + 1);
heapInit(HeapIndex::heapSvm, 0ull, maxNBitValue(48) + 1);
}
if (gpuAddressSpace == maxNBitValue(57)) {
uint64_t heapExtendedSize = 4 * systemMemorySize;
reserve57BitRangeWithMemoryMapsParse(osMemory.get(), reservedCpuAddressRangeForHeapExtended, heapExtendedSize);
if (reservedCpuAddressRangeForHeapExtended.alignedPtr) {
heapInit(HeapIndex::HEAP_EXTENDED_HOST, castToUint64(reservedCpuAddressRangeForHeapExtended.alignedPtr), heapExtendedSize);
heapInit(HeapIndex::heapExtendedHost, castToUint64(reservedCpuAddressRangeForHeapExtended.alignedPtr), heapExtendedSize);
}
}
} else {
// On 48 bit CPU this range is reserved for OS usage, do not reserve
gfxBase = maxNBitValue(48 - 1) + 1; // 0x800000000000
gfxTop = maxNBitValue(48) + 1; // 0x1000000000000
heapInit(HeapIndex::HEAP_SVM, 0ull, gfxBase);
heapInit(HeapIndex::heapSvm, 0ull, gfxBase);
}
// Init HEAP_EXTENDED only for 57 bit GPU
if (gpuAddressSpace == maxNBitValue(57)) {
// Split HEAP_EXTENDED among root devices (like HEAP_STANDARD64K)
auto heapExtendedSize = alignDown((maxNBitValue(48) + 1) / numRootDevices, GfxPartition::heapGranularity);
heapInit(HeapIndex::HEAP_EXTENDED, maxNBitValue(57 - 1) + 1 + rootDeviceIndex * heapExtendedSize, heapExtendedSize);
heapInit(HeapIndex::heapExtended, maxNBitValue(57 - 1) + 1 + rootDeviceIndex * heapExtendedSize, heapExtendedSize);
}
return true;

View File

@@ -15,23 +15,23 @@ namespace NEO {
class HeapAllocator;
enum class HeapIndex : uint32_t {
HEAP_INTERNAL_DEVICE_MEMORY = 0u,
HEAP_INTERNAL = 1u,
HEAP_EXTERNAL_DEVICE_MEMORY = 2u,
HEAP_EXTERNAL = 3u,
HEAP_STANDARD,
HEAP_STANDARD64KB,
HEAP_STANDARD2MB,
HEAP_SVM,
HEAP_EXTENDED,
HEAP_EXTERNAL_FRONT_WINDOW,
HEAP_EXTERNAL_DEVICE_FRONT_WINDOW,
HEAP_INTERNAL_FRONT_WINDOW,
HEAP_INTERNAL_DEVICE_FRONT_WINDOW,
HEAP_EXTENDED_HOST,
heapInternalDeviceMemory = 0u,
heapInternal = 1u,
heapExternalDeviceMemory = 2u,
heapExternal = 3u,
heapStandard,
heapStandard64KB,
heapStandard2MB,
heapSvm,
heapExtended,
heapExternalFrontWindow,
heapExternalDeviceFrontWindow,
heapInternalFrontWindow,
heapInternalDeviceFrontWindow,
heapExtendedHost,
// Please put new heap indexes above this line
TOTAL_HEAPS
totalHeaps
};
class GfxPartition {
@@ -85,11 +85,11 @@ class GfxPartition {
uint64_t getHeapMinimalAddress(HeapIndex heapIndex);
bool isLimitedRange() { return getHeap(HeapIndex::HEAP_SVM).getSize() == 0ull; }
bool isLimitedRange() { return getHeap(HeapIndex::heapSvm).getSize() == 0ull; }
static bool isAnyHeap32(HeapIndex heapIndex) {
if ((heapIndex >= HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY && heapIndex <= HeapIndex::HEAP_EXTERNAL) ||
(heapIndex >= HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW && heapIndex <= HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)) {
if ((heapIndex >= HeapIndex::heapInternalDeviceMemory && heapIndex <= HeapIndex::heapExternal) ||
(heapIndex >= HeapIndex::heapExternalFrontWindow && heapIndex <= HeapIndex::heapInternalDeviceFrontWindow)) {
return true;
}
return false;
@@ -129,7 +129,7 @@ class GfxPartition {
return heaps[static_cast<uint32_t>(heapIndex)];
}
std::array<Heap, static_cast<uint32_t>(HeapIndex::TOTAL_HEAPS)> heaps;
std::array<Heap, static_cast<uint32_t>(HeapIndex::totalHeaps)> heaps;
OSMemory::ReservedCpuAddressRange &reservedCpuAddressRangeForHeapSvm;
OSMemory::ReservedCpuAddressRange reservedCpuAddressRangeForHeapExtended{};

View File

@@ -120,10 +120,10 @@ GmmHelper *MemoryManager::getGmmHelper(uint32_t rootDeviceIndex) {
}
HeapIndex MemoryManager::selectInternalHeap(bool useLocalMemory) {
return useLocalMemory ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_INTERNAL;
return useLocalMemory ? HeapIndex::heapInternalDeviceMemory : HeapIndex::heapInternal;
}
HeapIndex MemoryManager::selectExternalHeap(bool useLocalMemory) {
return useLocalMemory ? HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL;
return useLocalMemory ? HeapIndex::heapExternalDeviceMemory : HeapIndex::heapExternal;
}
void MemoryManager::zeroCpuMemoryIfRequested(const AllocationData &allocationData, void *cpuPtr, size_t size) {
@@ -771,15 +771,15 @@ HeapIndex MemoryManager::selectHeap(const GraphicsAllocation *allocation, bool h
}
if (isFullRangeSVM) {
if (hasPointer) {
return HeapIndex::HEAP_SVM;
return HeapIndex::heapSvm;
}
if (allocation && allocation->getDefaultGmm()->gmmResourceInfo->is64KBPageSuitable()) {
return HeapIndex::HEAP_STANDARD64KB;
return HeapIndex::heapStandard64KB;
}
return HeapIndex::HEAP_STANDARD;
return HeapIndex::heapStandard;
}
// Limited range allocation goes to STANDARD heap
return HeapIndex::HEAP_STANDARD;
return HeapIndex::heapStandard;
}
bool MemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy) {

View File

@@ -541,7 +541,7 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType
size_t alignedSize = alignSizeWholePage(pMem, memSize);
auto heap = (force32bitAllocations || requireSpecificBitness) ? HeapIndex::HEAP_EXTERNAL : HeapIndex::HEAP_STANDARD;
auto heap = (force32bitAllocations || requireSpecificBitness) ? HeapIndex::heapExternal : HeapIndex::heapStandard;
auto gfxPartition = getGfxPartition(rootDeviceIndex);
uint64_t limitedGpuAddress = gfxPartition->heapAllocate(heap, alignedSize);
@@ -549,7 +549,7 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType
auto memoryAllocation = new MemoryAllocation(rootDeviceIndex, allocationType, driverAllocatedCpuPointer, pMem, canonizedGpuAddress, memSize,
count, pool, uncacheable, flushL3Required, maxOsContextCount);
if (heap == HeapIndex::HEAP_EXTERNAL) {
if (heap == HeapIndex::heapExternal) {
memoryAllocation->setGpuBaseAddress(gmmHelper->canonize(gfxPartition->getHeapBase(heap)));
}
memoryAllocation->sizeToFree = alignedSize;
@@ -558,12 +558,12 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType
}
size_t OsAgnosticMemoryManager::selectAlignmentAndHeap(size_t size, HeapIndex *heap) {
*heap = HeapIndex::HEAP_STANDARD;
*heap = HeapIndex::heapStandard;
return MemoryConstants::pageSize64k;
}
AddressRange OsAgnosticMemoryManager::reserveGpuAddress(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) {
return reserveGpuAddressOnHeap(requiredStartAddress, size, rootDeviceIndices, reservedOnRootDeviceIndex, HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
return reserveGpuAddressOnHeap(requiredStartAddress, size, rootDeviceIndices, reservedOnRootDeviceIndex, HeapIndex::heapStandard, MemoryConstants::pageSize64k);
}
AddressRange OsAgnosticMemoryManager::reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) {
@@ -638,13 +638,13 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(
}
auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex);
auto heapIndex = HeapIndex::HEAP_STANDARD64KB;
auto heapIndex = HeapIndex::heapStandard64KB;
if (use32Allocator) {
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
heapIndex = heapAssigners[allocationData.rootDeviceIndex]->get32BitHeapIndex(allocationData.type, true, *hwInfo, allocationData.flags.use32BitFrontWindow);
} else if ((gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0) && !allocationData.flags.resource48Bit) {
heapIndex = HeapIndex::HEAP_EXTENDED;
} else if ((gfxPartition->getHeapLimit(HeapIndex::heapExtended) > 0) && !allocationData.flags.resource48Bit) {
heapIndex = HeapIndex::heapExtended;
}
auto systemMemory = allocateSystemMemory(sizeAligned64k, MemoryConstants::pageSize64k);

View File

@@ -60,13 +60,13 @@ DrmMemoryManager::DrmMemoryManager(gemCloseWorkerMode mode,
forcePinEnabled(forcePinAllowed),
validateHostPtrMemory(validateHostPtrMemory) {
alignmentSelector.addCandidateAlignment(MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD64KB);
alignmentSelector.addCandidateAlignment(MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::heapStandard64KB);
if (debugManager.flags.AlignLocalMemoryVaTo2MB.get() != 0) {
alignmentSelector.addCandidateAlignment(MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD2MB);
alignmentSelector.addCandidateAlignment(MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::heapStandard2MB);
}
const size_t customAlignment = static_cast<size_t>(debugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.get());
if (customAlignment > 0) {
const auto heapIndex = customAlignment >= MemoryConstants::pageSize2M ? HeapIndex::HEAP_STANDARD2MB : HeapIndex::HEAP_STANDARD64KB;
const auto heapIndex = customAlignment >= MemoryConstants::pageSize2M ? HeapIndex::heapStandard2MB : HeapIndex::heapStandard64KB;
alignmentSelector.addCandidateAlignment(customAlignment, true, AlignmentSelector::anyWastage, heapIndex);
}
@@ -121,7 +121,7 @@ BufferObject *DrmMemoryManager::createRootDeviceBufferObject(uint32_t rootDevice
if (bo) {
if (isLimitedRange(rootDeviceIndex)) {
auto boSize = bo->peekSize();
bo->setAddress(acquireGpuRange(boSize, rootDeviceIndex, HeapIndex::HEAP_STANDARD));
bo->setAddress(acquireGpuRange(boSize, rootDeviceIndex, HeapIndex::heapStandard));
UNRECOVERABLE_IF(boSize < bo->peekSize());
}
} else {
@@ -353,7 +353,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryWithAlignmentImpl(const A
// if limitedRangeAlloction is enabled, memory allocation for bo in the limited Range heap is required
if ((isLimitedRange(allocationData.rootDeviceIndex) || svmCpuAllocation) && !allocationData.flags.isUSMHostAllocation) {
gpuReservationAddress = acquireGpuRange(alignedVirtualAddressRangeSize, allocationData.rootDeviceIndex, HeapIndex::HEAP_STANDARD);
gpuReservationAddress = acquireGpuRange(alignedVirtualAddressRangeSize, allocationData.rootDeviceIndex, HeapIndex::heapStandard);
if (!gpuReservationAddress) {
return nullptr;
}
@@ -435,7 +435,7 @@ GraphicsAllocation *DrmMemoryManager::allocateUSMHostGraphicsMemory(const Alloca
uint64_t gpuAddress = 0;
auto svmCpuAllocation = allocationData.type == AllocationType::svmCpu;
if (isLimitedRange(allocationData.rootDeviceIndex) || svmCpuAllocation) {
gpuAddress = acquireGpuRange(cSize, allocationData.rootDeviceIndex, HeapIndex::HEAP_STANDARD);
gpuAddress = acquireGpuRange(cSize, allocationData.rootDeviceIndex, HeapIndex::heapStandard);
if (!gpuAddress) {
return nullptr;
}
@@ -519,7 +519,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(con
auto rootDeviceIndex = allocationData.rootDeviceIndex;
alignedSize = alignUp(alignedSize, MemoryConstants::pageSize2M);
auto gpuVirtualAddress = acquireGpuRangeWithCustomAlignment(alignedSize, rootDeviceIndex, HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize2M);
auto gpuVirtualAddress = acquireGpuRangeWithCustomAlignment(alignedSize, rootDeviceIndex, HeapIndex::heapStandard, MemoryConstants::pageSize2M);
if (!gpuVirtualAddress) {
return nullptr;
}
@@ -629,7 +629,7 @@ GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData &
auto gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr,
allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, productHelper), systemMemoryStorageInfo, gmmRequirements);
size_t bufferSize = allocationData.size;
uint64_t gpuRange = acquireGpuRangeWithCustomAlignment(bufferSize, allocationData.rootDeviceIndex, HeapIndex::HEAP_STANDARD64KB, allocationData.alignment);
uint64_t gpuRange = acquireGpuRangeWithCustomAlignment(bufferSize, allocationData.rootDeviceIndex, HeapIndex::heapStandard64KB, allocationData.alignment);
auto &drm = getDrm(allocationData.rootDeviceIndex);
auto ioctlHelper = drm.getIoctlHelper();
@@ -665,7 +665,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A
const auto memoryPool = MemoryPool::SystemCpuInaccessible;
uint64_t gpuRange = acquireGpuRange(allocationData.imgInfo->size, allocationData.rootDeviceIndex, HeapIndex::HEAP_STANDARD);
uint64_t gpuRange = acquireGpuRange(allocationData.imgInfo->size, allocationData.rootDeviceIndex, HeapIndex::heapStandard);
auto &drm = this->getDrm(allocationData.rootDeviceIndex);
auto ioctlHelper = drm.getIoctlHelper();
@@ -845,8 +845,8 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromMultipleShared
gpuRange = reinterpret_cast<uint64_t>(mapPointer);
} else {
auto gfxPartition = getGfxPartition(properties.rootDeviceIndex);
auto prefer57bitAddressing = (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0);
auto heapIndex = prefer57bitAddressing ? HeapIndex::HEAP_EXTENDED : HeapIndex::HEAP_STANDARD2MB;
auto prefer57bitAddressing = (gfxPartition->getHeapLimit(HeapIndex::heapExtended) > 0);
auto heapIndex = prefer57bitAddressing ? HeapIndex::heapExtended : HeapIndex::heapStandard2MB;
gpuRange = acquireGpuRange(totalSize, properties.rootDeviceIndex, heapIndex);
}
@@ -998,20 +998,20 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
auto getHeapIndex = [&] {
if (requireSpecificBitness && this->force32bitAllocations) {
return HeapIndex::HEAP_EXTERNAL;
return HeapIndex::heapExternal;
}
auto gfxPartition = getGfxPartition(properties.rootDeviceIndex);
auto prefer57bitAddressing = (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0);
auto prefer57bitAddressing = (gfxPartition->getHeapLimit(HeapIndex::heapExtended) > 0);
if (prefer57bitAddressing) {
return HeapIndex::HEAP_EXTENDED;
return HeapIndex::heapExtended;
}
if (isLocalMemorySupported(properties.rootDeviceIndex)) {
return HeapIndex::HEAP_STANDARD2MB;
return HeapIndex::heapStandard2MB;
}
return HeapIndex::HEAP_STANDARD;
return HeapIndex::heapStandard;
};
if (mapPointer) {
@@ -1374,7 +1374,7 @@ size_t DrmMemoryManager::selectAlignmentAndHeap(size_t size, HeapIndex *heap) {
// If all devices can support HEAP EXTENDED, then that heap is used, otherwise the HEAP based on the size is used.
for (auto rootDeviceIndex = 0u; rootDeviceIndex < rootDeviceCount; rootDeviceIndex++) {
auto gfxPartition = getGfxPartition(rootDeviceIndex);
if (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0) {
if (gfxPartition->getHeapLimit(HeapIndex::heapExtended) > 0) {
auto alignSize = size >= 8 * MemoryConstants::gigaByte && Math::isPow2(size);
if (debugManager.flags.UseHighAlignmentForHeapExtended.get() != -1) {
alignSize = !!debugManager.flags.UseHighAlignmentForHeapExtended.get();
@@ -1384,7 +1384,7 @@ size_t DrmMemoryManager::selectAlignmentAndHeap(size_t size, HeapIndex *heap) {
pageSizeAlignment = Math::prevPowerOfTwo(size);
}
*heap = HeapIndex::HEAP_EXTENDED;
*heap = HeapIndex::heapExtended;
} else {
pageSizeAlignment = alignmentBase.alignment;
*heap = alignmentBase.heap;
@@ -1395,14 +1395,14 @@ size_t DrmMemoryManager::selectAlignmentAndHeap(size_t size, HeapIndex *heap) {
}
AddressRange DrmMemoryManager::reserveGpuAddress(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) {
return reserveGpuAddressOnHeap(requiredStartAddress, size, rootDeviceIndices, reservedOnRootDeviceIndex, HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
return reserveGpuAddressOnHeap(requiredStartAddress, size, rootDeviceIndices, reservedOnRootDeviceIndex, HeapIndex::heapStandard, MemoryConstants::pageSize64k);
}
AddressRange DrmMemoryManager::reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) {
uint64_t gpuVa = 0u;
*reservedOnRootDeviceIndex = 0;
for (auto rootDeviceIndex : rootDeviceIndices) {
if (heap == HeapIndex::HEAP_EXTENDED) {
if (heap == HeapIndex::heapExtended) {
gpuVa = acquireGpuRangeWithCustomAlignment(size, rootDeviceIndex, heap, alignment);
} else {
gpuVa = acquireGpuRange(size, rootDeviceIndex, heap);
@@ -1649,13 +1649,13 @@ AllocationStatus getGpuAddress(const AlignmentSelector &alignmentSelector, HeapA
break;
default:
if (heapAssigner.useExternal32BitHeap(allocType)) {
auto heapIndex = allocationData.flags.use32BitFrontWindow ? HeapAssigner::mapExternalWindowIndex(HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY) : HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY;
auto heapIndex = allocationData.flags.use32BitFrontWindow ? HeapAssigner::mapExternalWindowIndex(HeapIndex::heapExternalDeviceMemory) : HeapIndex::heapExternalDeviceMemory;
gpuAddress = gmmHelper->canonize(gfxPartition->heapAllocateWithCustomAlignment(heapIndex, sizeAllocated, std::max(allocationData.alignment, MemoryConstants::pageSize64k)));
break;
}
AlignmentSelector::CandidateAlignment alignment = alignmentSelector.selectAlignment(sizeAllocated);
if (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0 && !allocationData.flags.resource48Bit) {
if (gfxPartition->getHeapLimit(HeapIndex::heapExtended) > 0 && !allocationData.flags.resource48Bit) {
auto alignSize = sizeAllocated >= 8 * MemoryConstants::gigaByte && Math::isPow2(sizeAllocated);
if (debugManager.flags.UseHighAlignmentForHeapExtended.get() != -1) {
alignSize = !!debugManager.flags.UseHighAlignmentForHeapExtended.get();
@@ -1665,7 +1665,7 @@ AllocationStatus getGpuAddress(const AlignmentSelector &alignmentSelector, HeapA
alignment.alignment = Math::prevPowerOfTwo(sizeAllocated);
}
alignment.heap = HeapIndex::HEAP_EXTENDED;
alignment.heap = HeapIndex::heapExtended;
}
if (alignment.alignment < allocationData.alignment) {
alignment.alignment = allocationData.alignment;
@@ -2139,9 +2139,9 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
uint64_t preferredAddress = 0;
auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex);
auto canAllocateInHeapExtended = debugManager.flags.AllocateHostAllocationsInHeapExtendedHost.get();
if (canAllocateInHeapExtended && allocationData.flags.isUSMHostAllocation && gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED_HOST) > 0u) {
if (canAllocateInHeapExtended && allocationData.flags.isUSMHostAllocation && gfxPartition->getHeapLimit(HeapIndex::heapExtendedHost) > 0u) {
preferredAddress = acquireGpuRange(totalSizeToAlloc, allocationData.rootDeviceIndex, HeapIndex::HEAP_EXTENDED_HOST);
preferredAddress = acquireGpuRange(totalSizeToAlloc, allocationData.rootDeviceIndex, HeapIndex::heapExtendedHost);
}
auto cpuPointer = this->mmapFunction(reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, PROT_NONE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
@@ -2293,8 +2293,8 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
uint64_t preferredAddress = 0;
auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex);
auto canAllocateInHeapExtended = debugManager.flags.AllocateSharedAllocationsInHeapExtendedHost.get();
if (canAllocateInHeapExtended && gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED_HOST) > 0u && !allocationData.flags.resource48Bit) {
preferredAddress = acquireGpuRange(totalSizeToAlloc, allocationData.rootDeviceIndex, HeapIndex::HEAP_EXTENDED_HOST);
if (canAllocateInHeapExtended && gfxPartition->getHeapLimit(HeapIndex::heapExtendedHost) > 0u && !allocationData.flags.resource48Bit) {
preferredAddress = acquireGpuRange(totalSizeToAlloc, allocationData.rootDeviceIndex, HeapIndex::heapExtendedHost);
}
auto cpuPointer = this->mmapFunction(reinterpret_cast<void *>(preferredAddress), totalSizeToAlloc, PROT_NONE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);

View File

@@ -35,7 +35,7 @@ DrmAllocation *DrmMemoryManager::createMultiHostAllocation(const AllocationData
auto gpuAddress = allocationData.gpuAddress;
bool addressReserved = false;
if (gpuAddress == 0) {
gpuAddress = acquireGpuRange(sizePerTile, allocationData.rootDeviceIndex, HeapIndex::HEAP_STANDARD);
gpuAddress = acquireGpuRange(sizePerTile, allocationData.rootDeviceIndex, HeapIndex::heapStandard);
addressReserved = true;
} else {
gpuAddress = allocationData.gpuAddress;

View File

@@ -1164,16 +1164,16 @@ bool Wddm::isGpuHangDetected(OsContext &osContext) {
void Wddm::initGfxPartition(GfxPartition &outGfxPartition, uint32_t rootDeviceIndex, size_t numRootDevices, bool useExternalFrontWindowPool) const {
if (gfxPartition.SVM.Limit != 0) {
outGfxPartition.heapInit(HeapIndex::HEAP_SVM, gfxPartition.SVM.Base, gfxPartition.SVM.Limit - gfxPartition.SVM.Base + 1);
outGfxPartition.heapInit(HeapIndex::heapSvm, gfxPartition.SVM.Base, gfxPartition.SVM.Limit - gfxPartition.SVM.Base + 1);
} else if (is32bit) {
outGfxPartition.heapInit(HeapIndex::HEAP_SVM, 0x0ull, 4 * MemoryConstants::gigaByte);
outGfxPartition.heapInit(HeapIndex::heapSvm, 0x0ull, 4 * MemoryConstants::gigaByte);
}
outGfxPartition.heapInit(HeapIndex::HEAP_STANDARD, gfxPartition.Standard.Base, gfxPartition.Standard.Limit - gfxPartition.Standard.Base + 1);
outGfxPartition.heapInit(HeapIndex::heapStandard, gfxPartition.Standard.Base, gfxPartition.Standard.Limit - gfxPartition.Standard.Base + 1);
// Split HEAP_STANDARD64K among root devices
auto gfxStandard64KBSize = alignDown((gfxPartition.Standard64KB.Limit - gfxPartition.Standard64KB.Base + 1) / numRootDevices, GfxPartition::heapGranularity);
outGfxPartition.heapInit(HeapIndex::HEAP_STANDARD64KB, gfxPartition.Standard64KB.Base + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize);
outGfxPartition.heapInit(HeapIndex::heapStandard64KB, gfxPartition.Standard64KB.Base + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize);
for (auto heap : GfxPartition::heap32Names) {
if (useExternalFrontWindowPool && HeapAssigner::heapTypeExternalWithFrontWindowPool(heap)) {

View File

@@ -93,7 +93,7 @@ void WddmMemoryManager::unMapPhysicalToVirtualMemory(GraphicsAllocation *physica
wddm->freeGpuVirtualAddress(gpuRange, bufferSize);
auto gfxPartition = getGfxPartition(rootDeviceIndex);
uint64_t reservedAddress = 0u;
auto status = wddm->reserveGpuVirtualAddress(gpuRange, gfxPartition->getHeapMinimalAddress(HeapIndex::HEAP_STANDARD64KB), gfxPartition->getHeapLimit(HeapIndex::HEAP_STANDARD64KB), bufferSize, &reservedAddress);
auto status = wddm->reserveGpuVirtualAddress(gpuRange, gfxPartition->getHeapMinimalAddress(HeapIndex::heapStandard64KB), gfxPartition->getHeapLimit(HeapIndex::heapStandard64KB), bufferSize, &reservedAddress);
UNRECOVERABLE_IF(status != STATUS_SUCCESS);
physicalAllocation->setCpuPtrAndGpuAddress(nullptr, 0u);
physicalAllocation->setReservedAddressRange(nullptr, 0u);
@@ -957,12 +957,12 @@ bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation, void *r
size_t WddmMemoryManager::selectAlignmentAndHeap(size_t size, HeapIndex *heap) {
AlignmentSelector::CandidateAlignment alignment = alignmentSelector.selectAlignment(size);
*heap = HeapIndex::HEAP_STANDARD64KB;
*heap = HeapIndex::heapStandard64KB;
return alignment.alignment;
}
AddressRange WddmMemoryManager::reserveGpuAddress(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) {
return reserveGpuAddressOnHeap(requiredStartAddress, size, rootDeviceIndices, reservedOnRootDeviceIndex, HeapIndex::HEAP_STANDARD64KB, MemoryConstants::pageSize64k);
return reserveGpuAddressOnHeap(requiredStartAddress, size, rootDeviceIndices, reservedOnRootDeviceIndex, HeapIndex::heapStandard64KB, MemoryConstants::pageSize64k);
}
AddressRange WddmMemoryManager::reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) {
@@ -1039,7 +1039,7 @@ bool WddmMemoryManager::mapMultiHandleAllocationWithRetry(WddmAllocation *alloca
auto alignedSize = allocation->getAlignedSize();
uint64_t addressToMap = 0;
HeapIndex heapIndex = preferredGpuVirtualAddress ? HeapIndex::HEAP_SVM : HeapIndex::HEAP_STANDARD64KB;
HeapIndex heapIndex = preferredGpuVirtualAddress ? HeapIndex::heapSvm : HeapIndex::heapStandard64KB;
if (preferredGpuVirtualAddress) {
addressToMap = castToUint64(preferredGpuVirtualAddress);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2021 Intel Corporation
* Copyright (C) 2019-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -9,12 +9,12 @@
using namespace NEO;
std::array<HeapIndex, static_cast<uint32_t>(HeapIndex::TOTAL_HEAPS)>
MockGfxPartition::allHeapNames{{HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_INTERNAL,
HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_EXTERNAL,
HeapIndex::HEAP_STANDARD,
HeapIndex::HEAP_STANDARD64KB,
HeapIndex::HEAP_STANDARD2MB,
HeapIndex::HEAP_SVM}};
std::array<HeapIndex, static_cast<uint32_t>(HeapIndex::totalHeaps)>
MockGfxPartition::allHeapNames{{HeapIndex::heapInternalDeviceMemory,
HeapIndex::heapInternal,
HeapIndex::heapExternalDeviceMemory,
HeapIndex::heapExternal,
HeapIndex::heapStandard,
HeapIndex::heapStandard64KB,
HeapIndex::heapStandard2MB,
HeapIndex::heapSvm}};

View File

@@ -74,11 +74,11 @@ class MockGfxPartition : public GfxPartition {
uint32_t freeGpuAddressRangeCalled = 0u;
bool callBasefreeGpuAddressRange = false;
static std::array<HeapIndex, static_cast<uint32_t>(HeapIndex::TOTAL_HEAPS)> allHeapNames;
static std::array<HeapIndex, static_cast<uint32_t>(HeapIndex::totalHeaps)> allHeapNames;
OSMemory::ReservedCpuAddressRange reservedCpuAddressRange;
bool callHeapAllocate = true;
HeapIndex heapAllocateIndex = HeapIndex::TOTAL_HEAPS;
HeapIndex heapAllocateIndex = HeapIndex::totalHeaps;
const uint64_t mockGpuVa = std::numeric_limits<uint64_t>::max();
uint64_t heapFreePtr = 0;
};

View File

@@ -463,7 +463,7 @@ TEST_F(DeviceGetCapsTest, givenFlagEnabled64kbPagesWhenCallConstructorMemoryMana
return {};
}
size_t selectAlignmentAndHeap(size_t size, HeapIndex *heap) override {
*heap = HeapIndex::HEAP_STANDARD;
*heap = HeapIndex::heapStandard;
return MemoryConstants::pageSize64k;
}
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override{};

View File

@@ -27,15 +27,15 @@ HWTEST_F(AlocationHelperTests, givenKernelIsaTypeWhenUse32BitHeapCalledThenTrueR
HWTEST_F(AlocationHelperTests, givenKernelIsaTypeWhenUseIternalAllocatorThenUseHeapInternal) {
auto heapIndex = heapAssigner.get32BitHeapIndex(AllocationType::kernelIsa, true, *defaultHwInfo, false);
EXPECT_EQ(heapIndex, NEO::HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
EXPECT_EQ(heapIndex, NEO::HeapIndex::heapInternalDeviceMemory);
heapIndex = heapAssigner.get32BitHeapIndex(AllocationType::kernelIsaInternal, true, *defaultHwInfo, false);
EXPECT_EQ(heapIndex, NEO::HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
EXPECT_EQ(heapIndex, NEO::HeapIndex::heapInternalDeviceMemory);
}
HWTEST_F(AlocationHelperTests, givenNotInternalTypeWhenUseIternalAllocatorThenUseHeapExternal) {
auto heapIndex = heapAssigner.get32BitHeapIndex(AllocationType::linearStream, true, *defaultHwInfo, false);
EXPECT_EQ(heapIndex, NEO::HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY);
EXPECT_EQ(heapIndex, NEO::HeapIndex::heapExternalDeviceMemory);
}
HWTEST_F(AlocationHelperTests, givenKernelIsaTypesWhenUseInternalAllocatorCalledThenTrueReturned) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -12,31 +12,31 @@
using namespace NEO;
TEST(HeapAssigner, givenInternalHeapIndexWhenMappingToInternalFrontWindowThenInternalFrontWindowReturned) {
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW, HeapAssigner::mapInternalWindowIndex(HeapIndex::HEAP_INTERNAL));
EXPECT_EQ(HeapIndex::heapInternalFrontWindow, HeapAssigner::mapInternalWindowIndex(HeapIndex::heapInternal));
}
TEST(HeapAssigner, givenInternalDeviceHeapIndexWhenMappingToInternalFrontWindowThenInternalDeviceFrontWindowReturned) {
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW, HeapAssigner::mapInternalWindowIndex(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
EXPECT_EQ(HeapIndex::heapInternalDeviceFrontWindow, HeapAssigner::mapInternalWindowIndex(HeapIndex::heapInternalDeviceMemory));
}
TEST(HeapAssigner, givenOtherThanInternalHeapIndexWhenMappingToInternalFrontWindowThenAbortIsThrown) {
EXPECT_THROW(HeapAssigner::mapInternalWindowIndex(HeapIndex::HEAP_STANDARD), std::exception);
EXPECT_THROW(HeapAssigner::mapInternalWindowIndex(HeapIndex::heapStandard), std::exception);
}
TEST(HeapAssigner, givenInternalHeapIndexWhenCheckingIsInternalHeapThenTrueIsReturned) {
EXPECT_TRUE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL));
EXPECT_TRUE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
EXPECT_TRUE(HeapAssigner::isInternalHeap(HeapIndex::heapInternal));
EXPECT_TRUE(HeapAssigner::isInternalHeap(HeapIndex::heapInternalDeviceMemory));
}
TEST(HeapAssigner, givenNonInternalHeapIndexWhenCheckingIsInternalHeapThenFalseIsReturned) {
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL_DEVICE_FRONT_WINDOW));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_STANDARD));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_STANDARD64KB));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_SVM));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTENDED));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapExternal));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapExternalDeviceMemory));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapExternalFrontWindow));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapExternalDeviceFrontWindow));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapInternalFrontWindow));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapInternalDeviceFrontWindow));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapStandard));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapStandard64KB));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapSvm));
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::heapExtended));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
* Copyright (C) 2019-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -84,18 +84,18 @@ TEST(AlignmentSelectorTests, givenMaxWastageThresholdWhenSelectingAlignmentThenR
TEST(AlignmentSelectorTests, givenCandidateArgumentHeapNotProvidedWhenSelectingAlignmentThenDefaultToUnknownHeap) {
AlignmentSelector selector{};
selector.addCandidateAlignment(1, false, AlignmentSelector::anyWastage);
EXPECT_EQ(HeapIndex::TOTAL_HEAPS, selector.selectAlignment(1).heap);
EXPECT_EQ(HeapIndex::totalHeaps, selector.selectAlignment(1).heap);
}
TEST(AlignmentSelectorTests, givenCandidateArgumentHeapProvidedWhenSelectingAlignmentThenReturnTheHeap) {
AlignmentSelector selector{};
selector.addCandidateAlignment(1, false, AlignmentSelector::anyWastage, HeapIndex::HEAP_INTERNAL);
selector.addCandidateAlignment(16, false, AlignmentSelector::anyWastage, HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY);
selector.addCandidateAlignment(32, false, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD2MB);
selector.addCandidateAlignment(1, false, AlignmentSelector::anyWastage, HeapIndex::heapInternal);
selector.addCandidateAlignment(16, false, AlignmentSelector::anyWastage, HeapIndex::heapExternalDeviceMemory);
selector.addCandidateAlignment(32, false, AlignmentSelector::anyWastage, HeapIndex::heapStandard2MB);
EXPECT_EQ(HeapIndex::HEAP_INTERNAL, selector.selectAlignment(1).heap);
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY, selector.selectAlignment(16).heap);
EXPECT_EQ(HeapIndex::HEAP_STANDARD2MB, selector.selectAlignment(32).heap);
EXPECT_EQ(HeapIndex::heapInternal, selector.selectAlignment(1).heap);
EXPECT_EQ(HeapIndex::heapExternalDeviceMemory, selector.selectAlignment(16).heap);
EXPECT_EQ(HeapIndex::heapStandard2MB, selector.selectAlignment(32).heap);
}
} // namespace NEO

View File

@@ -69,13 +69,13 @@ constexpr uint64_t sizeHeap32 = 4 * MemoryConstants::gigaByte;
void testGfxPartition(MockGfxPartition &gfxPartition, uint64_t gfxBase, uint64_t gfxTop, uint64_t svmTop) {
if (svmTop) {
// SVM should be initialized
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::HEAP_SVM));
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::HEAP_SVM), 0ull);
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::HEAP_SVM), svmTop);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::HEAP_SVM), svmTop - 1);
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::heapSvm));
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::heapSvm), 0ull);
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::heapSvm), svmTop);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::heapSvm), svmTop - 1);
} else {
// Limited range
EXPECT_FALSE(gfxPartition.heapInitialized(HeapIndex::HEAP_SVM));
EXPECT_FALSE(gfxPartition.heapInitialized(HeapIndex::heapSvm));
}
for (auto heap32 : GfxPartition::heap32Names) {
@@ -86,31 +86,31 @@ void testGfxPartition(MockGfxPartition &gfxPartition, uint64_t gfxBase, uint64_t
gfxBase += sizeHeap32;
}
constexpr uint32_t numStandardHeaps = static_cast<uint32_t>(HeapIndex::HEAP_STANDARD2MB) - static_cast<uint32_t>(HeapIndex::HEAP_STANDARD) + 1;
constexpr uint32_t numStandardHeaps = static_cast<uint32_t>(HeapIndex::heapStandard2MB) - static_cast<uint32_t>(HeapIndex::heapStandard) + 1;
constexpr uint64_t maxStandardHeapGranularity = std::max(GfxPartition::heapGranularity, GfxPartition::heapGranularity2MB);
gfxBase = alignUp(gfxBase, maxStandardHeapGranularity);
uint64_t maxStandardHeapSize = alignDown((gfxTop - gfxBase) / numStandardHeaps, maxStandardHeapGranularity);
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::HEAP_STANDARD));
auto heapStandardBase = gfxPartition.getHeapBase(HeapIndex::HEAP_STANDARD);
auto heapStandardSize = gfxPartition.getHeapSize(HeapIndex::HEAP_STANDARD);
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::heapStandard));
auto heapStandardBase = gfxPartition.getHeapBase(HeapIndex::heapStandard);
auto heapStandardSize = gfxPartition.getHeapSize(HeapIndex::heapStandard);
EXPECT_TRUE(isAligned<GfxPartition::heapGranularity>(heapStandardBase));
EXPECT_EQ(heapStandardBase, gfxBase);
EXPECT_EQ(heapStandardSize, maxStandardHeapSize);
gfxBase += maxStandardHeapSize;
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::HEAP_STANDARD64KB));
auto heapStandard64KbBase = gfxPartition.getHeapBase(HeapIndex::HEAP_STANDARD64KB);
auto heapStandard64KbSize = gfxPartition.getHeapSize(HeapIndex::HEAP_STANDARD64KB);
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::heapStandard64KB));
auto heapStandard64KbBase = gfxPartition.getHeapBase(HeapIndex::heapStandard64KB);
auto heapStandard64KbSize = gfxPartition.getHeapSize(HeapIndex::heapStandard64KB);
EXPECT_TRUE(isAligned<GfxPartition::heapGranularity>(heapStandard64KbBase));
EXPECT_EQ(heapStandard64KbBase, heapStandardBase + heapStandardSize);
EXPECT_EQ(heapStandard64KbSize, heapStandardSize);
gfxBase += maxStandardHeapSize;
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::HEAP_STANDARD2MB));
auto heapStandard2MbBase = gfxPartition.getHeapBase(HeapIndex::HEAP_STANDARD2MB);
auto heapStandard2MbSize = gfxPartition.getHeapSize(HeapIndex::HEAP_STANDARD2MB);
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::heapStandard2MB));
auto heapStandard2MbBase = gfxPartition.getHeapBase(HeapIndex::heapStandard2MB);
auto heapStandard2MbSize = gfxPartition.getHeapSize(HeapIndex::heapStandard2MB);
EXPECT_TRUE(isAligned<GfxPartition::heapGranularity>(heapStandard2MbBase));
EXPECT_EQ(heapStandard2MbBase, heapStandard64KbBase + heapStandard64KbSize);
EXPECT_EQ(heapStandard2MbSize, heapStandard64KbSize);
@@ -118,21 +118,21 @@ void testGfxPartition(MockGfxPartition &gfxPartition, uint64_t gfxBase, uint64_t
EXPECT_LE(heapStandard2MbBase + heapStandard2MbSize, gfxTop);
EXPECT_LE(gfxBase + maxStandardHeapSize, gfxTop);
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternalFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternalFrontWindow));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternalDeviceFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceFrontWindow));
size_t sizeSmall = MemoryConstants::pageSize;
size_t sizeBig = 4 * MemoryConstants::megaByte + MemoryConstants::pageSize;
for (auto heap : MockGfxPartition::allHeapNames) {
if (!gfxPartition.heapInitialized(heap)) {
EXPECT_TRUE(heap == HeapIndex::HEAP_SVM || heap == HeapIndex::HEAP_EXTENDED);
EXPECT_TRUE(heap == HeapIndex::heapSvm || heap == HeapIndex::heapExtended);
continue;
}
const bool isInternalHeapType = heap == HeapIndex::HEAP_INTERNAL || heap == HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY;
const auto heapGranularity = (heap == HeapIndex::HEAP_STANDARD2MB) ? GfxPartition::heapGranularity2MB : GfxPartition::heapGranularity;
const bool isInternalHeapType = heap == HeapIndex::heapInternal || heap == HeapIndex::heapInternalDeviceMemory;
const auto heapGranularity = (heap == HeapIndex::heapStandard2MB) ? GfxPartition::heapGranularity2MB : GfxPartition::heapGranularity;
if (heap == HeapIndex::HEAP_SVM) {
if (heap == HeapIndex::heapSvm) {
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(heap), gfxPartition.getHeapBase(heap));
} else if (isInternalHeapType) {
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(heap), gfxPartition.getHeapBase(heap) + GfxPartition::internalFrontWindowPoolSize);
@@ -223,13 +223,13 @@ TEST(GfxPartitionTest, GivenFullRange48BitSvmHeap64KbSplitWhenTestingGfxPartitio
uint64_t gfxBase = is32bit ? MemoryConstants::maxSvmAddress + 1 : maxNBitValue(48 - 1) + 1;
uint64_t gfxTop = maxNBitValue(48) + 1;
constexpr auto numStandardHeaps = static_cast<uint32_t>(HeapIndex::HEAP_STANDARD2MB) - static_cast<uint32_t>(HeapIndex::HEAP_STANDARD) + 1;
constexpr auto numStandardHeaps = static_cast<uint32_t>(HeapIndex::heapStandard2MB) - static_cast<uint32_t>(HeapIndex::heapStandard) + 1;
constexpr auto maxStandardHeapGranularity = std::max(GfxPartition::heapGranularity, GfxPartition::heapGranularity2MB);
auto maxStandardHeapSize = alignDown((gfxTop - gfxBase - 4 * sizeHeap32) / numStandardHeaps, maxStandardHeapGranularity);
auto heapStandard64KBSize = alignDown(maxStandardHeapSize / numRootDevices, GfxPartition::heapGranularity);
EXPECT_EQ(heapStandard64KBSize, gfxPartition.getHeapSize(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(gfxBase + 4 * sizeHeap32 + maxStandardHeapSize + rootDeviceIndex * heapStandard64KBSize, gfxPartition.getHeapBase(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(heapStandard64KBSize, gfxPartition.getHeapSize(HeapIndex::heapStandard64KB));
EXPECT_EQ(gfxBase + 4 * sizeHeap32 + maxStandardHeapSize + rootDeviceIndex * heapStandard64KBSize, gfxPartition.getHeapBase(HeapIndex::heapStandard64KB));
}
TEST(GfxPartitionTest, GivenFullRange47BitSvmHeap64KbSplitWhenTestingGfxPartitionThenAllExpectationsAreMet) {
@@ -242,14 +242,14 @@ TEST(GfxPartitionTest, GivenFullRange47BitSvmHeap64KbSplitWhenTestingGfxPartitio
uint64_t gfxBase = is32bit ? MemoryConstants::maxSvmAddress + 1 : (uint64_t)gfxPartition.getReservedCpuAddressRange();
uint64_t gfxTop = is32bit ? maxNBitValue(47) + 1 : gfxBase + gfxPartition.getReservedCpuAddressRangeSize();
constexpr auto numStandardHeaps = static_cast<uint32_t>(HeapIndex::HEAP_STANDARD2MB) - static_cast<uint32_t>(HeapIndex::HEAP_STANDARD) + 1;
constexpr auto numStandardHeaps = static_cast<uint32_t>(HeapIndex::heapStandard2MB) - static_cast<uint32_t>(HeapIndex::heapStandard) + 1;
constexpr auto maxStandardHeapGranularity = std::max(GfxPartition::heapGranularity, GfxPartition::heapGranularity2MB);
gfxBase = alignUp(gfxBase, maxStandardHeapGranularity);
auto maxStandardHeapSize = alignDown((gfxTop - gfxBase - 4 * sizeHeap32) / numStandardHeaps, maxStandardHeapGranularity);
auto heapStandard64KBSize = alignDown(maxStandardHeapSize / numRootDevices, GfxPartition::heapGranularity);
EXPECT_EQ(heapStandard64KBSize, gfxPartition.getHeapSize(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(gfxBase + 4 * sizeHeap32 + maxStandardHeapSize + rootDeviceIndex * heapStandard64KBSize, gfxPartition.getHeapBase(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(heapStandard64KBSize, gfxPartition.getHeapSize(HeapIndex::heapStandard64KB));
EXPECT_EQ(gfxBase + 4 * sizeHeap32 + maxStandardHeapSize + rootDeviceIndex * heapStandard64KBSize, gfxPartition.getHeapBase(HeapIndex::heapStandard64KB));
}
class MockOsMemory : public OSMemory {
@@ -339,23 +339,23 @@ TEST(GfxPartitionTest, givenGfxPartitionWhenInitializedThenInternalFrontWindowHe
MockGfxPartition gfxPartition;
gfxPartition.init(maxNBitValue(48), reservedCpuAddressRangeSize, 0, 1, false, 0u);
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL));
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::heapInternalFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternal));
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceMemory));
auto frontWindowSize = GfxPartition::internalFrontWindowPoolSize;
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW), frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW), frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::heapInternalFrontWindow), frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::heapInternalDeviceFrontWindow), frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternalFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternalFrontWindow));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternalDeviceFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceFrontWindow));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL) + frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY) + frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternal), gfxPartition.getHeapBase(HeapIndex::heapInternal) + frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternalDeviceMemory), gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceMemory) + frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::HEAP_INTERNAL),
gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL) + gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL) - 1);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY),
gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY) + gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY) - 1);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::heapInternal),
gfxPartition.getHeapBase(HeapIndex::heapInternal) + gfxPartition.getHeapSize(HeapIndex::heapInternal) - 1);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::heapInternalDeviceMemory),
gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceMemory) + gfxPartition.getHeapSize(HeapIndex::heapInternalDeviceMemory) - 1);
}
TEST(GfxPartitionTest, givenInternalFrontWindowHeapWhenAllocatingSmallOrBigChunkThenAddressFromFrontIsReturned) {
@@ -363,10 +363,10 @@ TEST(GfxPartitionTest, givenInternalFrontWindowHeapWhenAllocatingSmallOrBigChunk
gfxPartition.init(maxNBitValue(48), reservedCpuAddressRangeSize, 0, 1, false, 0u);
const size_t sizeSmall = MemoryConstants::pageSize64k;
const size_t sizeBig = static_cast<size_t>(gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW)) - MemoryConstants::pageSize64k;
const size_t sizeBig = static_cast<size_t>(gfxPartition.getHeapSize(HeapIndex::heapInternalFrontWindow)) - MemoryConstants::pageSize64k;
HeapIndex heaps[] = {HeapIndex::HEAP_INTERNAL_FRONT_WINDOW,
HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW};
HeapIndex heaps[] = {HeapIndex::heapInternalFrontWindow,
HeapIndex::heapInternalDeviceFrontWindow};
for (int i = 0; i < 2; i++) {
size_t sizeToAlloc = sizeSmall;
@@ -390,8 +390,8 @@ TEST(GfxPartitionTest, givenInternalHeapWhenAllocatingSmallOrBigChunkThenAddress
const size_t sizeSmall = MemoryConstants::pageSize64k;
const size_t sizeBig = 4 * MemoryConstants::megaByte + MemoryConstants::pageSize64k;
HeapIndex heaps[] = {HeapIndex::HEAP_INTERNAL,
HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY};
HeapIndex heaps[] = {HeapIndex::heapInternal,
HeapIndex::heapInternalDeviceMemory};
for (int i = 0; i < 2; i++) {
size_t sizeToAlloc = sizeSmall;
@@ -449,14 +449,14 @@ TEST_P(GfxPartitionTestForAllHeapTypes, givenHeapIndexWhenFreeGpuAddressRangeIsC
INSTANTIATE_TEST_SUITE_P(
GfxPartitionTestForAllHeapTypesTests,
GfxPartitionTestForAllHeapTypes,
::testing::Values(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_INTERNAL,
HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_EXTERNAL,
HeapIndex::HEAP_STANDARD,
HeapIndex::HEAP_STANDARD64KB,
HeapIndex::HEAP_STANDARD2MB,
HeapIndex::HEAP_EXTENDED));
::testing::Values(HeapIndex::heapInternalDeviceMemory,
HeapIndex::heapInternal,
HeapIndex::heapExternalDeviceMemory,
HeapIndex::heapExternal,
HeapIndex::heapStandard,
HeapIndex::heapStandard64KB,
HeapIndex::heapStandard2MB,
HeapIndex::heapExtended));
struct GfxPartitionOn57bTest : public ::testing::TestWithParam<uint32_t> {
public:
@@ -520,8 +520,8 @@ struct GfxPartitionOn57bTest : public ::testing::TestWithParam<uint32_t> {
};
void verifyHeaps(uint64_t gfxBase, uint64_t gfxTop, uint64_t svmLimit, bool expectHeapExtendedInitialized) {
EXPECT_EQ(0u, gfxPartition->getHeapBase(HeapIndex::HEAP_SVM));
EXPECT_EQ(svmLimit, gfxPartition->getHeapLimit(HeapIndex::HEAP_SVM));
EXPECT_EQ(0u, gfxPartition->getHeapBase(HeapIndex::heapSvm));
EXPECT_EQ(svmLimit, gfxPartition->getHeapLimit(HeapIndex::heapSvm));
constexpr uint64_t gfxHeap32Size = 4 * MemoryConstants::gigaByte;
for (auto heap : GfxPartition::heap32Names) {
@@ -531,24 +531,24 @@ struct GfxPartitionOn57bTest : public ::testing::TestWithParam<uint32_t> {
gfxBase += gfxHeap32Size;
}
constexpr uint32_t numStandardHeaps = static_cast<uint32_t>(HeapIndex::HEAP_STANDARD2MB) - static_cast<uint32_t>(HeapIndex::HEAP_STANDARD) + 1;
constexpr uint32_t numStandardHeaps = static_cast<uint32_t>(HeapIndex::heapStandard2MB) - static_cast<uint32_t>(HeapIndex::heapStandard) + 1;
constexpr uint64_t maxStandardHeapGranularity = std::max(GfxPartition::heapGranularity, GfxPartition::heapGranularity2MB);
gfxBase = alignUp(gfxBase, maxStandardHeapGranularity);
uint64_t maxStandardHeapSize = alignDown((gfxTop - gfxBase) / numStandardHeaps, maxStandardHeapGranularity);
EXPECT_EQ(gfxBase, gfxPartition->getHeapBase(HeapIndex::HEAP_STANDARD));
EXPECT_EQ(gfxBase + maxStandardHeapSize - 1, gfxPartition->getHeapLimit(HeapIndex::HEAP_STANDARD));
EXPECT_EQ(gfxBase, gfxPartition->getHeapBase(HeapIndex::heapStandard));
EXPECT_EQ(gfxBase + maxStandardHeapSize - 1, gfxPartition->getHeapLimit(HeapIndex::heapStandard));
gfxBase += maxStandardHeapSize;
EXPECT_EQ(gfxBase, gfxPartition->getHeapBase(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(gfxBase + maxStandardHeapSize - 1, gfxPartition->getHeapLimit(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(gfxBase, gfxPartition->getHeapBase(HeapIndex::heapStandard64KB));
EXPECT_EQ(gfxBase + maxStandardHeapSize - 1, gfxPartition->getHeapLimit(HeapIndex::heapStandard64KB));
if (expectHeapExtendedInitialized) {
EXPECT_TRUE(gfxPartition->heapInitialized(HeapIndex::HEAP_EXTENDED));
EXPECT_TRUE(gfxPartition->heapInitialized(HeapIndex::heapExtended));
} else {
EXPECT_FALSE(gfxPartition->heapInitialized(HeapIndex::HEAP_EXTENDED));
EXPECT_FALSE(gfxPartition->heapInitialized(HeapIndex::heapExtended));
}
}
@@ -870,8 +870,8 @@ TEST(GfxPartitionTest, givenGpuAddressSpaceIs57BitAndSeveralRootDevicesThenHeapE
auto heapExtendedSize = 4 * systemMemorySize;
EXPECT_EQ(heapExtendedSize, gfxPartition.getHeapSize(HeapIndex::HEAP_EXTENDED_HOST));
EXPECT_LT(maxNBitValue(48), gfxPartition.getHeapBase(HeapIndex::HEAP_EXTENDED_HOST));
EXPECT_EQ(heapExtendedSize, gfxPartition.getHeapSize(HeapIndex::heapExtendedHost));
EXPECT_LT(maxNBitValue(48), gfxPartition.getHeapBase(HeapIndex::heapExtendedHost));
}
{
@@ -884,8 +884,8 @@ TEST(GfxPartitionTest, givenGpuAddressSpaceIs57BitAndSeveralRootDevicesThenHeapE
auto heapExtendedTotalSize = maxNBitValue(48) + 1;
auto heapExtendedSize = alignDown(heapExtendedTotalSize / numRootDevices, GfxPartition::heapGranularity);
EXPECT_EQ(heapExtendedSize, gfxPartition.getHeapSize(HeapIndex::HEAP_EXTENDED));
EXPECT_EQ(maxNBitValue(56) + 1 + rootDeviceIndex * heapExtendedSize, gfxPartition.getHeapBase(HeapIndex::HEAP_EXTENDED));
EXPECT_EQ(heapExtendedSize, gfxPartition.getHeapSize(HeapIndex::heapExtended));
EXPECT_EQ(maxNBitValue(56) + 1 + rootDeviceIndex * heapExtendedSize, gfxPartition.getHeapBase(HeapIndex::heapExtended));
}
{
@@ -898,33 +898,33 @@ TEST(GfxPartitionTest, givenGpuAddressSpaceIs57BitAndSeveralRootDevicesThenHeapE
auto heapExtendedTotalSize = maxNBitValue(48) + 1;
auto heapExtendedSize = alignDown(heapExtendedTotalSize / numRootDevices, GfxPartition::heapGranularity);
EXPECT_EQ(heapExtendedSize, gfxPartition.getHeapSize(HeapIndex::HEAP_EXTENDED));
EXPECT_EQ(maxNBitValue(56) + 1 + rootDeviceIndex * heapExtendedSize, gfxPartition.getHeapBase(HeapIndex::HEAP_EXTENDED));
EXPECT_EQ(heapExtendedSize, gfxPartition.getHeapSize(HeapIndex::heapExtended));
EXPECT_EQ(maxNBitValue(56) + 1 + rootDeviceIndex * heapExtendedSize, gfxPartition.getHeapBase(HeapIndex::heapExtended));
}
}
TEST(GfxPartitionTest, givenHeapIndexWhenCheckingIsAnyHeap32ThenTrueIsReturnedFor32BitHeapsOnly) {
HeapIndex heaps32[] = {HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_INTERNAL,
HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY,
HeapIndex::HEAP_EXTERNAL,
HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW,
HeapIndex::HEAP_EXTERNAL_DEVICE_FRONT_WINDOW,
HeapIndex::HEAP_INTERNAL_FRONT_WINDOW,
HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW};
HeapIndex heaps32[] = {HeapIndex::heapInternalDeviceMemory,
HeapIndex::heapInternal,
HeapIndex::heapExternalDeviceMemory,
HeapIndex::heapExternal,
HeapIndex::heapExternalFrontWindow,
HeapIndex::heapExternalDeviceFrontWindow,
HeapIndex::heapInternalFrontWindow,
HeapIndex::heapInternalDeviceFrontWindow};
for (size_t i = 0; i < sizeof(heaps32) / sizeof(heaps32[0]); i++) {
EXPECT_TRUE(GfxPartition::isAnyHeap32(heaps32[i]));
}
HeapIndex heapsOther[] = {
HeapIndex::HEAP_STANDARD,
HeapIndex::HEAP_STANDARD64KB,
HeapIndex::HEAP_STANDARD2MB,
HeapIndex::HEAP_SVM,
HeapIndex::HEAP_EXTENDED,
HeapIndex::HEAP_EXTENDED_HOST};
HeapIndex::heapStandard,
HeapIndex::heapStandard64KB,
HeapIndex::heapStandard2MB,
HeapIndex::heapSvm,
HeapIndex::heapExtended,
HeapIndex::heapExtendedHost};
for (size_t i = 0; i < sizeof(heapsOther) / sizeof(heapsOther[0]); i++) {
EXPECT_FALSE(GfxPartition::isAnyHeap32(heapsOther[i]));

View File

@@ -245,14 +245,14 @@ HWTEST_F(MemoryManagerTests, givenDefaultHwInfoWhenAllocatingDebugAreaThenHeapIn
auto &gfxCoreHelper = executionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>();
auto systemMemoryPlacement = gfxCoreHelper.useSystemMemoryPlacementForISA(*defaultHwInfo);
HeapIndex expectedHeap = HeapIndex::TOTAL_HEAPS;
HeapIndex baseHeap = HeapIndex::TOTAL_HEAPS;
HeapIndex expectedHeap = HeapIndex::totalHeaps;
HeapIndex baseHeap = HeapIndex::totalHeaps;
if (systemMemoryPlacement) {
expectedHeap = HeapIndex::HEAP_INTERNAL_FRONT_WINDOW;
baseHeap = HeapIndex::HEAP_INTERNAL;
expectedHeap = HeapIndex::heapInternalFrontWindow;
baseHeap = HeapIndex::heapInternal;
} else {
expectedHeap = HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW;
baseHeap = HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY;
expectedHeap = HeapIndex::heapInternalDeviceFrontWindow;
baseHeap = HeapIndex::heapInternalDeviceMemory;
}
auto moduleDebugArea = osAgnosticMemoryManager.allocateGraphicsMemoryWithProperties(properties);
auto gpuAddress = moduleDebugArea->getGpuAddress();
@@ -283,11 +283,11 @@ HWTEST2_F(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocatingDebugAreaThen
auto systemMemoryPlacement = gfxCoreHelper.useSystemMemoryPlacementForISA(hwInfo);
EXPECT_FALSE(systemMemoryPlacement);
HeapIndex expectedHeap = HeapIndex::TOTAL_HEAPS;
HeapIndex baseHeap = HeapIndex::TOTAL_HEAPS;
HeapIndex expectedHeap = HeapIndex::totalHeaps;
HeapIndex baseHeap = HeapIndex::totalHeaps;
expectedHeap = HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW;
baseHeap = HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY;
expectedHeap = HeapIndex::heapInternalDeviceFrontWindow;
baseHeap = HeapIndex::heapInternalDeviceMemory;
auto moduleDebugArea = osAgnosticMemoryManager.allocateGraphicsMemoryWithProperties(properties);
auto gpuAddress = moduleDebugArea->getGpuAddress();

View File

@@ -226,14 +226,14 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGpuAddressIsReserv
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 10;
auto gmmHelper = memoryManager.getGmmHelper(0);
HeapIndex heap = HeapIndex::HEAP_STANDARD64KB;
HeapIndex heap = HeapIndex::heapStandard64KB;
auto alignment = memoryManager.selectAlignmentAndHeap(MemoryConstants::pageSize, &heap);
EXPECT_EQ(heap, HeapIndex::HEAP_STANDARD);
EXPECT_EQ(heap, HeapIndex::heapStandard);
EXPECT_EQ(MemoryConstants::pageSize64k, alignment);
auto addressRange = memoryManager.reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, heap, alignment);
EXPECT_EQ(0u, rootDeviceIndexReserved);
EXPECT_LE(memoryManager.getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager.getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager.freeGpuAddress(addressRange, 0);
}
@@ -245,17 +245,17 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGpuAddressIsReserv
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 10;
auto gmmHelper = memoryManager.getGmmHelper(0);
auto addressRange = memoryManager.reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
auto addressRange = memoryManager.reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_EQ(0u, rootDeviceIndexReserved);
EXPECT_LE(memoryManager.getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager.getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager.freeGpuAddress(addressRange, 0);
addressRange = memoryManager.reserveGpuAddress(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_EQ(0u, rootDeviceIndexReserved);
EXPECT_LE(memoryManager.getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager.getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager.freeGpuAddress(addressRange, 0);
}
@@ -267,17 +267,17 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGpuAddressIsReserv
rootDeviceIndices.pushUnique(1);
uint32_t rootDeviceIndexReserved = 10;
auto gmmHelper = memoryManager.getGmmHelper(1);
auto addressRange = memoryManager.reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
auto addressRange = memoryManager.reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_EQ(1u, rootDeviceIndexReserved);
EXPECT_LE(memoryManager.getGfxPartition(1)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(1)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager.getGfxPartition(1)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(1)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager.freeGpuAddress(addressRange, 1);
addressRange = memoryManager.reserveGpuAddress(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_EQ(1u, rootDeviceIndexReserved);
EXPECT_LE(memoryManager.getGfxPartition(1)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(1)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager.getGfxPartition(1)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager.getGfxPartition(1)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager.freeGpuAddress(addressRange, 1);
}
@@ -289,10 +289,10 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGpuAddressReservat
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 10;
// emulate GPU address space exhaust
memoryManager.getGfxPartition(0)->heapInit(HeapIndex::HEAP_STANDARD, 0x0, 0x10000);
auto addressRange = memoryManager.reserveGpuAddressOnHeap(0ull, (size_t)(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD) * 2), rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
memoryManager.getGfxPartition(0)->heapInit(HeapIndex::heapStandard, 0x0, 0x10000);
auto addressRange = memoryManager.reserveGpuAddressOnHeap(0ull, (size_t)(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard) * 2), rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_EQ(static_cast<int>(addressRange.address), 0);
addressRange = memoryManager.reserveGpuAddress(0ull, (size_t)(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD) * 2), rootDeviceIndices, &rootDeviceIndexReserved);
addressRange = memoryManager.reserveGpuAddress(0ull, (size_t)(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard) * 2), rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_EQ(static_cast<int>(addressRange.address), 0);
}
@@ -302,7 +302,7 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGpuAddressReservat
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 10;
auto addressRange = memoryManager.reserveGpuAddressOnHeap(0x1234, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
auto addressRange = memoryManager.reserveGpuAddressOnHeap(0x1234, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_EQ(0u, rootDeviceIndexReserved);
EXPECT_NE(static_cast<int>(addressRange.address), 0x1234);
EXPECT_NE(static_cast<int>(addressRange.size), 0);
@@ -393,11 +393,11 @@ TEST(MemoryManagerTest, givenDebugVariableWhenCreatingMemoryManagerThenSetSuppor
}
TEST(MemoryManagerTest, givenLocalMemoryRequiredWhenSelectingHeapThenPickDeviceHeapIndex) {
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, MemoryManager::selectInternalHeap(true));
EXPECT_EQ(HeapIndex::HEAP_INTERNAL, MemoryManager::selectInternalHeap(false));
EXPECT_EQ(HeapIndex::heapInternalDeviceMemory, MemoryManager::selectInternalHeap(true));
EXPECT_EQ(HeapIndex::heapInternal, MemoryManager::selectInternalHeap(false));
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY, MemoryManager::selectExternalHeap(true));
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, MemoryManager::selectExternalHeap(false));
EXPECT_EQ(HeapIndex::heapExternalDeviceMemory, MemoryManager::selectExternalHeap(true));
EXPECT_EQ(HeapIndex::heapExternal, MemoryManager::selectExternalHeap(false));
}
TEST(MemoryManagerTest, whenCreatingAllocPropertiesForMultiStorageResourceThenMultiStorageResourcesFlagIsSetToTrue) {
@@ -1053,7 +1053,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAskedForNon32BitAllocationWh
auto gfxAllocation = memoryManager.allocateGraphicsMemoryWithAlignment(allocationData);
ASSERT_NE(gfxAllocation, nullptr);
EXPECT_EQ(gfxAllocation->getGpuBaseAddress(), 0ull);
EXPECT_EQ(gfxAllocation->getGpuAddress(), memoryManager.getGfxPartition(allocationData.rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD) + 1 - GfxPartition::heapGranularity - MemoryConstants::pageSize);
EXPECT_EQ(gfxAllocation->getGpuAddress(), memoryManager.getGfxPartition(allocationData.rootDeviceIndex)->getHeapLimit(HeapIndex::heapStandard) + 1 - GfxPartition::heapGranularity - MemoryConstants::pageSize);
memoryManager.freeGraphicsMemory(gfxAllocation);
}
@@ -2562,12 +2562,12 @@ TEST_F(HeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExtern
TEST_F(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenStandardHeapIsUsed) {
GraphicsAllocation allocation{0, AllocationType::unknown, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu};
EXPECT_EQ(HeapIndex::HEAP_STANDARD, memoryManager->selectHeap(&allocation, true, false, false));
EXPECT_EQ(HeapIndex::heapStandard, memoryManager->selectHeap(&allocation, true, false, false));
}
TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithPtrThenSvmHeapIsUsed) {
GraphicsAllocation allocation{0, AllocationType::unknown, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu};
EXPECT_EQ(HeapIndex::HEAP_SVM, memoryManager->selectHeap(&allocation, true, true, false));
EXPECT_EQ(HeapIndex::heapSvm, memoryManager->selectHeap(&allocation, true, true, false));
}
TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIs64KSuitableThenStandard64kHeapIsUsed) {
@@ -2580,7 +2580,7 @@ TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAlloca
auto resourceInfo = static_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get());
resourceInfo->is64KBPageSuitableValue = true;
allocation.setDefaultGmm(gmm.get());
EXPECT_EQ(HeapIndex::HEAP_STANDARD64KB, memoryManager->selectHeap(&allocation, false, true, false));
EXPECT_EQ(HeapIndex::heapStandard64KB, memoryManager->selectHeap(&allocation, false, true, false));
}
TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIsNot64KSuitableThenStandardHeapIsUsed) {
@@ -2593,28 +2593,28 @@ TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAlloca
auto resourceInfo = static_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get());
resourceInfo->is64KBPageSuitableValue = false;
allocation.setDefaultGmm(gmm.get());
EXPECT_EQ(HeapIndex::HEAP_STANDARD, memoryManager->selectHeap(&allocation, false, true, false));
EXPECT_EQ(HeapIndex::heapStandard, memoryManager->selectHeap(&allocation, false, true, false));
}
TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForNullAllocationWithoutPtrThenStandardHeapIsUsed) {
EXPECT_EQ(HeapIndex::HEAP_STANDARD, memoryManager->selectHeap(nullptr, false, true, false));
EXPECT_EQ(HeapIndex::heapStandard, memoryManager->selectHeap(nullptr, false, true, false));
}
TEST_F(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForNullAllocationWithoutPtrThenStandardHeapIsUsed) {
EXPECT_EQ(HeapIndex::HEAP_STANDARD, memoryManager->selectHeap(nullptr, false, false, false));
EXPECT_EQ(HeapIndex::heapStandard, memoryManager->selectHeap(nullptr, false, false, false));
}
TEST_F(HeapSelectorTest, givenDebugModuleAreaAllocationAndUseFrontWindowWhenSelectingHeapThenInternalFrontWindowHeapIsReturned) {
GraphicsAllocation allocation{0, AllocationType::debugModuleArea, nullptr, 0, 0, 0, MemoryPool::MemoryNull, 1};
allocation.set32BitAllocation(true);
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW, memoryManager->selectHeap(&allocation, false, false, true));
EXPECT_EQ(HeapIndex::heapInternalFrontWindow, memoryManager->selectHeap(&allocation, false, false, true));
}
TEST_F(HeapSelectorTest, givenDebugModuleAreaAllocationInLocalMemoryAndUseFrontWindowWhenSelectingHeapThenInternalDeviceFrontWindowHeapIsReturned) {
GraphicsAllocation allocation{0, AllocationType::debugModuleArea, nullptr, 0, 0, 0, MemoryPool::LocalMemory, 1};
allocation.set32BitAllocation(true);
EXPECT_TRUE(allocation.isAllocatedInLocalMemoryPool());
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW, memoryManager->selectHeap(&allocation, false, false, true));
EXPECT_EQ(HeapIndex::heapInternalDeviceFrontWindow, memoryManager->selectHeap(&allocation, false, false, true));
}
TEST(MemoryAllocationTest, givenAllocationTypeWhenPassedToMemoryAllocationConstructorThenAllocationTypeIsStored) {

View File

@@ -41,43 +41,43 @@ TEST_F(FrontWindowAllocatorTests, givenAllocateInFrontWindowPoolFlagWhenAllocate
}
TEST_F(FrontWindowAllocatorTests, givenInitializedHeapsWhenUseExternalAllocatorForSshAndDshEnabledThenExternalHeapHaveFrontWindowPool) {
EXPECT_NE(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW), 0u);
EXPECT_NE(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExternalFrontWindow), 0u);
}
TEST_F(FrontWindowAllocatorTests, givenInitializedHeapsWhenUseExternalAllocatorForSshAndDshEnabledThenFrontWindowPoolIsAtBeginingOfExternalHeap) {
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW));
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW));
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternalFrontWindow), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternalFrontWindow));
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::heapExternalFrontWindow), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternalFrontWindow));
}
TEST_F(FrontWindowAllocatorTests, givenInitializedHeapsWhenUseExternalAllocatorForSshAndDshEnabledThenMinimalAddressIsNotAtBeginingOfExternalHeap) {
EXPECT_GT(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::HEAP_EXTERNAL), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::heapExternal), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternal));
}
TEST_F(FrontWindowAllocatorTests, givenInitializedHeapsWhenUseExternalAllocatorForSshAndDshEnabledThenMinimalAddressIsAtBeginingOfExternalFrontWindowHeap) {
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW));
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::heapExternalFrontWindow), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternalFrontWindow));
}
TEST_F(FrontWindowAllocatorTests, givenInitializedHeapsWhenUseExternalAllocatorForSshAndDshEnabledThenMinimalAddressIsAtBeginingOfExternalDeviceFrontWindowHeap) {
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::HEAP_EXTERNAL_DEVICE_FRONT_WINDOW), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL_DEVICE_FRONT_WINDOW));
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::heapExternalDeviceFrontWindow), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternalDeviceFrontWindow));
}
TEST_F(FrontWindowAllocatorTests, givenInitializedHeapsWhenUseExternalAllocatorForSshAndDshDisabledThenMinimalAddressEqualBeginingOfExternalHeap) {
DebugManagerStateRestore dbgRestorer;
debugManager.flags.UseExternalAllocatorForSshAndDsh.set(false);
memManager.reset(new FrontWindowMemManagerMock(*pDevice->getExecutionEnvironment()));
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::HEAP_EXTERNAL), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL) + GfxPartition::heapGranularity);
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::heapExternal), memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternal) + GfxPartition::heapGranularity);
}
TEST_F(FrontWindowAllocatorTests, givenInitializedHeapsWhenUseExternalAllocatorForSshAndDshDisabledThenExternalHeapDoesntHaveFrontWindowPool) {
DebugManagerStateRestore dbgRestorer;
debugManager.flags.UseExternalAllocatorForSshAndDsh.set(false);
memManager.reset(new FrontWindowMemManagerMock(*pDevice->getExecutionEnvironment()));
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW), 0u);
EXPECT_EQ(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExternalFrontWindow), 0u);
}
TEST_F(FrontWindowAllocatorTests, givenLinearStreamAllocWhenSelectingHeapWithFrontWindowThenCorrectIndexReturned) {
GraphicsAllocation allocation{0, AllocationType::linearStream, nullptr, 0, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount};
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW, memManager->selectHeap(&allocation, true, true, true));
EXPECT_EQ(HeapIndex::heapExternalFrontWindow, memManager->selectHeap(&allocation, true, true, true));
}
} // namespace NEO

View File

@@ -63,8 +63,8 @@ TEST_F(DrmMemoryManagerLocalMemoryWithCustomPrelimMockTest, givenCreateDebugSurf
EXPECT_NE(reinterpret_cast<uint64_t>(debugSurface->getUnderlyingBuffer()), gpuAddress);
auto gmmHelper = device.get()->getGmmHelper();
EXPECT_GE(gmmHelper->decanonize(gpuAddress), gfxPartition->getHeapBase(HeapIndex::HEAP_STANDARD));
EXPECT_LT(gmmHelper->decanonize(gpuAddress), gfxPartition->getHeapLimit(HeapIndex::HEAP_STANDARD));
EXPECT_GE(gmmHelper->decanonize(gpuAddress), gfxPartition->getHeapBase(HeapIndex::heapStandard));
EXPECT_LT(gmmHelper->decanonize(gpuAddress), gfxPartition->getHeapLimit(HeapIndex::heapStandard));
auto &storageInfo = debugSurface->storageInfo;
auto &bos = debugSurface->getBOs();

View File

@@ -1924,21 +1924,21 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenSupportedTypeWhenAllocatingIn
auto gmmHelper = device->getGmmHelper();
if (allocation->getAllocationType() == AllocationType::svmGpu) {
if (!memoryManager->isLimitedRange(0)) {
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapSvm)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapSvm)), gpuAddress);
}
} else if (memoryManager->heapAssigners[rootDeviceIndex]->useInternal32BitHeap(allocation->getAllocationType())) {
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapInternalDeviceMemory)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapInternalDeviceMemory)), gpuAddress);
} else {
const bool prefer2MBAlignment = allocation->getUnderlyingBufferSize() >= 2 * MemoryConstants::megaByte;
const bool prefer57bitAddressing = memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0 && !allocData.flags.resource48Bit;
const bool prefer57bitAddressing = memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExtended) > 0 && !allocData.flags.resource48Bit;
auto heap = HeapIndex::HEAP_STANDARD64KB;
auto heap = HeapIndex::heapStandard64KB;
if (prefer2MBAlignment) {
heap = HeapIndex::HEAP_STANDARD2MB;
heap = HeapIndex::heapStandard2MB;
} else if (prefer57bitAddressing) {
heap = HeapIndex::HEAP_EXTENDED;
heap = HeapIndex::heapExtended;
}
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(heap)), gpuAddress);
@@ -2095,10 +2095,10 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenDebugModuleAreaTypeWhenAlloca
auto gpuAddress = moduleDebugArea->getGpuAddress();
auto gmmHelper = device->getGmmHelper();
EXPECT_LE(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), moduleDebugArea->getGpuBaseAddress());
EXPECT_LE(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceFrontWindow)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapInternalDeviceFrontWindow)), gpuAddress);
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceFrontWindow)), moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceMemory)), moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(MemoryPool::LocalMemory, moduleDebugArea->getMemoryPool());
memoryManager->freeGraphicsMemory(moduleDebugArea);
@@ -2113,10 +2113,10 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenSipKernelTypeWhenAllocatingTh
auto gpuAddress = sipAllocation->getGpuAddress();
auto gmmHelper = device->getGmmHelper();
EXPECT_LE(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), sipAllocation->getGpuBaseAddress());
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), sipAllocation->getGpuBaseAddress());
EXPECT_LE(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceFrontWindow)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapInternalDeviceFrontWindow)), gpuAddress);
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceFrontWindow)), sipAllocation->getGpuBaseAddress());
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceMemory)), sipAllocation->getGpuBaseAddress());
EXPECT_EQ(MemoryPool::LocalMemory, sipAllocation->getMemoryPool());
memoryManager->freeGraphicsMemory(sipAllocation);
@@ -2535,8 +2535,8 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
ASSERT_NE(nullptr, graphicsAllocation);
const bool prefer57bitAddressing = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0;
const auto expectedHeap = prefer57bitAddressing ? HeapIndex::HEAP_EXTENDED : HeapIndex::HEAP_STANDARD2MB;
const bool prefer57bitAddressing = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended) > 0;
const auto expectedHeap = prefer57bitAddressing ? HeapIndex::heapExtended : HeapIndex::heapStandard2MB;
auto gpuAddress = graphicsAllocation->getGpuAddress();
auto gmmHelper = device->getGmmHelper();
@@ -3004,7 +3004,7 @@ class DrmMemoryManagerAllocation57BitTest : public DrmMemoryManagerLocalMemoryPr
};
TEST_P(DrmMemoryManagerAllocation57BitTest, givenAllocationTypeHaveToBeAllocatedAs57BitThenHeapExtendedIsUsed) {
if (0 == memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
if (0 == memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExtended)) {
GTEST_SKIP();
}
@@ -3013,8 +3013,8 @@ TEST_P(DrmMemoryManagerAllocation57BitTest, givenAllocationTypeHaveToBeAllocated
auto gpuAddress = allocation->getGpuAddress();
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTENDED)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExtended)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExtended)), gpuAddress);
memoryManager->freeGraphicsMemory(allocation);
}

View File

@@ -606,20 +606,20 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenSupportedTypeWhenAllocatingInDev
auto gmmHelper = device->getGmmHelper();
if (allocation->getAllocationType() == AllocationType::svmGpu) {
if (!memoryManager->isLimitedRange(0)) {
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapSvm)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapSvm)), gpuAddress);
}
} else if (memoryManager->heapAssigners[rootDeviceIndex]->useInternal32BitHeap(allocation->getAllocationType())) {
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapInternalDeviceMemory)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapInternalDeviceMemory)), gpuAddress);
} else {
const bool prefer2MBAlignment = allocation->getUnderlyingBufferSize() >= 2 * MemoryConstants::megaByte;
auto heap = HeapIndex::HEAP_STANDARD64KB;
auto heap = HeapIndex::heapStandard64KB;
if (prefer2MBAlignment) {
heap = HeapIndex::HEAP_STANDARD2MB;
} else if (memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0 && !allocData.flags.resource48Bit) {
heap = HeapIndex::HEAP_EXTENDED;
heap = HeapIndex::heapStandard2MB;
} else if (memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExtended) > 0 && !allocData.flags.resource48Bit) {
heap = HeapIndex::heapExtended;
}
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(heap)), gpuAddress);

View File

@@ -302,18 +302,18 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenGp
rootDeviceIndices.pushUnique(1);
uint32_t rootDeviceIndexReserved = 0;
auto gmmHelper = memoryManager->getGmmHelper(1);
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_EQ(rootDeviceIndexReserved, 1u);
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager->freeGpuAddress(addressRange, 1);
addressRange = memoryManager->reserveGpuAddress(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_EQ(rootDeviceIndexReserved, 1u);
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager->freeGpuAddress(addressRange, 1);
}
@@ -323,21 +323,21 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenGp
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 1;
auto gmmHelper = memoryManager->getGmmHelper(0);
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_LE(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager->freeGpuAddress(addressRange, 0);
addressRange = memoryManager->reserveGpuAddress(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_LE(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager->freeGpuAddress(addressRange, 0);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenDebugVariableToDisableAddressAlignmentAndCallToSelectAlignmentAndHeapWithPow2MemoryThenAlignmentIs2Mb) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended)) {
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
@@ -345,40 +345,40 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenDebugVar
auto size = 8 * MemoryConstants::gigaByte;
HeapIndex heap = HeapIndex::HEAP_STANDARD;
HeapIndex heap = HeapIndex::heapStandard;
auto alignment = memoryManager->selectAlignmentAndHeap(size, &heap);
EXPECT_EQ(heap, HeapIndex::HEAP_EXTENDED);
EXPECT_EQ(heap, HeapIndex::heapExtended);
EXPECT_EQ(MemoryConstants::pageSize2M, alignment);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenCalltoSelectAlignmentAndHeapWithPow2MemoryThenAlignmentIsPreviousPow2) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended)) {
GTEST_SKIP();
}
auto size = Math::nextPowerOfTwo(8 * MemoryConstants::gigaByte);
HeapIndex heap = HeapIndex::HEAP_STANDARD;
HeapIndex heap = HeapIndex::heapStandard;
auto alignment = memoryManager->selectAlignmentAndHeap(size, &heap);
EXPECT_EQ(heap, HeapIndex::HEAP_EXTENDED);
EXPECT_EQ(heap, HeapIndex::heapExtended);
EXPECT_EQ(Math::prevPowerOfTwo(size), alignment);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenCalltoSelectAlignmentAndHeapWithNonPow2SizeThenAlignmentIs2MB) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended)) {
GTEST_SKIP();
}
auto size = (8 * MemoryConstants::gigaByte) + 5;
HeapIndex heap = HeapIndex::HEAP_STANDARD;
HeapIndex heap = HeapIndex::heapStandard;
auto alignment = memoryManager->selectAlignmentAndHeap(size, &heap);
EXPECT_EQ(heap, HeapIndex::HEAP_EXTENDED);
EXPECT_EQ(heap, HeapIndex::heapExtended);
EXPECT_EQ(MemoryConstants::pageSize2M, alignment);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenDebugVariableToDisableAddressAlignmentWhenSelectAlignmentAndHeapNewCustomAlignmentReturned) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended)) {
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
@@ -386,22 +386,22 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenDebugVar
auto size = 16 * MemoryConstants::megaByte;
HeapIndex heap = HeapIndex::HEAP_STANDARD;
HeapIndex heap = HeapIndex::heapStandard;
auto alignment = memoryManager->selectAlignmentAndHeap(size, &heap);
EXPECT_EQ(heap, HeapIndex::HEAP_EXTENDED);
EXPECT_EQ(heap, HeapIndex::heapExtended);
EXPECT_NE(MemoryConstants::pageSize64k, alignment);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenSelectAlignmentAndHeapThen64KbAlignmentReturned) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended)) {
GTEST_SKIP();
}
auto size = 16 * MemoryConstants::megaByte;
HeapIndex heap = HeapIndex::HEAP_STANDARD;
HeapIndex heap = HeapIndex::heapStandard;
auto alignment = memoryManager->selectAlignmentAndHeap(size, &heap);
EXPECT_EQ(heap, HeapIndex::HEAP_EXTENDED);
EXPECT_EQ(heap, HeapIndex::heapExtended);
EXPECT_NE(MemoryConstants::pageSize64k, alignment);
}
@@ -410,13 +410,13 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenGp
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 1;
HeapIndex heap = HeapIndex::HEAP_STANDARD;
HeapIndex heap = HeapIndex::heapStandard;
auto alignment = memoryManager->selectAlignmentAndHeap(MemoryConstants::pageSize, &heap);
auto gfxPartition = memoryManager->getGfxPartition(0);
if (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0) {
EXPECT_EQ(heap, HeapIndex::HEAP_EXTENDED);
if (gfxPartition->getHeapLimit(HeapIndex::heapExtended) > 0) {
EXPECT_EQ(heap, HeapIndex::heapExtended);
} else {
EXPECT_EQ(heap, HeapIndex::HEAP_STANDARD64KB);
EXPECT_EQ(heap, HeapIndex::heapStandard64KB);
}
EXPECT_EQ(MemoryConstants::pageSize64k, alignment);
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, heap, alignment);
@@ -430,7 +430,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenGp
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 1;
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0x1234, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0x1234, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_NE(static_cast<int>(addressRange.address), 0x1234);
EXPECT_NE(static_cast<int>(addressRange.size), 0);
memoryManager->freeGpuAddress(addressRange, 0);
@@ -447,9 +447,9 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenGp
uint32_t rootDeviceIndexReserved = 1;
// emulate GPU address space exhaust
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
memoryManager->getGfxPartition(0)->heapInit(HeapIndex::HEAP_STANDARD, 0x0, 0x10000);
size_t invalidSize = (size_t)memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD) + MemoryConstants::pageSize;
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, invalidSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
memoryManager->getGfxPartition(0)->heapInit(HeapIndex::heapStandard, 0x0, 0x10000);
size_t invalidSize = (size_t)memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard) + MemoryConstants::pageSize;
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, invalidSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_EQ(static_cast<int>(addressRange.address), 0);
addressRange = memoryManager->reserveGpuAddress(0ull, invalidSize, rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_EQ(static_cast<int>(addressRange.address), 0);
@@ -459,14 +459,14 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenHe
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, true, false, *executionEnvironment);
// emulate GPU address space exhaust
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
memoryManager->getGfxPartition(0)->heapInit(HeapIndex::HEAP_EXTENDED, 0x11000, 0x10000);
memoryManager->getGfxPartition(1)->heapInit(HeapIndex::HEAP_STANDARD, 0, 0x10000);
memoryManager->getGfxPartition(1)->heapInit(HeapIndex::HEAP_EXTENDED, 0, 0);
memoryManager->getGfxPartition(0)->heapInit(HeapIndex::heapExtended, 0x11000, 0x10000);
memoryManager->getGfxPartition(1)->heapInit(HeapIndex::heapStandard, 0, 0x10000);
memoryManager->getGfxPartition(1)->heapInit(HeapIndex::heapExtended, 0, 0);
auto size = MemoryConstants::pageSize64k;
HeapIndex heap = HeapIndex::HEAP_STANDARD;
HeapIndex heap = HeapIndex::heapStandard;
auto alignment = memoryManager->selectAlignmentAndHeap(size, &heap);
EXPECT_EQ(heap, HeapIndex::HEAP_STANDARD64KB);
EXPECT_EQ(heap, HeapIndex::heapStandard64KB);
EXPECT_EQ(MemoryConstants::pageSize64k, alignment);
}
@@ -1560,7 +1560,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
auto gfxPartition = memoryManager->getGfxPartition(device->getRootDeviceIndex());
auto allocatedPointer = gfxPartition->heapAllocate(HeapIndex::HEAP_STANDARD, dummySize);
auto allocatedPointer = gfxPartition->heapAllocate(HeapIndex::heapStandard, dummySize);
gfxPartition->freeGpuAddressRange(allocatedPointer, dummySize);
auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
@@ -1571,7 +1571,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
// make sure that partition is free
size_t dummySize2 = 13u;
auto allocatedPointer2 = gfxPartition->heapAllocate(HeapIndex::HEAP_STANDARD, dummySize2);
auto allocatedPointer2 = gfxPartition->heapAllocate(HeapIndex::heapStandard, dummySize2);
EXPECT_EQ(allocatedPointer2, allocatedPointer);
gfxPartition->freeGpuAddressRange(allocatedPointer, dummySize2);
}
@@ -1737,21 +1737,21 @@ TEST_F(DrmMemoryManagerTest, GivenMemoryManagerWhenCreatingGraphicsAllocation64k
TEST_F(DrmMemoryManagerTest, givenRequiresStandardHeapThenStandardHeapIsAcquired) {
const uint32_t rootDeviceIndex = 0;
size_t bufferSize = 4096u;
uint64_t range = memoryManager->acquireGpuRange(bufferSize, rootDeviceIndex, HeapIndex::HEAP_STANDARD);
uint64_t range = memoryManager->acquireGpuRange(bufferSize, rootDeviceIndex, HeapIndex::heapStandard);
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD)), range);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD)), range);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapStandard)), range);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapStandard)), range);
}
TEST_F(DrmMemoryManagerTest, givenRequiresStandard2MBHeapThenStandard2MBHeapIsAcquired) {
const uint32_t rootDeviceIndex = 0;
size_t bufferSize = 4096u;
uint64_t range = memoryManager->acquireGpuRange(bufferSize, rootDeviceIndex, HeapIndex::HEAP_STANDARD2MB);
uint64_t range = memoryManager->acquireGpuRange(bufferSize, rootDeviceIndex, HeapIndex::heapStandard2MB);
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD2MB)), range);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD2MB)), range);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapStandard2MB)), range);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapStandard2MB)), range);
}
TEST_F(DrmMemoryManagerTest, GivenShareableEnabledWhenAskedToCreateGraphicsAllocationThenValidAllocationIsReturnedAndStandard64KBHeapIsUsed) {
@@ -1766,8 +1766,8 @@ TEST_F(DrmMemoryManagerTest, GivenShareableEnabledWhenAskedToCreateGraphicsAlloc
EXPECT_NE(0u, allocation->getGpuAddress());
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(allocation->getRootDeviceIndex())->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(allocation->getRootDeviceIndex())->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(allocation->getRootDeviceIndex())->getHeapBase(HeapIndex::heapStandard64KB)), allocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(allocation->getRootDeviceIndex())->getHeapLimit(HeapIndex::heapStandard64KB)), allocation->getGpuAddress());
memoryManager->freeGraphicsMemory(allocation);
}
@@ -1866,15 +1866,15 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenLimitedRangeAllocatorSetThenH
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
uint64_t sizeBig = 4 * MemoryConstants::megaByte + MemoryConstants::pageSize;
auto gpuAddressLimitedRange = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_STANDARD, sizeBig);
EXPECT_LT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange);
EXPECT_GT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange + sizeBig);
EXPECT_EQ(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapMinimalAddress(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange);
auto gpuAddressLimitedRange = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::heapStandard, sizeBig);
EXPECT_LT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapStandard), gpuAddressLimitedRange);
EXPECT_GT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapStandard), gpuAddressLimitedRange + sizeBig);
EXPECT_EQ(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapMinimalAddress(HeapIndex::heapStandard), gpuAddressLimitedRange);
auto gpuInternal32BitAlloc = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, sizeBig);
EXPECT_LT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gpuInternal32BitAlloc);
EXPECT_GT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gpuInternal32BitAlloc + sizeBig);
EXPECT_EQ(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gpuInternal32BitAlloc);
auto gpuInternal32BitAlloc = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::heapInternalDeviceMemory, sizeBig);
EXPECT_LT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceMemory), gpuInternal32BitAlloc);
EXPECT_GT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapInternalDeviceMemory), gpuInternal32BitAlloc + sizeBig);
EXPECT_EQ(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapMinimalAddress(HeapIndex::heapInternalDeviceMemory), gpuInternal32BitAlloc);
}
TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForAllocationWithAlignmentAndLimitedRangeAllocatorSetAndAcquireGpuRangeFailsThenNullIsReturned) {
@@ -1885,7 +1885,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForAllocationWithAlignme
// emulate GPU address space exhaust
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
memoryManager->getGfxPartition(rootDeviceIndex)->heapInit(HeapIndex::HEAP_STANDARD, 0x0, 0x10000);
memoryManager->getGfxPartition(rootDeviceIndex)->heapInit(HeapIndex::heapStandard, 0x0, 0x10000);
// set size to something bigger than allowed space
allocationData.size = 0x20000;
@@ -1942,7 +1942,7 @@ TEST_F(DrmMemoryManagerTest, GivenExhaustedInternalHeapWhenAllocate32BitIsCalled
memoryManager->setForce32BitAllocations(true);
size_t size = MemoryConstants::pageSize64k;
auto alloc = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, size);
auto alloc = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::heapInternalDeviceMemory, size);
EXPECT_NE(0llu, alloc);
size_t allocationSize = 4 * MemoryConstants::gigaByte;
@@ -2047,8 +2047,8 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemory
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, graphicsAllocation->getMemoryPool());
EXPECT_EQ(this->mock->inputFd, static_cast<int32_t>(handle));
const bool prefer57bitAddressing = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0;
const auto expectedHeap = prefer57bitAddressing ? HeapIndex::HEAP_EXTENDED : HeapIndex::HEAP_STANDARD2MB;
const bool prefer57bitAddressing = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended) > 0;
const auto expectedHeap = prefer57bitAddressing ? HeapIndex::heapExtended : HeapIndex::heapStandard2MB;
auto gpuAddress = graphicsAllocation->getGpuAddress();
auto gmmHelper = device->getGmmHelper();
@@ -2534,12 +2534,12 @@ TEST_F(DrmMemoryManagerTest, given32BitAllocatorWithHeapAllocatorWhenLargerFragm
memoryManager->setForce32BitAllocations(true);
size_t allocationSize = 4 * MemoryConstants::pageSize;
auto ptr = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_EXTERNAL, allocationSize);
auto ptr = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::heapExternal, allocationSize);
size_t smallAllocationSize = MemoryConstants::pageSize;
memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_EXTERNAL, smallAllocationSize);
memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::heapExternal, smallAllocationSize);
// now free first allocation , this will move it to chunks
memoryManager->getGfxPartition(rootDeviceIndex)->heapFree(HeapIndex::HEAP_EXTERNAL, ptr, allocationSize);
memoryManager->getGfxPartition(rootDeviceIndex)->heapFree(HeapIndex::heapExternal, ptr, allocationSize);
// now ask for 3 pages, this will give ptr from chunks
size_t pages3size = 3 * MemoryConstants::pageSize;
@@ -2838,7 +2838,7 @@ TEST_F(DrmMemoryManagerBasic, givenDefaultDrmMemoryManagerWhenItIsQueriedForInte
true,
true,
executionEnvironment));
auto heapBase = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
auto heapBase = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceMemory);
EXPECT_EQ(heapBase, memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, true));
}
@@ -3500,14 +3500,14 @@ TEST_F(DrmMemoryManagerBasic, ifLimitedRangeAllocatorAvailableWhenAskedForAlloca
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
size_t size = 100u;
auto ptr = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_STANDARD, size);
auto address64bit = ptrDiff(ptr, memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD));
auto ptr = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::heapStandard, size);
auto address64bit = ptrDiff(ptr, memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapStandard));
EXPECT_LT(address64bit, defaultHwInfo->capabilityTable.gpuAddressSpace);
EXPECT_LT(0u, address64bit);
memoryManager->getGfxPartition(rootDeviceIndex)->heapFree(HeapIndex::HEAP_STANDARD, ptr, size);
memoryManager->getGfxPartition(rootDeviceIndex)->heapFree(HeapIndex::heapStandard, ptr, size);
}
TEST_F(DrmMemoryManagerBasic, givenSpecificAddressSpaceWhenInitializingMemoryManagerThenSetCorrectHeaps) {
@@ -3515,7 +3515,7 @@ TEST_F(DrmMemoryManagerBasic, givenSpecificAddressSpaceWhenInitializingMemoryMan
TestedDrmMemoryManager memoryManager(false, false, false, executionEnvironment);
auto gfxPartition = memoryManager.getGfxPartition(rootDeviceIndex);
auto limit = gfxPartition->getHeapLimit(HeapIndex::HEAP_SVM);
auto limit = gfxPartition->getHeapLimit(HeapIndex::heapSvm);
EXPECT_EQ(maxNBitValue(48 - 1), limit);
}
@@ -3600,7 +3600,7 @@ TEST_F(DrmMemoryManagerTest, givenDebugModuleAreaTypeWhenCreatingAllocationThen3
EXPECT_TRUE(moduleDebugArea->is32BitAllocation());
HeapIndex heap = HeapAssigner::mapInternalWindowIndex(memoryManager->selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool()));
EXPECT_TRUE(heap == HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW || heap == HeapIndex::HEAP_INTERNAL_FRONT_WINDOW);
EXPECT_TRUE(heap == HeapIndex::heapInternalDeviceFrontWindow || heap == HeapIndex::heapInternalFrontWindow);
auto gmmHelper = device->getGmmHelper();
auto frontWindowBase = gmmHelper->canonize(memoryManager->getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(heap));
@@ -3728,8 +3728,8 @@ TEST_F(DrmMemoryManagerTest, givenSvmCpuAllocationWhenSizeAndAlignmentProvidedTh
EXPECT_NE(0llu, bo->peekAddress());
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapStandard)), bo->peekAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapStandard)), bo->peekAddress());
EXPECT_EQ(reinterpret_cast<void *>(allocation->getGpuAddress()), alignUp(allocation->getReservedAddressPtr(), allocationData.alignment));
EXPECT_EQ(alignUp(allocationData.size, allocationData.alignment) + allocationData.alignment, allocation->getReservedAddressSize());
@@ -3744,7 +3744,7 @@ TEST_F(DrmMemoryManagerTest, givenSvmCpuAllocationWhenSizeAndAlignmentProvidedBu
mock->ioctlExpected.gemWait = 0;
mock->ioctlExpected.gemClose = 0;
memoryManager->getGfxPartition(rootDeviceIndex)->heapInit(HeapIndex::HEAP_STANDARD, 0, 0);
memoryManager->getGfxPartition(rootDeviceIndex)->heapInit(HeapIndex::heapStandard, 0, 0);
AllocationData allocationData;
allocationData.size = 2 * MemoryConstants::megaByte;
@@ -3762,7 +3762,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndReleaseGpuRangeIsCalledThen
auto mockGfxPartition = std::make_unique<MockGfxPartition>();
mockGfxPartition->init(hwInfo->capabilityTable.gpuAddressSpace, reservedCpuAddressRangeSize, 0, 1, false, 0u);
auto size = 2 * MemoryConstants::megaByte;
auto gpuAddress = mockGfxPartition->heapAllocate(HeapIndex::HEAP_STANDARD, size);
auto gpuAddress = mockGfxPartition->heapAllocate(HeapIndex::heapStandard, size);
auto gmmHelper = device->getGmmHelper();
auto gpuAddressCanonized = gmmHelper->canonize(gpuAddress);
EXPECT_LE(gpuAddress, gpuAddressCanonized);
@@ -4670,8 +4670,8 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenAffinityMaskDeviceWith
TEST_F(DrmMemoryManagerTest, whenWddmMemoryManagerIsCreatedThenAlignmentSelectorHasExpectedAlignments) {
std::vector<AlignmentSelector::CandidateAlignment> expectedAlignments = {
{MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD2MB},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD64KB},
{MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::heapStandard2MB},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::heapStandard64KB},
};
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
@@ -4693,7 +4693,7 @@ TEST_F(DrmMemoryManagerTest, given2MbPagesDisabledWhenWddmMemoryManagerIsCreated
debugManager.flags.AlignLocalMemoryVaTo2MB.set(0);
std::vector<AlignmentSelector::CandidateAlignment> expectedAlignments = {
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD64KB},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::heapStandard64KB},
};
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
@@ -4706,9 +4706,9 @@ TEST_F(DrmMemoryManagerTest, givenCustomAlignmentWhenWddmMemoryManagerIsCreatedT
{
debugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.set(MemoryConstants::megaByte);
std::vector<AlignmentSelector::CandidateAlignment> expectedAlignments = {
{MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD2MB},
{MemoryConstants::megaByte, true, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD64KB},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD64KB},
{MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::heapStandard2MB},
{MemoryConstants::megaByte, true, AlignmentSelector::anyWastage, HeapIndex::heapStandard64KB},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::heapStandard64KB},
};
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
EXPECT_EQ(expectedAlignments, memoryManager.alignmentSelector.peekCandidateAlignments());
@@ -4717,9 +4717,9 @@ TEST_F(DrmMemoryManagerTest, givenCustomAlignmentWhenWddmMemoryManagerIsCreatedT
{
debugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.set(2 * MemoryConstants::pageSize2M);
std::vector<AlignmentSelector::CandidateAlignment> expectedAlignments = {
{2 * MemoryConstants::pageSize2M, true, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD2MB},
{MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD2MB},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::HEAP_STANDARD64KB},
{2 * MemoryConstants::pageSize2M, true, AlignmentSelector::anyWastage, HeapIndex::heapStandard2MB},
{MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::heapStandard2MB},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::heapStandard64KB},
};
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
EXPECT_EQ(expectedAlignments, memoryManager.alignmentSelector.peekCandidateAlignments());
@@ -4848,7 +4848,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenDeviceHeapIsDepletedTh
auto status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.size = MemoryConstants::pageSize + mockGfxPartition->heapGetLimit(NEO::HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
allocData.size = MemoryConstants::pageSize + mockGfxPartition->heapGetLimit(NEO::HeapIndex::heapInternalDeviceMemory);
allocData.flags.useSystemMemory = false;
allocData.flags.allocateMemory = true;
allocData.type = AllocationType::kernelIsa;
@@ -6198,7 +6198,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, given2MbAlignmentAllowedWhenAll
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD64KB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard64KB));
memoryManager->freeGraphicsMemory(allocation);
}
{
@@ -6207,7 +6207,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, given2MbAlignmentAllowedWhenAll
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD64KB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard64KB));
memoryManager->freeGraphicsMemory(allocation);
}
{
@@ -6216,7 +6216,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, given2MbAlignmentAllowedWhenAll
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD64KB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard64KB));
memoryManager->freeGraphicsMemory(allocation);
}
}
@@ -6237,7 +6237,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, given2MbAlignmentAllowedWhenAll
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD2MB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard2MB));
memoryManager->freeGraphicsMemory(allocation);
}
{
@@ -6246,7 +6246,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, given2MbAlignmentAllowedWhenAll
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD64KB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard64KB));
memoryManager->freeGraphicsMemory(allocation);
}
{
@@ -6255,14 +6255,14 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, given2MbAlignmentAllowedWhenAll
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD2MB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard2MB));
EXPECT_TRUE(isAligned(allocation->getGpuAddress(), MemoryConstants::pageSize2M));
memoryManager->freeGraphicsMemory(allocation);
}
}
TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenExtendedHeapPreferredAnd2MbAlignmentAllowedWhenAllocatingAllocationBiggerThenUseExtendedHeap) {
if (memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED) == 0) {
if (memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExtended) == 0) {
GTEST_SKIP();
}
@@ -6282,7 +6282,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenExtendedHeapPreferredAnd2M
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAligned(allocation->getGpuAddress(), MemoryConstants::pageSize2M));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_EXTENDED));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapExtended));
memoryManager->freeGraphicsMemory(allocation);
}
{
@@ -6291,7 +6291,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenExtendedHeapPreferredAnd2M
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_EXTENDED));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapExtended));
memoryManager->freeGraphicsMemory(allocation);
}
{
@@ -6300,7 +6300,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenExtendedHeapPreferredAnd2M
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_EXTENDED));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapExtended));
EXPECT_TRUE(isAligned(allocation->getGpuAddress(), MemoryConstants::pageSize2M));
memoryManager->freeGraphicsMemory(allocation);
}
@@ -6323,7 +6323,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenCustomAlignmentWhenAllocat
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD2MB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard2MB));
EXPECT_TRUE(isAligned(allocation->getGpuAddress(), 2 * MemoryConstants::megaByte));
memoryManager->freeGraphicsMemory(allocation);
}
@@ -6336,7 +6336,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenCustomAlignmentWhenAllocat
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD2MB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard2MB));
EXPECT_TRUE(isAligned(allocation->getGpuAddress(), 16 * MemoryConstants::megaByte));
memoryManager->freeGraphicsMemory(allocation);
}
@@ -6349,7 +6349,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenCustomAlignmentWhenAllocat
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD64KB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard64KB));
EXPECT_TRUE(isAligned(allocation->getGpuAddress(), 8 * MemoryConstants::pageSize64k));
memoryManager->freeGraphicsMemory(allocation);
}
@@ -6373,7 +6373,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenCustomAlignmentWhenAllocat
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD2MB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard2MB));
memoryManager->freeGraphicsMemory(allocation);
}
@@ -6385,7 +6385,7 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenCustomAlignmentWhenAllocat
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocationData, allocationStatus);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, allocationStatus);
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::HEAP_STANDARD2MB));
EXPECT_TRUE(isAllocationWithinHeap(*memoryManager, *allocation, HeapIndex::heapStandard2MB));
memoryManager->freeGraphicsMemory(allocation);
}
}
@@ -6417,9 +6417,9 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUs
auto gpuAddress = allocation->getGpuAddress();
EXPECT_NE(0u, gpuAddress);
auto heap = HeapIndex::HEAP_STANDARD64KB;
if (memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
heap = HeapIndex::HEAP_EXTENDED;
auto heap = HeapIndex::heapStandard64KB;
if (memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended)) {
heap = HeapIndex::heapExtended;
}
auto gmmHelper = device->getGmmHelper();
@@ -6554,8 +6554,8 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUs
EXPECT_NE(0u, gpuAddress);
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapStandard64KB)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapStandard64KB)), gpuAddress);
EXPECT_EQ(0u, allocation->getGpuBaseAddress());
EXPECT_EQ(sizeAligned, allocation->getUnderlyingBufferSize());
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
@@ -6596,9 +6596,9 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUs
auto gpuAddress = allocation->getGpuAddress();
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), allocation->getGpuBaseAddress());
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceMemory)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapInternalDeviceMemory)), gpuAddress);
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapInternalDeviceMemory)), allocation->getGpuBaseAddress());
EXPECT_EQ(sizeAligned, allocation->getUnderlyingBufferSize());
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
EXPECT_EQ(sizeAligned, allocation->getReservedAddressSize());
@@ -6635,9 +6635,9 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenUnsuppor
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenOversizedAllocationWhenGraphicsAllocationInDevicePoolIsAllocatedThenAllocationAndBufferObjectHaveRequestedSize) {
auto heap = HeapIndex::HEAP_STANDARD64KB;
if (memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
heap = HeapIndex::HEAP_EXTENDED;
auto heap = HeapIndex::heapStandard64KB;
if (memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended)) {
heap = HeapIndex::heapExtended;
}
auto largerSize = 6 * MemoryConstants::megaByte;
@@ -6668,7 +6668,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenOversize
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenAllocationsThatAreAlignedToPowerOf2InSizeAndAreGreaterThen8GBThenTheyAreAlignedToPreviousPowerOfTwoForGpuVirtualAddress) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended)) {
GTEST_SKIP();
}
@@ -6700,7 +6700,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenAllocati
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenDebugVariableToDisableAddressAlignmentWhenAllocationsAreMadeTheyAreAlignedTo2MB) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
if (!memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExtended)) {
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
@@ -7102,34 +7102,34 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenGp
rootDeviceIndices.pushUnique(1);
uint32_t rootDeviceIndexReserved = 0;
auto gmmHelper = memoryManager->getGmmHelper(1);
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_EQ(rootDeviceIndexReserved, 1u);
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
uint64_t requiredAddr = addressRange.address;
memoryManager->freeGpuAddress(addressRange, 1);
addressRange = memoryManager->reserveGpuAddressOnHeap(requiredAddr, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::HEAP_STANDARD, MemoryConstants::pageSize64k);
addressRange = memoryManager->reserveGpuAddressOnHeap(requiredAddr, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved, NEO::HeapIndex::heapStandard, MemoryConstants::pageSize64k);
EXPECT_EQ(rootDeviceIndexReserved, 1u);
EXPECT_EQ(addressRange.address, requiredAddr);
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager->freeGpuAddress(addressRange, 1);
addressRange = memoryManager->reserveGpuAddress(0ull, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_EQ(rootDeviceIndexReserved, 1u);
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
requiredAddr = addressRange.address;
memoryManager->freeGpuAddress(addressRange, 1);
addressRange = memoryManager->reserveGpuAddress(requiredAddr, MemoryConstants::pageSize, rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_EQ(rootDeviceIndexReserved, 1u);
EXPECT_EQ(addressRange.address, requiredAddr);
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memoryManager->getGfxPartition(1)->getHeapBase(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memoryManager->getGfxPartition(1)->getHeapLimit(HeapIndex::heapStandard), gmmHelper->decanonize(addressRange.address));
memoryManager->freeGpuAddress(addressRange, 1);
}
@@ -7138,7 +7138,7 @@ TEST_F(DrmMemoryManagerTest, given57bAddressSpaceCpuAndGpuWhenAllocatingHostUSMT
GTEST_SKIP();
}
auto mockGfxPartition = std::make_unique<MockGfxPartition>();
mockGfxPartition->initHeap(HeapIndex::HEAP_EXTENDED_HOST, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
mockGfxPartition->initHeap(HeapIndex::heapExtendedHost, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
memoryManager->overrideGfxPartition(mockGfxPartition.release());
VariableBackup<bool> backupCaptureExtendedPointers(&SysCalls::mmapCaptureExtendedPointers, true);
VariableBackup<bool> backupAllowExtendedPointers(&SysCalls::mmapAllowExtendedPointers, true);
@@ -7157,8 +7157,8 @@ TEST_F(DrmMemoryManagerTest, given57bAddressSpaceCpuAndGpuWhenAllocatingHostUSMT
auto gpuAddress = reinterpret_cast<uint64_t>(SysCalls::mmapCapturedExtendedPointers[0]);
SysCalls::mmapCapturedExtendedPointers.clear();
auto gmmHelper = memoryManager->getGmmHelper(mockRootDeviceIndex);
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTENDED_HOST), gmmHelper->decanonize(gpuAddress));
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED_HOST), gmmHelper->decanonize(gpuAddress));
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::heapExtendedHost), gmmHelper->decanonize(gpuAddress));
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::heapExtendedHost), gmmHelper->decanonize(gpuAddress));
EXPECT_EQ(hostUSM->getGpuAddress(), gpuAddress);
EXPECT_EQ(hostUSM->getReservedAddressPtr(), reinterpret_cast<void *>(gpuAddress));
@@ -7170,7 +7170,7 @@ TEST_F(DrmMemoryManagerTest, given48bAddressSpaceCpuAnd57bGpuWhenAllocatingHostU
GTEST_SKIP();
}
auto mockGfxPartition = std::make_unique<MockGfxPartition>();
mockGfxPartition->initHeap(HeapIndex::HEAP_EXTENDED_HOST, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
mockGfxPartition->initHeap(HeapIndex::heapExtendedHost, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
memoryManager->overrideGfxPartition(mockGfxPartition.release());
VariableBackup<bool> backupCaptureExtendedPointers(&SysCalls::mmapCaptureExtendedPointers, true);
VariableBackup<bool> backupAllowExtendedPointers(&SysCalls::mmapAllowExtendedPointers, false);
@@ -7189,8 +7189,8 @@ TEST_F(DrmMemoryManagerTest, given48bAddressSpaceCpuAnd57bGpuWhenAllocatingHostU
auto gpuAddress = reinterpret_cast<uint64_t>(SysCalls::mmapCapturedExtendedPointers[0]);
SysCalls::mmapCapturedExtendedPointers.clear();
auto gmmHelper = memoryManager->getGmmHelper(mockRootDeviceIndex);
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTENDED_HOST), gmmHelper->decanonize(gpuAddress));
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED_HOST), gmmHelper->decanonize(gpuAddress));
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::heapExtendedHost), gmmHelper->decanonize(gpuAddress));
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::heapExtendedHost), gmmHelper->decanonize(gpuAddress));
EXPECT_NE(hostUSM->getGpuAddress(), gpuAddress);
memoryManager->freeGraphicsMemory(hostUSM);
@@ -7202,7 +7202,7 @@ TEST_F(DrmMemoryManagerTest, given57bAddressSpaceCpuAndGpuAndDisabledHeapExtende
}
auto mockGfxPartition = std::make_unique<MockGfxPartition>();
mockGfxPartition->initHeap(HeapIndex::HEAP_EXTENDED_HOST, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
mockGfxPartition->initHeap(HeapIndex::heapExtendedHost, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
memoryManager->overrideGfxPartition(mockGfxPartition.release());
DebugManagerStateRestore restorer;
debugManager.flags.AllocateHostAllocationsInHeapExtendedHost.set(false);
@@ -7229,7 +7229,7 @@ TEST_F(DrmMemoryManagerTest, given57bAddressSpaceCpuAndGpuWhenAllocatingSharedUS
}
auto mockGfxPartition = std::make_unique<MockGfxPartition>();
mockGfxPartition->initHeap(HeapIndex::HEAP_EXTENDED_HOST, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
mockGfxPartition->initHeap(HeapIndex::heapExtendedHost, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
memoryManager->overrideGfxPartition(mockGfxPartition.release());
DebugManagerStateRestore restorer;
debugManager.flags.AllocateSharedAllocationsInHeapExtendedHost.set(true);
@@ -7256,8 +7256,8 @@ TEST_F(DrmMemoryManagerTest, given57bAddressSpaceCpuAndGpuWhenAllocatingSharedUS
auto gpuAddress = reinterpret_cast<uint64_t>(SysCalls::mmapCapturedExtendedPointers[0]);
SysCalls::mmapCapturedExtendedPointers.clear();
auto gmmHelper = memoryManager->getGmmHelper(mockRootDeviceIndex);
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTENDED_HOST), gmmHelper->decanonize(gpuAddress));
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED_HOST), gmmHelper->decanonize(gpuAddress));
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::heapExtendedHost), gmmHelper->decanonize(gpuAddress));
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::heapExtendedHost), gmmHelper->decanonize(gpuAddress));
EXPECT_EQ(sharedUSM->getGpuAddress(), gpuAddress);
EXPECT_EQ(sharedUSM->getReservedAddressPtr(), reinterpret_cast<void *>(gpuAddress));
@@ -7269,7 +7269,7 @@ TEST_F(DrmMemoryManagerTest, given48bAddressSpaceCpuAnd57bGpuWhenAllocatingShare
GTEST_SKIP();
}
auto mockGfxPartition = std::make_unique<MockGfxPartition>();
mockGfxPartition->initHeap(HeapIndex::HEAP_EXTENDED_HOST, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
mockGfxPartition->initHeap(HeapIndex::heapExtendedHost, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
memoryManager->overrideGfxPartition(mockGfxPartition.release());
DebugManagerStateRestore restorer;
debugManager.flags.AllocateSharedAllocationsInHeapExtendedHost.set(true);
@@ -7296,8 +7296,8 @@ TEST_F(DrmMemoryManagerTest, given48bAddressSpaceCpuAnd57bGpuWhenAllocatingShare
auto gpuAddress = reinterpret_cast<uint64_t>(SysCalls::mmapCapturedExtendedPointers[0]);
SysCalls::mmapCapturedExtendedPointers.clear();
auto gmmHelper = memoryManager->getGmmHelper(mockRootDeviceIndex);
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTENDED_HOST), gmmHelper->decanonize(gpuAddress));
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED_HOST), gmmHelper->decanonize(gpuAddress));
EXPECT_LE(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapBase(HeapIndex::heapExtendedHost), gmmHelper->decanonize(gpuAddress));
EXPECT_GT(memoryManager->getGfxPartition(mockRootDeviceIndex)->getHeapLimit(HeapIndex::heapExtendedHost), gmmHelper->decanonize(gpuAddress));
EXPECT_NE(sharedUSM->getGpuAddress(), gpuAddress);
memoryManager->freeGraphicsMemory(sharedUSM);
@@ -7308,7 +7308,7 @@ TEST_F(DrmMemoryManagerTest, given57bAddressSpaceCpuAndGpuWhenAllocating48bResou
GTEST_SKIP();
}
auto mockGfxPartition = std::make_unique<MockGfxPartition>();
mockGfxPartition->initHeap(HeapIndex::HEAP_EXTENDED_HOST, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
mockGfxPartition->initHeap(HeapIndex::heapExtendedHost, maxNBitValue(48) + 1, MemoryConstants::teraByte, MemoryConstants::pageSize64k);
memoryManager->overrideGfxPartition(mockGfxPartition.release());
DebugManagerStateRestore restorer;
debugManager.flags.AllocateSharedAllocationsInHeapExtendedHost.set(true);

View File

@@ -1255,23 +1255,23 @@ TEST(WddmGfxPartitionTests, givenGfxPartitionWhenInitializedThenInternalFrontWin
wddm->init();
wddm->initGfxPartition(gfxPartition, rootDeviceIndex, numRootDevices, false);
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL));
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::heapInternalFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternal));
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceMemory));
auto frontWindowSize = GfxPartition::internalFrontWindowPoolSize;
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW), frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW), frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::heapInternalFrontWindow), frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::heapInternalDeviceFrontWindow), frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternalFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternalFrontWindow));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternalDeviceFrontWindow), gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceFrontWindow));
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL) + frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY) + frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternal), gfxPartition.getHeapBase(HeapIndex::heapInternal) + frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapMinimalAddress(HeapIndex::heapInternalDeviceMemory), gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceMemory) + frontWindowSize);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::HEAP_INTERNAL),
gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL) + gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL) - 1);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY),
gfxPartition.getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY) + gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY) - 1);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::heapInternal),
gfxPartition.getHeapBase(HeapIndex::heapInternal) + gfxPartition.getHeapSize(HeapIndex::heapInternal) - 1);
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::heapInternalDeviceMemory),
gfxPartition.getHeapBase(HeapIndex::heapInternalDeviceMemory) + gfxPartition.getHeapSize(HeapIndex::heapInternalDeviceMemory) - 1);
}
TEST(WddmGfxPartitionTests, givenInternalFrontWindowHeapWhenAllocatingSmallOrBigChunkThenAddressFromFrontIsReturned) {
@@ -1286,10 +1286,10 @@ TEST(WddmGfxPartitionTests, givenInternalFrontWindowHeapWhenAllocatingSmallOrBig
wddm->initGfxPartition(gfxPartition, rootDeviceIndex, numRootDevices, false);
const size_t sizeSmall = MemoryConstants::pageSize64k;
const size_t sizeBig = static_cast<size_t>(gfxPartition.getHeapSize(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW)) - MemoryConstants::pageSize64k;
const size_t sizeBig = static_cast<size_t>(gfxPartition.getHeapSize(HeapIndex::heapInternalFrontWindow)) - MemoryConstants::pageSize64k;
HeapIndex heaps[] = {HeapIndex::HEAP_INTERNAL_FRONT_WINDOW,
HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW};
HeapIndex heaps[] = {HeapIndex::heapInternalFrontWindow,
HeapIndex::heapInternalDeviceFrontWindow};
for (int i = 0; i < 2; i++) {
size_t sizeToAlloc = sizeSmall;

View File

@@ -1189,9 +1189,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValueOnSomeOfMultipleEngine
}
TEST_F(WddmMemoryManagerSimpleTest, givenWddmMemoryManagerWhenSelectAlignmentAndHeapCalledThenCorrectHeapReturned) {
HeapIndex heap = HeapIndex::HEAP_STANDARD;
HeapIndex heap = HeapIndex::heapStandard;
auto alignment = memoryManager->selectAlignmentAndHeap(MemoryConstants::pageSize64k, &heap);
EXPECT_EQ(heap, HeapIndex::HEAP_STANDARD64KB);
EXPECT_EQ(heap, HeapIndex::heapStandard64KB);
EXPECT_EQ(MemoryConstants::pageSize64k, alignment);
}
@@ -1199,9 +1199,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenWddmMemoryManagerWhenGpuAddressIsReserv
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 1;
HeapIndex heap = HeapIndex::HEAP_STANDARD;
HeapIndex heap = HeapIndex::heapStandard;
auto alignment = memoryManager->selectAlignmentAndHeap(MemoryConstants::pageSize64k, &heap);
EXPECT_EQ(heap, HeapIndex::HEAP_STANDARD64KB);
EXPECT_EQ(heap, HeapIndex::heapStandard64KB);
EXPECT_EQ(MemoryConstants::pageSize64k, alignment);
auto addressRange = memoryManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, heap, alignment);
auto gmmHelper = memoryManager->getGmmHelper(0);
@@ -1346,8 +1346,8 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMultiHandleAllocationAndPreferredGpuVaI
auto gmmSize = allocation.getDefaultGmm()->gmmResourceInfo->getSizeAllocation();
auto lastRequiredAddress = (numGmms - 1) * gmmSize + gpuPreferredVa;
EXPECT_EQ(lastRequiredAddress, wddm->mapGpuVirtualAddressResult.uint64ParamPassed);
EXPECT_GT(lastRequiredAddress, memoryManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::HEAP_SVM));
EXPECT_LT(lastRequiredAddress, memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_SVM));
EXPECT_GT(lastRequiredAddress, memoryManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::heapSvm));
EXPECT_LT(lastRequiredAddress, memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapSvm));
wddm->destroyAllocation(&allocation, nullptr);
}
@@ -1400,7 +1400,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenSvmCpuAllocationWhenSizeAndAlignmentPro
EXPECT_EQ(size, allocation->getUnderlyingBufferSize());
EXPECT_NE(nullptr, allocation->getUnderlyingBuffer());
EXPECT_EQ(allocation->getUnderlyingBuffer(), allocation->getDriverAllocatedCpuPtr());
// limited platforms will not use heap HeapIndex::HEAP_SVM
// limited platforms will not use heap HeapIndex::heapSvm
if (executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm()) {
EXPECT_EQ(alignUp(allocation->getReservedAddressPtr(), size), reinterpret_cast<void *>(allocation->getGpuAddress()));
}
@@ -1461,8 +1461,8 @@ TEST_F(WddmMemoryManagerSimpleTest, givenBufferHostMemoryAllocationAndLimitedRan
EXPECT_EQ(0ULL, gpuAddress & 0xffFFffF000000000);
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternal)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExternal)), gpuAddress);
memoryManager->freeGraphicsMemory(allocation);
}
@@ -1618,8 +1618,8 @@ TEST_F(WddmMemoryManagerSimpleTest, givenEnabledLocalMemoryWhenAllocatingMemoryI
EXPECT_TRUE(buffer->isAllocatedInLocalMemoryPool());
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
auto heapBase = gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD64KB));
auto heapLimit = gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB));
auto heapBase = gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard64KB));
auto heapLimit = gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard64KB));
EXPECT_NE(0u, buffer->getGpuAddress());
@@ -1635,8 +1635,8 @@ TEST_F(WddmMemoryManagerSimpleTest, givenEnabledLocalMemoryWhenAllocatingMemoryI
TEST_F(WddmMemoryManagerSimpleTest, whenWddmMemoryManagerIsCreatedThenAlignmentSelectorHasExpectedAlignments) {
std::vector<AlignmentSelector::CandidateAlignment> expectedAlignments = {
{MemoryConstants::pageSize2M, false, 0.1f, HeapIndex::TOTAL_HEAPS},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::TOTAL_HEAPS},
{MemoryConstants::pageSize2M, false, 0.1f, HeapIndex::totalHeaps},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::totalHeaps},
};
MockWddmMemoryManager memoryManager(true, true, executionEnvironment);
@@ -1648,7 +1648,7 @@ TEST_F(WddmMemoryManagerSimpleTest, given2MbPagesDisabledWhenWddmMemoryManagerIs
debugManager.flags.AlignLocalMemoryVaTo2MB.set(0);
std::vector<AlignmentSelector::CandidateAlignment> expectedAlignments = {
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::TOTAL_HEAPS},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::totalHeaps},
};
MockWddmMemoryManager memoryManager(true, true, executionEnvironment);
@@ -1661,9 +1661,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenCustomAlignmentWhenWddmMemoryManagerIsC
{
debugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.set(MemoryConstants::megaByte);
std::vector<AlignmentSelector::CandidateAlignment> expectedAlignments = {
{MemoryConstants::pageSize2M, false, 0.1f, HeapIndex::TOTAL_HEAPS},
{MemoryConstants::megaByte, false, AlignmentSelector::anyWastage, HeapIndex::TOTAL_HEAPS},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::TOTAL_HEAPS},
{MemoryConstants::pageSize2M, false, 0.1f, HeapIndex::totalHeaps},
{MemoryConstants::megaByte, false, AlignmentSelector::anyWastage, HeapIndex::totalHeaps},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::totalHeaps},
};
MockWddmMemoryManager memoryManager(true, true, executionEnvironment);
EXPECT_EQ(expectedAlignments, memoryManager.alignmentSelector.peekCandidateAlignments());
@@ -1672,9 +1672,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenCustomAlignmentWhenWddmMemoryManagerIsC
{
debugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.set(2 * MemoryConstants::pageSize2M);
std::vector<AlignmentSelector::CandidateAlignment> expectedAlignments = {
{2 * MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::TOTAL_HEAPS},
{MemoryConstants::pageSize2M, false, 0.1f, HeapIndex::TOTAL_HEAPS},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::TOTAL_HEAPS},
{2 * MemoryConstants::pageSize2M, false, AlignmentSelector::anyWastage, HeapIndex::totalHeaps},
{MemoryConstants::pageSize2M, false, 0.1f, HeapIndex::totalHeaps},
{MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage, HeapIndex::totalHeaps},
};
MockWddmMemoryManager memoryManager(true, true, executionEnvironment);
EXPECT_EQ(expectedAlignments, memoryManager.alignmentSelector.peekCandidateAlignments());
@@ -2256,7 +2256,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenSvmGpuAllocationWhenHostPtrProvidedThen
EXPECT_EQ(size, allocation->getUnderlyingBufferSize());
EXPECT_EQ(nullptr, allocation->getUnderlyingBuffer());
EXPECT_EQ(nullptr, allocation->getDriverAllocatedCpuPtr());
// limited platforms will not use heap HeapIndex::HEAP_SVM
// limited platforms will not use heap HeapIndex::heapSvm
if (executionEnvironment.rootDeviceEnvironments[0]->isFullRangeSvm()) {
EXPECT_EQ(svmPtr, reinterpret_cast<void *>(allocation->getGpuAddress()));
}
@@ -2793,8 +2793,8 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocateGraphicsMemory
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{mockRootDeviceIndex, true, size, AllocationType::buffer, mockDeviceBitfield}, ptr);
auto gfxPartition = memoryManager->getGfxPartition(mockRootDeviceIndex);
D3DGPU_VIRTUAL_ADDRESS svmRangeMinimumAddress = gfxPartition->getHeapMinimalAddress(HeapIndex::HEAP_SVM);
D3DGPU_VIRTUAL_ADDRESS svmRangeMaximumAddress = gfxPartition->getHeapLimit(HeapIndex::HEAP_SVM);
D3DGPU_VIRTUAL_ADDRESS svmRangeMinimumAddress = gfxPartition->getHeapMinimalAddress(HeapIndex::heapSvm);
D3DGPU_VIRTUAL_ADDRESS svmRangeMaximumAddress = gfxPartition->getHeapLimit(HeapIndex::heapSvm);
ASSERT_NE(nullptr, allocation);
EXPECT_FALSE(memoryManager->allocationGraphicsMemory64kbCreated);
@@ -2945,8 +2945,8 @@ TEST_F(WddmMemoryManagerTest, GivenNullptrWhenAllocating32BitMemoryThenAddressIs
ASSERT_NE(nullptr, gpuAllocation);
auto gmmHelper = memoryManager->getGmmHelper(gpuAllocation->getRootDeviceIndex());
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternal)), gpuAllocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExternal)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
EXPECT_EQ(0u, gpuAllocation->fragmentsStorage.fragmentCount);
memoryManager->freeGraphicsMemory(gpuAllocation);
@@ -2959,8 +2959,8 @@ TEST_F(WddmMemoryManagerTest, given32BitAllocationWhenItIsCreatedThenItHasNonZer
EXPECT_NE(0llu, gpuAllocation->getGpuAddressToPatch());
auto gmmHelper = memoryManager->getGmmHelper(gpuAllocation->getRootDeviceIndex());
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapExternal)), gpuAllocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapExternal)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
memoryManager->freeGraphicsMemory(gpuAllocation);
}
@@ -2975,8 +2975,8 @@ TEST_F(WddmMemoryManagerTest, GivenMisalignedHostPtrWhenAllocating32BitMemoryThe
EXPECT_EQ(alignSizeWholePage(misalignedPtr, misalignedSize), gpuAllocation->getUnderlyingBufferSize());
auto gmmHelper = memoryManager->getGmmHelper(gpuAllocation->getRootDeviceIndex());
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::heapExternal)), gpuAllocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::heapExternal)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
EXPECT_EQ(0u, gpuAllocation->fragmentsStorage.fragmentCount);
@@ -3188,7 +3188,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithNoRegisteredOsContextsWh
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerAnd32bitBuildThenSvmPartitionIsAlwaysInitialized) {
if (is32bit) {
EXPECT_EQ(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_SVM), MemoryConstants::max32BitAddress);
EXPECT_EQ(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapSvm), MemoryConstants::max32BitAddress);
}
}
@@ -3975,7 +3975,7 @@ TEST(WddmMemoryManagerTest3, givenDefaultWddmMemoryManagerWhenItIsQueriedForInte
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
wddm->init();
MockWddmMemoryManager memoryManager(executionEnvironment);
auto heapBase = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base;
auto heapBase = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::heapInternalDeviceMemory)].Base;
heapBase = std::max(heapBase, static_cast<uint64_t>(wddm->getWddmMinAddress()));
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress(0, true));
}

View File

@@ -52,18 +52,18 @@ TEST_F(WddmMemoryReservationTests, givenWddmMemoryManagerWhenGpuAddressIsReserve
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 1;
auto gmmHelper = memManager->getGmmHelper(0);
auto addressRange = memManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::HEAP_STANDARD64KB, MemoryConstants::pageSize64k);
auto addressRange = memManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::heapStandard64KB, MemoryConstants::pageSize64k);
EXPECT_EQ(rootDeviceIndexReserved, 0u);
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
memManager->freeGpuAddress(addressRange, 0);
addressRange = memManager->reserveGpuAddress(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_EQ(rootDeviceIndexReserved, 0u);
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
memManager->freeGpuAddress(addressRange, 0);
}
@@ -73,20 +73,20 @@ TEST_F(WddmMemoryReservationTests, givenWddmMemoryManagerWhenGpuAddressIsReserve
uint32_t rootDeviceIndexReserved = 1;
uint64_t invalidAddress = 0x1234;
auto gmmHelper = memManager->getGmmHelper(0);
auto addressRange = memManager->reserveGpuAddressOnHeap(invalidAddress, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::HEAP_STANDARD64KB, MemoryConstants::pageSize64k);
auto addressRange = memManager->reserveGpuAddressOnHeap(invalidAddress, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::heapStandard64KB, MemoryConstants::pageSize64k);
EXPECT_NE(invalidAddress, addressRange.address);
EXPECT_EQ(rootDeviceIndexReserved, 0u);
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
memManager->freeGpuAddress(addressRange, 0);
addressRange = memManager->reserveGpuAddress(invalidAddress, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved);
EXPECT_NE(invalidAddress, addressRange.address);
EXPECT_EQ(rootDeviceIndexReserved, 0u);
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
memManager->freeGpuAddress(addressRange, 0);
}
@@ -95,15 +95,15 @@ TEST_F(WddmMemoryReservationTests, givenWddmMemoryManagerWhenGpuAddressIsReserve
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 1;
auto gmmHelper = memManager->getGmmHelper(0);
auto addressRange = memManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::HEAP_STANDARD64KB, MemoryConstants::pageSize64k);
auto addressRange = memManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::heapStandard64KB, MemoryConstants::pageSize64k);
auto previousAddress = addressRange.address;
memManager->freeGpuAddress(addressRange, 0);
auto newAddressRange = memManager->reserveGpuAddressOnHeap(previousAddress, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::HEAP_STANDARD64KB, MemoryConstants::pageSize64k);
auto newAddressRange = memManager->reserveGpuAddressOnHeap(previousAddress, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::heapStandard64KB, MemoryConstants::pageSize64k);
EXPECT_EQ(previousAddress, addressRange.address);
EXPECT_EQ(rootDeviceIndexReserved, 0u);
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
memManager->freeGpuAddress(addressRange, 0);
addressRange = memManager->reserveGpuAddress(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved);
@@ -113,8 +113,8 @@ TEST_F(WddmMemoryReservationTests, givenWddmMemoryManagerWhenGpuAddressIsReserve
EXPECT_EQ(previousAddress, addressRange.address);
EXPECT_EQ(rootDeviceIndexReserved, 0u);
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_LE(memManager->getGfxPartition(0)->getHeapBase(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
EXPECT_GT(memManager->getGfxPartition(0)->getHeapLimit(HeapIndex::heapStandard64KB), gmmHelper->decanonize(addressRange.address));
memManager->freeGpuAddress(addressRange, 0);
}
@@ -136,7 +136,7 @@ TEST(WddmMemoryReservationFailTest, givenWddmMemoryManagerWhenGpuAddressReservat
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 1;
auto addressRange = memManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::HEAP_STANDARD64KB, MemoryConstants::pageSize64k);
auto addressRange = memManager->reserveGpuAddressOnHeap(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved, HeapIndex::heapStandard64KB, MemoryConstants::pageSize64k);
EXPECT_EQ(addressRange.address, 0ull);
EXPECT_EQ(addressRange.size, 0u);
addressRange = memManager->reserveGpuAddress(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved);

View File

@@ -139,8 +139,8 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddr
size_t alignedSize = 0x2000;
std::unique_ptr<Gmm> gmm(GmmHelperFunctionsWindows::getGmm(alignedPtr, alignedSize, getGmmHelper()));
uint64_t gpuAddress = 0u;
auto heapBase = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base;
auto heapLimit = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Limit;
auto heapBase = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::heapInternalDeviceMemory)].Base;
auto heapLimit = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::heapInternalDeviceMemory)].Limit;
bool ret = wddm->mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, heapBase, heapLimit, 0u, gpuAddress);
EXPECT_TRUE(ret);
@@ -172,8 +172,8 @@ TEST(WddmGfxPartitionTests, WhenInitializingGfxPartitionThen64KBHeapsAreUsed) {
wddm->initGfxPartition(gfxPartition, rootDeviceIndex, numRootDevices, false);
auto heapStandard64KBSize = alignDown((wddm->gfxPartition.Standard64KB.Limit - wddm->gfxPartition.Standard64KB.Base + 1) / numRootDevices, GfxPartition::heapGranularity);
EXPECT_EQ(heapStandard64KBSize, gfxPartition.getHeapSize(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(wddm->gfxPartition.Standard64KB.Base + rootDeviceIndex * heapStandard64KBSize, gfxPartition.getHeapBase(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(heapStandard64KBSize, gfxPartition.getHeapSize(HeapIndex::heapStandard64KB));
EXPECT_EQ(wddm->gfxPartition.Standard64KB.Base + rootDeviceIndex * heapStandard64KBSize, gfxPartition.getHeapBase(HeapIndex::heapStandard64KB));
}
namespace NEO {
@@ -319,7 +319,7 @@ TEST_F(WddmGfxPartitionTest, WhenInitializingGfxPartitionThenAllHeapsAreInitiali
for (auto heap : MockGfxPartition::allHeapNames) {
if (!gfxPartition.heapInitialized(heap)) {
EXPECT_TRUE(heap == HeapIndex::HEAP_SVM || heap == HeapIndex::HEAP_STANDARD2MB || heap == HeapIndex::HEAP_EXTENDED);
EXPECT_TRUE(heap == HeapIndex::heapSvm || heap == HeapIndex::heapStandard2MB || heap == HeapIndex::heapExtended);
} else {
EXPECT_TRUE(gfxPartition.heapInitialized(heap));
}