From 50fcb45038b29cc9816078c157bfc324a90b66d3 Mon Sep 17 00:00:00 2001 From: Brandon Yates Date: Wed, 17 Jul 2024 15:24:49 +0000 Subject: [PATCH] feature: Disable per context VMs with debugger in heapless mode Related-to: NEO-11791 Signed-off-by: Brandon Yates --- .../test/unit_test/linux/main_linux_dll.cpp | 16 +++++++ shared/source/dll/linux/drm_neo_create.cpp | 5 +- .../mocks/mock_compiler_product_helper.h | 46 +++++++++++++++++++ .../common/test_macros/mock_method_macros.h | 6 ++- 4 files changed, 70 insertions(+), 3 deletions(-) diff --git a/opencl/test/unit_test/linux/main_linux_dll.cpp b/opencl/test/unit_test/linux/main_linux_dll.cpp index f9712cc905..a27cddf19d 100644 --- a/opencl/test/unit_test/linux/main_linux_dll.cpp +++ b/opencl/test/unit_test/linux/main_linux_dll.cpp @@ -24,7 +24,9 @@ #include "shared/test/common/helpers/ult_hw_config.inl" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/libult/signal_utils.h" +#include "shared/test/common/mocks/mock_compiler_product_helper.h" #include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/mocks/mock_release_helper.h" #include "shared/test/common/os_interface/linux/device_command_stream_fixture.h" #include "shared/test/common/test_macros/hw_test.h" @@ -744,6 +746,20 @@ TEST_F(DrmTests, givenEnabledDebuggingAndVmBindNotAvailableWhenDrmIsCreatedThenP EXPECT_TRUE(hasSubstr(errStr, std::string("WARNING: Debugging not supported\n"))); } +TEST_F(DrmTests, givenEnabledDebuggingAndHeaplessModeWhenDrmIsCreatedThenPerContextVMIsFalse) { + + mockRootDeviceEnvironment->executionEnvironment.setDebuggingMode(NEO::DebuggingMode::online); + auto compilerHelper = std::unique_ptr(new MockCompilerProductHelper()); + auto releaseHelper = std::unique_ptr(new MockReleaseHelper()); + compilerHelper->isHeaplessModeEnabledResult = true; + mockRootDeviceEnvironment->compilerProductHelper.reset(compilerHelper.release()); + mockRootDeviceEnvironment->releaseHelper.reset(releaseHelper.release()); + + auto drm = DrmWrap::createDrm(*mockRootDeviceEnvironment); + EXPECT_NE(drm, nullptr); + EXPECT_FALSE(drm->isPerContextVMRequired()); +} + TEST_F(DrmTests, givenDrmIsCreatedWhenCreateVirtualMemoryFailsThenReturnVirtualMemoryIdZeroAndPrintDebugMessage) { DebugManagerStateRestore dbgRestorer; debugManager.flags.PrintDebugMessages.set(true); diff --git a/shared/source/dll/linux/drm_neo_create.cpp b/shared/source/dll/linux/drm_neo_create.cpp index 7d701e98cd..f2287759c1 100644 --- a/shared/source/dll/linux/drm_neo_create.cpp +++ b/shared/source/dll/linux/drm_neo_create.cpp @@ -9,6 +9,7 @@ #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/helpers/compiler_product_helper_base.inl" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/os_interface/device_factory.h" @@ -77,8 +78,8 @@ Drm *Drm::create(std::unique_ptr &&hwDeviceId, RootDeviceEnvironm drm->checkContextDebugSupport(); drm->queryPageFaultSupport(); - - if (rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled()) { + auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + if (rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled() && !compilerProductHelper.isHeaplessModeEnabled()) { if (drm->getRootDeviceEnvironment().executionEnvironment.getDebuggingMode() == DebuggingMode::offline) { drm->setPerContextVMRequired(false); } else { diff --git a/shared/test/common/mocks/mock_compiler_product_helper.h b/shared/test/common/mocks/mock_compiler_product_helper.h index 0fae440968..11104d846c 100644 --- a/shared/test/common/mocks/mock_compiler_product_helper.h +++ b/shared/test/common/mocks/mock_compiler_product_helper.h @@ -6,6 +6,7 @@ */ #include "shared/source/helpers/compiler_product_helper.h" +#include "shared/test/common/test_macros/mock_method_macros.h" namespace NEO { template @@ -19,4 +20,49 @@ class MockCompilerProductHelperHeaplessHw : public CompilerProductHelperHw; + ADDMETHOD_CONST_NOBASE(getDeviceOpenCLCVersions, getDeviceOpenCLCVersionsRetType, {}, (const HardwareInfo &hwInfo, OclCVersion max)); + ADDMETHOD_CONST_NOBASE_VOIDRETURN(adjustHwInfoForIgc, (HardwareInfo & hwInfo)); + ADDMETHOD_CONST_NOBASE(isHeaplessModeEnabled, bool, false, ()); + ADDMETHOD_CONST_NOBASE(isHeaplessStateInitEnabled, bool, false, (bool heaplessModeEnabled)); + ADDMETHOD_CONST_NOBASE_VOIDRETURN(getKernelFp16AtomicCapabilities, (const ReleaseHelper *releaseHelper, uint32_t &fp16Caps)); + ADDMETHOD_CONST_NOBASE_VOIDRETURN(getKernelFp32AtomicCapabilities, (uint32_t & fp32Caps)); + ADDMETHOD_CONST_NOBASE_VOIDRETURN(getKernelFp64AtomicCapabilities, (uint32_t & fp64Caps)); + ADDMETHOD_CONST_NOBASE_VOIDRETURN(getKernelCapabilitiesExtra, (const ReleaseHelper *releaseHelper, uint32_t &extraCaps)); + ADDMETHOD_CONST_NOBASE(isBindlessAddressingDisabled, bool, false, (const ReleaseHelper *releaseHelper)); + + ADDMETHOD_CONST_NOBASE(getProductConfigFromHwInfo, uint32_t, 0, (const HardwareInfo &hwInfo)); +}; + } // namespace NEO diff --git a/shared/test/common/test_macros/mock_method_macros.h b/shared/test/common/test_macros/mock_method_macros.h index 5d71f14c29..e7b4e045a7 100644 --- a/shared/test/common/test_macros/mock_method_macros.h +++ b/shared/test/common/test_macros/mock_method_macros.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -30,6 +30,10 @@ funcName##Called++; \ } +#define ADDMETHOD_CONST_NOBASE_VOIDRETURN(funcName, funcParams) \ + void funcName funcParams const override { \ + } + #define ADDMETHOD_NOBASE_REFRETURN(funcName, retType, funcParams) \ std::remove_reference::type *funcName##ResultPtr = nullptr; \ uint32_t funcName##Called = 0u; \