diff --git a/shared/source/helpers/definitions/indirect_detection_versions.h b/shared/source/helpers/definitions/indirect_detection_versions.h index 2e13b2082a..cc04b8ce87 100644 --- a/shared/source/helpers/definitions/indirect_detection_versions.h +++ b/shared/source/helpers/definitions/indirect_detection_versions.h @@ -12,5 +12,6 @@ namespace NEO { namespace IndirectDetectionVersions { constexpr uint32_t requiredDetectIndirectVersionPVC = 3u; -} +constexpr uint32_t disabled = std::numeric_limits::max(); +} // namespace IndirectDetectionVersions } // namespace NEO \ No newline at end of file diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 69eb4f3ed6..ae784961ef 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -189,6 +189,7 @@ class ProductHelper { virtual bool isDummyBlitWaRequired() const = 0; virtual bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled, const uint32_t precompiledKernelIndirectDetectionVersion) const = 0; virtual uint32_t getRequiredDetectIndirectVersion() const = 0; + virtual uint32_t getRequiredDetectIndirectVersionVC() const = 0; virtual bool isLinearStoragePreferred(bool isImage1d, bool forceLinearStorage) const = 0; virtual bool isTranslationExceptionSupported() const = 0; virtual uint32_t getMaxNumSamplers() const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index f78342e75d..f0bb1a79b4 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -12,6 +12,7 @@ #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/cache_policy.h" #include "shared/source/helpers/constants.h" +#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/local_memory_access_modes.h" @@ -71,19 +72,32 @@ bool ProductHelperHw::isTlbFlushRequired() const { template bool ProductHelperHw::isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled, const uint32_t precompiledKernelIndirectDetectionVersion) const { - if (std::numeric_limits::max() == getRequiredDetectIndirectVersion()) { - return false; - } - const bool isZebin = kernelDescriptor.kernelAttributes.binaryFormat == DeviceBinaryFormat::zebin; const bool isCMKernelHeuristic = kernelDescriptor.kernelAttributes.simdSize == 1; + const bool isZebin = kernelDescriptor.kernelAttributes.binaryFormat == DeviceBinaryFormat::zebin; const auto currentIndirectDetectionVersion = isPrecompiled ? precompiledKernelIndirectDetectionVersion : INDIRECT_ACCESS_DETECTION_VERSION; - const bool indirectDetectionValid = currentIndirectDetectionVersion >= getRequiredDetectIndirectVersion(); - return isZebin && indirectDetectionValid && !isCMKernelHeuristic; + bool indirectDetectionValid = false; + if (isCMKernelHeuristic) { + if (IndirectDetectionVersions::disabled == getRequiredDetectIndirectVersionVC()) { + return false; + } + indirectDetectionValid = currentIndirectDetectionVersion >= getRequiredDetectIndirectVersionVC(); + } else { + if (IndirectDetectionVersions::disabled == getRequiredDetectIndirectVersion()) { + return false; + } + indirectDetectionValid = currentIndirectDetectionVersion >= getRequiredDetectIndirectVersion(); + } + return isZebin && indirectDetectionValid; } template uint32_t ProductHelperHw::getRequiredDetectIndirectVersion() const { - return std::numeric_limits::max(); + return IndirectDetectionVersions::disabled; +} + +template +uint32_t ProductHelperHw::getRequiredDetectIndirectVersionVC() const { + return IndirectDetectionVersions::disabled; } template diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index afb32e7dc5..6d564a504c 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -132,6 +132,7 @@ class ProductHelperHw : public ProductHelper { bool isDummyBlitWaRequired() const override; bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled, const uint32_t precompiledKernelIndirectDetectionVersion) const override; uint32_t getRequiredDetectIndirectVersion() const override; + uint32_t getRequiredDetectIndirectVersionVC() const override; bool isLinearStoragePreferred(bool isImage1d, bool forceLinearStorage) const override; bool isTranslationExceptionSupported() const override; uint32_t getMaxNumSamplers() const override; 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 707fcd61e2..97b6e4dbb4 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -8,6 +8,7 @@ #include "shared/test/unit_test/os_interface/product_helper_tests.h" #include "shared/source/aub_mem_dump/aub_mem_dump.h" +#include "shared/source/helpers/definitions/indirect_detection_versions.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/local_memory_access_modes.h" #include "shared/source/kernel/kernel_descriptor.h" @@ -883,69 +884,82 @@ HWTEST_F(ProductHelperTest, givenProductHelperWhenCheckDummyBlitWaRequiredThenRe HWTEST_F(ProductHelperTest, givenProductHelperAndKernelBinaryFormatsWhenCheckingIsDetectIndirectAccessInKernelSupportedThenCorrectValueIsReturned) { KernelDescriptor kernelDescriptor; - const auto minimalRequiredDetectIndirectVersion = productHelper->getRequiredDetectIndirectVersion(); - EXPECT_GT(minimalRequiredDetectIndirectVersion, 0u); const auto igcDetectIndirectVersion = INDIRECT_ACCESS_DETECTION_VERSION; - EXPECT_LE(igcDetectIndirectVersion, minimalRequiredDetectIndirectVersion); - const bool detectionEnabled = std::numeric_limits::max() != minimalRequiredDetectIndirectVersion; - if (detectionEnabled) { - const uint32_t notAcceptedIndirectDetectionVersion = minimalRequiredDetectIndirectVersion - 1; - { - kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::patchtokens; - kernelDescriptor.kernelAttributes.simdSize = 8u; - 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)); + { + const auto minimalRequiredDetectIndirectVersion = productHelper->getRequiredDetectIndirectVersion(); + EXPECT_GT(minimalRequiredDetectIndirectVersion, 0u); + EXPECT_LE(igcDetectIndirectVersion, minimalRequiredDetectIndirectVersion); + const bool detectionEnabled = IndirectDetectionVersions::disabled != minimalRequiredDetectIndirectVersion; + if (detectionEnabled) { + const uint32_t notAcceptedIndirectDetectionVersion = minimalRequiredDetectIndirectVersion - 1; + { + kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::patchtokens; + kernelDescriptor.kernelAttributes.simdSize = 8u; + 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)); + } + { + kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::zebin; + kernelDescriptor.kernelAttributes.simdSize = 8u; + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, notAcceptedIndirectDetectionVersion)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersion)); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); + } + } else { // detection disabled + { + kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::patchtokens; + kernelDescriptor.kernelAttributes.simdSize = 8u; + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); + } + { + kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::zebin; + kernelDescriptor.kernelAttributes.simdSize = 8u; + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); + } } - { - kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::patchtokens; - kernelDescriptor.kernelAttributes.simdSize = 1u; - 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)); - } - { - kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::zebin; - kernelDescriptor.kernelAttributes.simdSize = 1u; - 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)); - } - { - kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::zebin; - kernelDescriptor.kernelAttributes.simdSize = 8u; - EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, notAcceptedIndirectDetectionVersion)); - EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersion)); - EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); - EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); - } - } else { // detection disabled - { - kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::patchtokens; - kernelDescriptor.kernelAttributes.simdSize = 8u; - EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); - EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); - } - { - kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::patchtokens; - kernelDescriptor.kernelAttributes.simdSize = 1u; - EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); - EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); - } - { - kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::zebin; - kernelDescriptor.kernelAttributes.simdSize = 1u; - EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); - EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); - } - { - kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::zebin; - kernelDescriptor.kernelAttributes.simdSize = 8u; - EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersion)); - EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersion)); + } + + { + const auto minimalRequiredDetectIndirectVersionVC = productHelper->getRequiredDetectIndirectVersionVC(); + EXPECT_GT(minimalRequiredDetectIndirectVersionVC, 0u); + EXPECT_LE(igcDetectIndirectVersion, minimalRequiredDetectIndirectVersionVC); + const bool detectionEnabledVC = IndirectDetectionVersions::disabled != minimalRequiredDetectIndirectVersionVC; + if (detectionEnabledVC) { + const uint32_t notAcceptedIndirectDetectionVersionVC = minimalRequiredDetectIndirectVersionVC - 1; + { + kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::patchtokens; + kernelDescriptor.kernelAttributes.simdSize = 1u; + 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)); + } + { + kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::zebin; + kernelDescriptor.kernelAttributes.simdSize = 1u; + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, notAcceptedIndirectDetectionVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, notAcceptedIndirectDetectionVersionVC)); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); + EXPECT_TRUE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + } + } else { // detection disabled for VC + { + kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::patchtokens; + kernelDescriptor.kernelAttributes.simdSize = 1u; + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + } + { + kernelDescriptor.kernelAttributes.binaryFormat = DeviceBinaryFormat::zebin; + kernelDescriptor.kernelAttributes.simdSize = 1u; + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, false, minimalRequiredDetectIndirectVersionVC)); + EXPECT_FALSE(productHelper->isDetectIndirectAccessInKernelSupported(kernelDescriptor, true, minimalRequiredDetectIndirectVersionVC)); + } } } }