diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 859c96827d..b3f06109ea 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -99,6 +99,7 @@ DECLARE_DEBUG_VARIABLE(std::string, OverrideDeviceName, std::string("unk"), "Ove DECLARE_DEBUG_VARIABLE(std::string, OverridePlatformName, std::string("unk"), "Override platform name to provided string; ignored when unk") DECLARE_DEBUG_VARIABLE(std::string, WddmResidencyLoggerOutputDirectory, std::string("unk"), "Selects non-default output directory for Wddm Residency logger file") DECLARE_DEBUG_VARIABLE(std::string, ToggleBitIn57GpuVa, std::string("unk"), "Toggles specific bit in GPU VA for given allocation type from heap extended. Format :,:") +DECLARE_DEBUG_VARIABLE(std::string, DisableIndirectDetectionForKernelNames, std::string("unk"), "If kernel name contains flag value (pass part of kernel name) OR flag value contains kernel name (pass list of exact names), disable indirect detection for it; ignored when unk") DECLARE_DEBUG_VARIABLE(int64_t, OverrideMultiStoragePlacement, -1, "Place memory only in selected tiles indicated by bit mask; ignore when -1") DECLARE_DEBUG_VARIABLE(int64_t, ForceCompressionDisabledForCompressedBlitCopies, -1, "If compression is required, set AUX_CCS_E, but force CompressionEnable filed; 0 should result in uncompressed read/write; values = -1: default, 0: disabled, 1: enabled") DECLARE_DEBUG_VARIABLE(int64_t, WddmPagingFenceCpuWaitDelayTime, 0, "Amount of microseconds after waitng for paging fence on CPU") @@ -300,6 +301,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideTimestampWidth, -1, "-1: default from KM DECLARE_DEBUG_VARIABLE(int32_t, DebugUmdFifoPollInterval, -1, "-1: default , > 0: Fifo will be polled based on input in milliseconds.") DECLARE_DEBUG_VARIABLE(int32_t, DebugUmdInterruptTimeout, -1, "-1: default , > 0: interruptTimeout based on input in milliseconds. Default is 2000 milliseconds") DECLARE_DEBUG_VARIABLE(int32_t, DebugUmdMaxReadWriteRetry, -1, "-1: default , > 0: max pread/pwrite retry attempts in read/writeGpuMemory calls based on input in milliseconds. Default is 3") +DECLARE_DEBUG_VARIABLE(int32_t, ForceIndirectDetectionForCMKernels, -1, "-1: default , 0 : disable indirect detection for CM kernels, 1 : enable indirect detection for CM kernels") DECLARE_DEBUG_VARIABLE(bool, ForceUseOnlyGlobalTimestamps, 0, "0- default disabled, 1: enable use only global timestamp") /*LOGGING FLAGS*/ @@ -353,6 +355,7 @@ DECLARE_DEBUG_VARIABLE(bool, PrintGmmCompressionParams, false, "Print Gmm compre DECLARE_DEBUG_VARIABLE(bool, PrintCpuFlags, false, "Print CPU Flags and properties upon detection") DECLARE_DEBUG_VARIABLE(int32_t, PrintL0MetricLogs, 0, "L0 Metrics logs mask. 0 - Disabled, 1 - ERROR, 3 - INFO, 7 - DEBUG") DECLARE_DEBUG_VARIABLE(bool, PrintL0SetKernelArg, false, "Print L0 Set Kernel Arg data") +DECLARE_DEBUG_VARIABLE(bool, LogIndirectDetectionKernelDetails, false, "Log information for indirect detection for each kernel") /*PERFORMANCE FLAGS*/ DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForBuffers, false, "When active all buffer allocations will not share memory with CPU.") diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index ef37659656..4404e6ff7a 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -15,6 +15,7 @@ #include "shared/source/helpers/definitions/indirect_detection_versions.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/hw_mapper.h" +#include "shared/source/helpers/kernel_helpers.h" #include "shared/source/helpers/local_memory_access_modes.h" #include "shared/source/helpers/preamble.h" #include "shared/source/kernel/kernel_descriptor.h" @@ -26,6 +27,7 @@ #include "shared/source/os_interface/product_helper_hw.h" #include "shared/source/release_helper/release_helper.h" #include "shared/source/unified_memory/usm_memory_support.h" +#include "shared/source/utilities/logger.h" #include "aubstream/engine_node.h" #include "ocl_igc_shared/indirect_access_detection/version.h" @@ -76,6 +78,30 @@ bool ProductHelperHw::isDetectIndirectAccessInKernelSupported(const const bool isZebin = kernelDescriptor.kernelAttributes.binaryFormat == DeviceBinaryFormat::zebin; const auto currentIndirectDetectionVersion = isPrecompiled ? precompiledKernelIndirectDetectionVersion : INDIRECT_ACCESS_DETECTION_VERSION; bool indirectDetectionValid = false; + NEO::fileLoggerInstance().log(!!debugManager.flags.LogIndirectDetectionKernelDetails.get(), + "kernelName,", kernelDescriptor.kernelMetadata.kernelName, + "isPrecompiled,", isPrecompiled, + "isZebin,", isZebin, + "isCMKernelHeuristic,", isCMKernelHeuristic, + "driver indirect detection version,", INDIRECT_ACCESS_DETECTION_VERSION, + "precompiled kernel indirect detection version,", precompiledKernelIndirectDetectionVersion, + "hasNonKernelArgLoad,", kernelDescriptor.kernelAttributes.hasNonKernelArgLoad, + "hasNonKernelArgStore,", kernelDescriptor.kernelAttributes.hasNonKernelArgStore, + "hasNonKernelArgAtomic,", kernelDescriptor.kernelAttributes.hasNonKernelArgAtomic, + "hasIndirectStatelessAccess,", kernelDescriptor.kernelAttributes.hasIndirectStatelessAccess, + "hasIndirectAccessInImplicitArg,", kernelDescriptor.kernelAttributes.hasIndirectAccessInImplicitArg, + "useStackCalls,", kernelDescriptor.kernelAttributes.flags.useStackCalls, + "isAnyArgumentPtrByValue,", KernelHelper::isAnyArgumentPtrByValue(kernelDescriptor), + "\n"); + if (debugManager.flags.DisableIndirectDetectionForKernelNames.get() != "unk") { + if (kernelDescriptor.kernelMetadata.kernelName.find(debugManager.flags.DisableIndirectDetectionForKernelNames.get()) != std::string::npos || + debugManager.flags.DisableIndirectDetectionForKernelNames.get().find(kernelDescriptor.kernelMetadata.kernelName) != std::string::npos) { + return false; + } + } + if (isCMKernelHeuristic && debugManager.flags.ForceIndirectDetectionForCMKernels.get() != -1) { + return debugManager.flags.ForceIndirectDetectionForCMKernels.get() == 1; + } if (isCMKernelHeuristic) { if (IndirectDetectionVersions::disabled == getRequiredDetectIndirectVersionVC()) { return false; diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 66aa372371..3c3c1604c4 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -648,4 +648,7 @@ Enable10ThreadsPerEu = -1 OverrideRegionCount = -1 ForceUseOnlyGlobalTimestamps = 0 PrintCalculatedTimestamps = 0 +DisableIndirectDetectionForKernelNames = unk +ForceIndirectDetectionForCMKernels = -1 +LogIndirectDetectionKernelDetails = 0 # Please don't edit below this line diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index 6d702b2566..ce31e772c0 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -843,6 +843,9 @@ HWTEST_F(ProductHelperTest, givenProductHelperWhenCheckingIsUnlockingLockedPtrNe HWTEST_F(ProductHelperTest, givenProductHelperAndKernelBinaryFormatsWhenCheckingIsDetectIndirectAccessInKernelSupportedThenCorrectValueIsReturned) { KernelDescriptor kernelDescriptor; + kernelDescriptor.kernelMetadata.kernelName = "long_kernel_name"; + auto kernelNamePart = "kernel"; + auto kernelNameList = "long_kernel_name;different_kernel_name"; const auto igcDetectIndirectVersion = INDIRECT_ACCESS_DETECTION_VERSION; { const auto minimalRequiredDetectIndirectVersion = productHelper->getRequiredDetectIndirectVersion(); @@ -866,6 +869,20 @@ HWTEST_F(ProductHelperTest, givenProductHelperAndKernelBinaryFormatsWhenChecking EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersion)); EXPECT_EQ(enabledForJit, productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); + { + DebugManagerStateRestore restorer; + debugManager.flags.DisableIndirectDetectionForKernelNames.set(kernelNamePart); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, notAcceptedIndirectDetectionVersion)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersion)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); + + debugManager.flags.DisableIndirectDetectionForKernelNames.set(kernelNameList); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, notAcceptedIndirectDetectionVersion)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersion)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); + } } } else { // detection disabled { @@ -905,6 +922,36 @@ HWTEST_F(ProductHelperTest, givenProductHelperAndKernelBinaryFormatsWhenChecking EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersionVC)); EXPECT_EQ(enabledForJitVC, productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + { + DebugManagerStateRestore restorer; + debugManager.flags.DisableIndirectDetectionForKernelNames.set(kernelNamePart); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, notAcceptedIndirectDetectionVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + + debugManager.flags.DisableIndirectDetectionForKernelNames.set(kernelNameList); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, notAcceptedIndirectDetectionVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + } + { + DebugManagerStateRestore restorer; + debugManager.flags.ForceIndirectDetectionForCMKernels.set(0); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, notAcceptedIndirectDetectionVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + } + { + DebugManagerStateRestore restorer; + debugManager.flags.ForceIndirectDetectionForCMKernels.set(1); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, notAcceptedIndirectDetectionVersionVC)); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersionVC)); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + } } } else { // detection disabled for VC { @@ -918,6 +965,12 @@ HWTEST_F(ProductHelperTest, givenProductHelperAndKernelBinaryFormatsWhenChecking kernelDescriptor.kernelAttributes.simdSize = 1u; EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + { + DebugManagerStateRestore restorer; + debugManager.flags.ForceIndirectDetectionForCMKernels.set(1); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + } } } }