fix: allow creating hostptr allocations with GPU VA equal hostptr

- when host USM memory is allocated, gpu virtual address should be the
same as cpu address when chunking due to huge size is used

Related-To: GSD-11423

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2025-09-16 16:07:20 +00:00
committed by Compute-Runtime-Automation
parent 749ca98226
commit 0f657e8877
3 changed files with 21 additions and 2 deletions

View File

@@ -494,7 +494,8 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const AllocationData &allocationData) {
if (allocationData.size > getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::useUmdSystemPtr)) {
return allocateHugeGraphicsMemory(allocationData, false);
bool isUSMHostAllocation = allocationData.flags.isUSMHostAllocation;
return allocateHugeGraphicsMemory(allocationData, isUSMHostAllocation);
}
if (mallocRestrictions.minAddress > reinterpret_cast<uintptr_t>(allocationData.hostPtr)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2024 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -21,6 +21,7 @@ class MockWddmMemoryManager : public MemoryManagerCreate<WddmMemoryManager> {
using BaseClass::allocateGraphicsMemoryForNonSvmHostPtr;
using BaseClass::allocateGraphicsMemoryWithAlignment;
using BaseClass::allocateGraphicsMemoryWithGpuVa;
using BaseClass::allocateGraphicsMemoryWithHostPtr;
using BaseClass::allocateGraphicsMemoryWithProperties;
using BaseClass::allocateMemoryByKMD;
using BaseClass::allocatePhysicalDeviceMemory;

View File

@@ -1181,6 +1181,23 @@ TEST_F(WddmMemoryManagerSimpleTest, GivenShareableEnabledAndHugeSizeWhenAskedToC
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(WddmMemoryManagerSimpleTest, GivenHostUsmWithHostPtrWhenAllocatingGraphicsMemoryThenGpuVaIsSameAsHostPtr) {
memoryManager.reset(new MockWddmMemoryManager(false, false, executionEnvironment));
memoryManager->hugeGfxMemoryChunkSize = MemoryConstants::pageSize64k;
AllocationData allocationData;
allocationData.size = 2ULL * MemoryConstants::pageSize64k;
allocationData.flags.isUSMHostAllocation = true;
auto memory = alignedMalloc(allocationData.size, MemoryConstants::pageSize);
allocationData.hostPtr = memory;
auto allocation = memoryManager->allocateGraphicsMemoryWithHostPtr(allocationData);
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(reinterpret_cast<uint64_t>(memory), allocation->getGpuAddress());
EXPECT_EQ(NEO::MemoryPool::system4KBPages, allocation->getMemoryPool());
memoryManager->freeGraphicsMemory(allocation);
alignedFree(memory);
}
TEST_F(WddmMemoryManagerSimpleTest, GivenMemoryManagerWhenAllocateByKmdThenAlignmentIsCorrect) {
memoryManager.reset(new MockWddmMemoryManager(false, false, executionEnvironment));
AllocationData allocationData;