diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index c353eaf029..c17a778d0f 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -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(allocationData.hostPtr)) { diff --git a/shared/test/common/os_interface/windows/mock_wddm_memory_manager.h b/shared/test/common/os_interface/windows/mock_wddm_memory_manager.h index 8b0c476eb1..bb2619bd9e 100644 --- a/shared/test/common/os_interface/windows/mock_wddm_memory_manager.h +++ b/shared/test/common/os_interface/windows/mock_wddm_memory_manager.h @@ -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 { using BaseClass::allocateGraphicsMemoryForNonSvmHostPtr; using BaseClass::allocateGraphicsMemoryWithAlignment; using BaseClass::allocateGraphicsMemoryWithGpuVa; + using BaseClass::allocateGraphicsMemoryWithHostPtr; using BaseClass::allocateGraphicsMemoryWithProperties; using BaseClass::allocateMemoryByKMD; using BaseClass::allocatePhysicalDeviceMemory; diff --git a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index 11ab303814..cbfd4f55a3 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -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(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;