From 5d9467b7532caff3be42583e5f90489d0287ce95 Mon Sep 17 00:00:00 2001 From: Slawomir Milczarek Date: Tue, 20 Oct 2020 12:37:09 +0200 Subject: [PATCH] Make the EnableVaLibCalls debug key tri-state (-1/0/1) Related-To: NEO-5110 Change-Id: I56b709e266a091fca68b55ff136690d673773734 Signed-off-by: Slawomir Milczarek --- .../sharings/va/va_sharing_functions.cpp | 7 ++++- .../sharings/va/va_sharing_linux_tests.cpp | 31 +++++++++++++++++++ .../test/unit_test/test_files/igdrcl.config | 2 +- .../debug_settings/debug_variables_base.inl | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/opencl/source/sharings/va/va_sharing_functions.cpp b/opencl/source/sharings/va/va_sharing_functions.cpp index dd883aa234..7b3a0bed1d 100644 --- a/opencl/source/sharings/va/va_sharing_functions.cpp +++ b/opencl/source/sharings/va/va_sharing_functions.cpp @@ -43,7 +43,12 @@ bool VASharingFunctions::isVaLibraryAvailable() { } void VASharingFunctions::initFunctions() { - if (DebugManager.flags.EnableVaLibCalls.get()) { + bool enableVaLibCalls = true; + if (DebugManager.flags.EnableVaLibCalls.get() != -1) { + enableVaLibCalls = !!DebugManager.flags.EnableVaLibCalls.get(); + } + + if (enableVaLibCalls) { libHandle = fdlopen(Os::libvaDllName, RTLD_LAZY); if (libHandle) { vaDisplayIsValidPFN = reinterpret_cast(fdlsym(libHandle, "vaDisplayIsValid")); diff --git a/opencl/test/unit_test/sharings/va/va_sharing_linux_tests.cpp b/opencl/test/unit_test/sharings/va/va_sharing_linux_tests.cpp index 6b5bcd0b92..53c2694aa1 100644 --- a/opencl/test/unit_test/sharings/va/va_sharing_linux_tests.cpp +++ b/opencl/test/unit_test/sharings/va/va_sharing_linux_tests.cpp @@ -90,6 +90,37 @@ TEST(VASharingFunctions, GivenInitFunctionsWhenDLOpenSuccedsThenFunctionsAreNotN EXPECT_TRUE(functions.wereFunctionsAssigned()); } +TEST(VASharingFunctions, GivenInitFunctionsWhenEnableVaLibCallsThenFunctionsAreAssigned) { + DebugManagerStateRestore restorer; + + VariableBackup dlopenBackup(&VASharingFunctions::fdlopen); + VariableBackup dlsymBackup(&VASharingFunctions::fdlsym); + VariableBackup dlcloseBackup(&VASharingFunctions::fdlclose); + + std::unique_ptr valib(new uint32_t); + ASSERT_NE(nullptr, valib.get()); + + VASharingFunctions::fdlopen = [&](const char *filename, int flag) -> void * { + return valib.get(); + }; + + VASharingFunctions::fdlsym = [&](void *handle, const char *symbol) -> void * { + return (void *)GetLibFunc; + }; + + VASharingFunctions::fdlclose = [&](void *handle) -> int { + return 0; + }; + + EXPECT_EQ(-1, DebugManager.flags.EnableVaLibCalls.get()); + VASharingFunctionsTested functionsWithDefaultVaLibCalls; + EXPECT_TRUE(functionsWithDefaultVaLibCalls.wereFunctionsAssigned()); + + DebugManager.flags.EnableVaLibCalls.set(1); + VASharingFunctionsTested functionsWithEnabledVaLibCalls; + EXPECT_TRUE(functionsWithEnabledVaLibCalls.wereFunctionsAssigned()); +} + TEST(VASharingFunctions, GivenFunctionsWhenNoLibvaThenDlcloseNotCalled) { VariableBackup dlopenBackup(&VASharingFunctions::fdlopen); VariableBackup dlsymBackup(&VASharingFunctions::fdlsym); diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index f933c2f114..016ef30e90 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -113,7 +113,7 @@ EnableGemCloseWorker = -1 EnableComputeWorkSizeND = 1 EnableMultiRootDeviceContexts = 0 EnableComputeWorkSizeSquared = 0 -EnableVaLibCalls = 1 +EnableVaLibCalls = -1 EnableExtendedVaFormats = 0 AddClGlSharing = 0 EnableFormatQuery = 0 diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 0341fac902..5790d04d69 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -158,7 +158,6 @@ DECLARE_DEBUG_VARIABLE(bool, EnableForcePin, true, "Enables early pinning for me DECLARE_DEBUG_VARIABLE(bool, EnableComputeWorkSizeND, true, "Enables diffrent algorithm to compute local work size") DECLARE_DEBUG_VARIABLE(bool, EnableMultiRootDeviceContexts, false, "Enables support for multi root device contexts") DECLARE_DEBUG_VARIABLE(bool, EnableComputeWorkSizeSquared, false, "Enables algorithm to compute the most squared work group as possible") -DECLARE_DEBUG_VARIABLE(bool, EnableVaLibCalls, true, "Enable cl-va sharing lib calls") DECLARE_DEBUG_VARIABLE(bool, EnableExtendedVaFormats, false, "Enable more formats in cl-va sharing") DECLARE_DEBUG_VARIABLE(bool, AddClGlSharing, false, "Add cl-gl extension") DECLARE_DEBUG_VARIABLE(bool, EnableFormatQuery, false, "Enable sharing format querying") @@ -173,6 +172,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableBlitterOperationsForReadWriteBuffers, -1, DECLARE_DEBUG_VARIABLE(int32_t, EnableCacheFlushAfterWalker, -1, "-1: platform behavior, 0: disabled, 1: enabled. Adds dedicated cache flush command after WALKER command when surfaces used by kernel require to flush the cache") DECLARE_DEBUG_VARIABLE(int32_t, EnableLocalMemory, -1, "-1: default behavior, 0: disabled, 1: enabled, Allows allocating graphics memory in Local Memory") DECLARE_DEBUG_VARIABLE(int32_t, EnableStatelessToStatefulBufferOffsetOpt, -1, "-1: dont override, 0: disable, 1: enable, Enables buffer-offset improvement of the stateless to stateful optimization") +DECLARE_DEBUG_VARIABLE(int32_t, EnableVaLibCalls, -1, "-1: default, 0: disable, 1: enable cl-va sharing lib calls") DECLARE_DEBUG_VARIABLE(int32_t, CreateMultipleRootDevices, 0, "0: default - disable, 1+: Driver will create multiple (N) devices during initialization.") DECLARE_DEBUG_VARIABLE(int32_t, CreateMultipleSubDevices, 0, "0: default - disable, 1+: Driver will create multiple (N) sub devices during initialization.") DECLARE_DEBUG_VARIABLE(int32_t, LimitAmountOfReturnedDevices, 0, "0: default - disable, 1+: Driver will limit the number of devices returned from clGetDeviceIds to N.")