diff --git a/opencl/test/unit_test/api/cl_build_program_tests.inl b/opencl/test/unit_test/api/cl_build_program_tests.inl index 47ca7fc95f..81bb326806 100644 --- a/opencl/test/unit_test/api/cl_build_program_tests.inl +++ b/opencl/test/unit_test/api/cl_build_program_tests.inl @@ -100,8 +100,9 @@ TEST_F(ClBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithSourceThenP EXPECT_EQ(CL_SUCCESS, retVal); } -HWTEST2_F(ClBuildProgramTests, GivenFailBuildProgramAndBinaryAsInputWhenCreatingProgramWithSourceThenProgramBuildFails, IsAtLeastXeHpcCore) { - debugManager.flags.FailBuildProgramWithStatefulAccess.set(1); +HWTEST_F(ClBuildProgramTests, GivenFailBuildProgramIsDisabledAndStatelessDisabledAndBinaryAsInputWhenCreatingProgramWithSourceThenProgramBuildSuccesses) { + debugManager.flags.FailBuildProgramWithStatefulAccess.set(0); + debugManager.flags.DisableForceToStateless.set(1); cl_program pProgram = nullptr; cl_int binaryStatus = CL_SUCCESS; MockZebinWrapper zebin{pDevice->getHardwareInfo()}; @@ -126,7 +127,7 @@ HWTEST2_F(ClBuildProgramTests, GivenFailBuildProgramAndBinaryAsInputWhenCreating nullptr, nullptr); - EXPECT_EQ(CL_BUILD_PROGRAM_FAILURE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); retVal = clReleaseProgram(pProgram); EXPECT_EQ(CL_SUCCESS, retVal); diff --git a/opencl/test/unit_test/api/cl_create_program_with_binary_tests.inl b/opencl/test/unit_test/api/cl_create_program_with_binary_tests.inl index 6f2f22c83c..c67779306c 100644 --- a/opencl/test/unit_test/api/cl_create_program_with_binary_tests.inl +++ b/opencl/test/unit_test/api/cl_create_program_with_binary_tests.inl @@ -88,7 +88,7 @@ TEST_F(ClCreateProgramWithBinaryTests, GivenInvalidInputWhenCreatingProgramWithB EXPECT_EQ(CL_INVALID_VALUE, retVal); EXPECT_EQ(nullptr, pProgram); - zebin.binarySizes[1] = zebin.data.storage.size(); + zebin.binarySizes[1] = zebin.data->storage.size(); pProgram = clCreateProgramWithBinary( pContext, diff --git a/opencl/test/unit_test/api/cl_get_program_info_tests.inl b/opencl/test/unit_test/api/cl_get_program_info_tests.inl index 40426e2c95..88bada3429 100644 --- a/opencl/test/unit_test/api/cl_get_program_info_tests.inl +++ b/opencl/test/unit_test/api/cl_get_program_info_tests.inl @@ -318,7 +318,7 @@ TEST(clGetProgramInfoTest, GivenMultiDeviceBuiltInProgramCreatedWithGenBinaryWhe cl_program pProgram = nullptr; cl_int retVal = CL_INVALID_PROGRAM; - pProgram = Program::createBuiltInFromGenBinary(&context, context.getDevices(), zebin.data.storage.data(), zebin.data.storage.size(), &retVal); + pProgram = Program::createBuiltInFromGenBinary(&context, context.getDevices(), zebin.data->storage.data(), zebin.data->storage.size(), &retVal); EXPECT_NE(nullptr, pProgram); EXPECT_EQ(CL_SUCCESS, retVal); @@ -346,8 +346,8 @@ TEST(clGetProgramInfoTest, GivenMultiDeviceBuiltInProgramCreatedWithGenBinaryWhe cl_int retVal = CL_INVALID_PROGRAM; - unsigned char *pBinary = zebin.data.storage.data(); - const size_t binarySize = zebin.data.storage.size(); + unsigned char *pBinary = zebin.data->storage.data(); + const size_t binarySize = zebin.data->storage.size(); pProgram = Program::createBuiltInFromGenBinary(&context, context.getDevices(), pBinary, binarySize, &retVal); EXPECT_NE(nullptr, pProgram); diff --git a/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp index 17bd193e41..a2b9a7fe91 100644 --- a/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp @@ -129,6 +129,7 @@ HWTEST2_F(EnqueueKernelTest, GivenIndirectAccessBufferVersion1WhenExecutingKerne ZebinTestData::ZebinCopyBufferModule::Descriptor desc{}; desc.execEnv["simd_size"] = std::to_string(simd); desc.execEnv["require_iab"] = "true"; + desc.isStateless = pDevice->getCompilerProductHelper().isForceToStatelessRequired(); auto zebinData = std::make_unique>(pDevice->getHardwareInfo(), desc); const auto src = zebinData->storage.data(); const auto binarySize = zebinData->storage.size(); diff --git a/shared/source/helpers/compiler_product_helper_base.inl b/shared/source/helpers/compiler_product_helper_base.inl index a461c6cd7e..1f8d308bf4 100644 --- a/shared/source/helpers/compiler_product_helper_base.inl +++ b/shared/source/helpers/compiler_product_helper_base.inl @@ -44,11 +44,6 @@ const char *CompilerProductHelperHw::getCachingPolicyOptions(bool is return L1CachePolicyHelper::getCachingPolicyOptions(isDebuggerActive); } -template -bool CompilerProductHelperHw::failBuildProgramWithStatefulAccessPreference() const { - return false; -} - template bool CompilerProductHelperHw::oclocEnforceZebinFormat() const { return false; diff --git a/shared/source/helpers/compiler_product_helper_before_xe_hpc.inl b/shared/source/helpers/compiler_product_helper_before_xe_hpc.inl index d3970c5398..77e71a4378 100644 --- a/shared/source/helpers/compiler_product_helper_before_xe_hpc.inl +++ b/shared/source/helpers/compiler_product_helper_before_xe_hpc.inl @@ -39,4 +39,9 @@ bool CompilerProductHelperHw::isSubgroupBufferPrefetchSupported() co return false; } +template +bool CompilerProductHelperHw::failBuildProgramWithStatefulAccessPreference() const { + return false; +} + } // namespace NEO diff --git a/shared/source/helpers/compiler_product_helper_xe_hpc_and_later.inl b/shared/source/helpers/compiler_product_helper_xe_hpc_and_later.inl index de40e49502..cc522a3661 100644 --- a/shared/source/helpers/compiler_product_helper_xe_hpc_and_later.inl +++ b/shared/source/helpers/compiler_product_helper_xe_hpc_and_later.inl @@ -43,4 +43,9 @@ bool CompilerProductHelperHw::isSubgroupBufferPrefetchSupported() co return true; } +template +bool CompilerProductHelperHw::failBuildProgramWithStatefulAccessPreference() const { + return true; +} + } // namespace NEO diff --git a/shared/source/xe_hpc_core/enable_compiler_product_helper_pvc.cpp b/shared/source/xe_hpc_core/enable_compiler_product_helper_pvc.cpp index 4ae2123fbe..3fc90bdc3e 100644 --- a/shared/source/xe_hpc_core/enable_compiler_product_helper_pvc.cpp +++ b/shared/source/xe_hpc_core/enable_compiler_product_helper_pvc.cpp @@ -63,11 +63,6 @@ uint32_t CompilerProductHelperHw::matchRevisionIdWithProductConfig(Har return pvcConfig.value; } -template <> -bool CompilerProductHelperHw::failBuildProgramWithStatefulAccessPreference() const { - return false; -} - template <> bool CompilerProductHelperHw::isMatrixMultiplyAccumulateSupported(const ReleaseHelper *releaseHelper) const { if (releaseHelper) { diff --git a/shared/test/common/mocks/mock_zebin_wrapper.h b/shared/test/common/mocks/mock_zebin_wrapper.h index 63924125ea..5c55b98db2 100644 --- a/shared/test/common/mocks/mock_zebin_wrapper.h +++ b/shared/test/common/mocks/mock_zebin_wrapper.h @@ -7,6 +7,7 @@ #pragma once +#include "shared/source/helpers/compiler_product_helper.h" #include "shared/test/common/libult/global_environment.h" #include "shared/test/common/mocks/mock_modules_zebin.h" @@ -19,16 +20,18 @@ template ::Descriptor; - MockZebinWrapper(const HardwareInfo &hwInfo, Descriptor desc) - : data(hwInfo, desc) { - std::fill_n(binaries.begin(), binariesCount, reinterpret_cast(this->data.storage.data())); - std::fill_n(binarySizes.begin(), binariesCount, this->data.storage.size()); + MockZebinWrapper(const HardwareInfo &hwInfo, Descriptor desc = {}) { + auto productHelper = NEO::CompilerProductHelper::create(defaultHwInfo->platform.eProductFamily); + desc.isStateless = productHelper->isForceToStatelessRequired(); + + data = std::make_unique>(hwInfo, desc); + + std::fill_n(binaries.begin(), binariesCount, reinterpret_cast(this->data->storage.data())); + std::fill_n(binarySizes.begin(), binariesCount, this->data->storage.size()); } - MockZebinWrapper(const HardwareInfo &hwInfo) : MockZebinWrapper(hwInfo, Descriptor{}) {} - auto &getFlags() { - return reinterpret_cast(this->data.elfHeader->flags); + return reinterpret_cast(this->data->elfHeader->flags); } void setAsMockCompilerReturnedBinary() { @@ -57,7 +60,7 @@ struct MockZebinWrapper { }}; } - ZebinTestData::ZebinCopyBufferModule data; + std::unique_ptr> data; std::array binaries; std::array binarySizes; std::unique_ptr debugVarsRestore{nullptr, nullptr}; diff --git a/shared/test/unit_test/helpers/compiler_product_helper_tests.cpp b/shared/test/unit_test/helpers/compiler_product_helper_tests.cpp index 46173507b4..2360472778 100644 --- a/shared/test/unit_test/helpers/compiler_product_helper_tests.cpp +++ b/shared/test/unit_test/helpers/compiler_product_helper_tests.cpp @@ -14,6 +14,7 @@ #include "shared/test/common/helpers/gtest_helpers.h" #include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/mocks/mock_release_helper.h" #include "shared/test/common/test_macros/hw_test.h" @@ -545,3 +546,17 @@ HWTEST_F(CompilerProductHelperFixture, GivenRequestForExtraKernelCapabilitiesThe EXPECT_EQ(0u, extraCaps); } } + +HWTEST2_F(CompilerProductHelperFixture, givenStatefulPlatformWhenFailBuildProgramWithStatefulAccessPreferenceThenFalseIsReturned, IsStatefulBufferPreferredForProduct) { + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + EXPECT_FALSE(compilerProductHelper.failBuildProgramWithStatefulAccessPreference()); +} + +HWTEST2_F(CompilerProductHelperFixture, givenNotStatefulPlatformWhenFailBuildProgramWithStatefulAccessPreferenceThenTrueIsReturned, IsStatelessBufferPreferredForProduct) { + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + EXPECT_TRUE(compilerProductHelper.failBuildProgramWithStatefulAccessPreference()); +} \ No newline at end of file diff --git a/shared/test/unit_test/xe_hpc_core/pvc/compiler_product_helper_tests_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/compiler_product_helper_tests_pvc.cpp index 1145d446b0..5bc52215fa 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/compiler_product_helper_tests_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/compiler_product_helper_tests_pvc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Intel Corporation + * Copyright (C) 2023-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -38,13 +38,6 @@ PVCTEST_F(CompilerProductHelperPvcTest, givenPvcConfigsWhenMatchConfigWithRevIdT EXPECT_EQ(compilerProductHelper.matchRevisionIdWithProductConfig(AOT::PVC_XT_C0_VG, 0x2f), AOT::PVC_XT_C0_VG); } -PVCTEST_F(CompilerProductHelperPvcTest, givenPvcWhenFailBuildProgramWithStatefulAccessPreferenceThenFalseIsReturned) { - MockExecutionEnvironment executionEnvironment{}; - auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; - auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); - EXPECT_FALSE(compilerProductHelper.failBuildProgramWithStatefulAccessPreference()); -} - PVCTEST_F(CompilerProductHelperPvcTest, givenPvcB0AndLaterThenMatrixMultiplyAccumulateTF32IsSupported) { MockExecutionEnvironment executionEnvironment{}; auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];