refactor: split gmm memory definitions

Related-To: NEO-11080

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2025-10-23 09:15:14 +00:00
committed by Compute-Runtime-Automation
parent e05d9ed529
commit 5f5c08b7a7
7 changed files with 52 additions and 28 deletions

View File

@@ -6,7 +6,8 @@
set(NEO_CORE_GMM_HELPER_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/gmm_memory.h
${CMAKE_CURRENT_SOURCE_DIR}/gmm_memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}gmm_memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gmm_memory_base.cpp
)
add_subdirectories()

View File

@@ -7,14 +7,9 @@
#include "shared/source/gmm_helper/windows/gmm_memory.h"
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/windows/windows_defs.h"
namespace NEO {
GmmMemory::GmmMemory(GmmClientContext *gmmClientContext) : clientContext(*gmmClientContext->getHandle()) {
}
bool GmmMemory::configureDevice(GMM_ESCAPE_HANDLE hAdapter,
GMM_ESCAPE_HANDLE hDevice,
GMM_ESCAPE_FUNC_TYPE pfnEscape,
@@ -22,7 +17,6 @@ bool GmmMemory::configureDevice(GMM_ESCAPE_HANDLE hAdapter,
BOOLEAN bdwL3Coherency,
uintptr_t &minAddress,
bool obtainMinAddress) {
minAddress = windowsMinAddress;
auto retVal = configureDeviceAddressSpace(hAdapter, hDevice, pfnEscape, svmSize, bdwL3Coherency);
if (obtainMinAddress) {
minAddress = getInternalGpuVaRangeLimit();

View File

@@ -0,0 +1,14 @@
/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
#include "shared/source/gmm_helper/windows/gmm_memory.h"
namespace NEO {
GmmMemory::GmmMemory(GmmClientContext *gmmClientContext) : clientContext(*gmmClientContext->getHandle()) {
}
}; // namespace NEO

View File

@@ -58,6 +58,7 @@ bool Wddm::configureDeviceAddressSpace() {
if (!hardwareInfoTable[productFamily]) {
return false;
}
minAddress = windowsMinAddress;
auto svmSize = hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace >= MemoryConstants::max64BitAppAddress
? maximumApplicationAddress + 1u
: 0u;

View File

@@ -25,6 +25,7 @@ if(WIN32)
${CMAKE_CURRENT_SOURCE_DIR}/self_lib_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/um_km_data_translator_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/${BRANCH_DIR_SUFFIX}wddm_additional_apater_info_options_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/${BRANCH_DIR_SUFFIX}wddm_configure_device_address_space_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_address_space_windows_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_command_stream_l0_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests.cpp

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
TEST_F(WddmInstrumentationTest, whenConfiguringDeviceAddressSpaceThenTrueIsReturned) {
SYSTEM_INFO sysInfo = {};
WddmMock::getSystemInfo(&sysInfo);
D3DKMT_HANDLE adapterHandle = ADAPTER_HANDLE;
D3DKMT_HANDLE deviceHandle = DEVICE_HANDLE;
const HardwareInfo hwInfo = *defaultHwInfo;
BOOLEAN ftrL3IACoherency = hwInfo.featureTable.flags.ftrL3IACoherency ? 1 : 0;
uintptr_t maxAddr = hwInfo.capabilityTable.gpuAddressSpace >= MemoryConstants::max64BitAppAddress
? reinterpret_cast<uintptr_t>(sysInfo.lpMaximumApplicationAddress) + 1
: 0;
wddm->init();
EXPECT_EQ(1u, gmmMem->configureDeviceAddressSpaceCalled);
EXPECT_EQ(adapterHandle, gmmMem->configureDeviceAddressSpaceParamsPassed[0].hAdapter);
EXPECT_EQ(deviceHandle, gmmMem->configureDeviceAddressSpaceParamsPassed[0].hDevice);
EXPECT_EQ(wddm->getGdi()->escape.mFunc, gmmMem->configureDeviceAddressSpaceParamsPassed[0].pfnEscape);
EXPECT_EQ(maxAddr, gmmMem->configureDeviceAddressSpaceParamsPassed[0].svmSize);
EXPECT_EQ(ftrL3IACoherency, gmmMem->configureDeviceAddressSpaceParamsPassed[0].bdwL3Coherency);
}

View File

@@ -95,27 +95,6 @@ TEST(Wddm20EnumAdaptersTest, givenEmptyHardwareInfoWhenEnumAdapterIsCalledThenCa
EXPECT_EQ(outHwInfo.capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds, hwInfo->capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds);
}
HWTEST_F(Wddm20InstrumentationTest, WhenConfiguringDeviceAddressSpaceThenTrueIsReturned) {
SYSTEM_INFO sysInfo = {};
WddmMock::getSystemInfo(&sysInfo);
D3DKMT_HANDLE adapterHandle = ADAPTER_HANDLE;
D3DKMT_HANDLE deviceHandle = DEVICE_HANDLE;
const HardwareInfo hwInfo = *defaultHwInfo;
BOOLEAN ftrL3IACoherency = hwInfo.featureTable.flags.ftrL3IACoherency ? 1 : 0;
uintptr_t maxAddr = hwInfo.capabilityTable.gpuAddressSpace >= MemoryConstants::max64BitAppAddress
? reinterpret_cast<uintptr_t>(sysInfo.lpMaximumApplicationAddress) + 1
: 0;
wddm->init();
EXPECT_EQ(1u, gmmMem->configureDeviceAddressSpaceCalled);
EXPECT_EQ(adapterHandle, gmmMem->configureDeviceAddressSpaceParamsPassed[0].hAdapter);
EXPECT_EQ(deviceHandle, gmmMem->configureDeviceAddressSpaceParamsPassed[0].hDevice);
EXPECT_EQ(wddm->getGdi()->escape.mFunc, gmmMem->configureDeviceAddressSpaceParamsPassed[0].pfnEscape);
EXPECT_EQ(maxAddr, gmmMem->configureDeviceAddressSpaceParamsPassed[0].svmSize);
EXPECT_EQ(ftrL3IACoherency, gmmMem->configureDeviceAddressSpaceParamsPassed[0].bdwL3Coherency);
}
TEST_F(Wddm20Tests, givenSuccessWhenRegisteringTrimCallbackThenReturnTrimCallbackHandle) {
auto trimCallbackHandle = wddm->registerTrimCallback([](D3DKMT_TRIMNOTIFICATION *) {});
EXPECT_NE(nullptr, trimCallbackHandle);