diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index 4e88e9a081..4d8ecc4aec 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2020 Intel Corporation + * Copyright (C) 2017-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -93,11 +93,16 @@ void Program::initInternalOptions(std::string &internalOptions) const { CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::hasBufferOffsetArg); } - auto &hwHelper = HwHelper::get(pClDevice->getHardwareInfo().platform.eRenderCoreFamily); - if (hwHelper.isForceEmuInt32DivRemSPWARequired(pClDevice->getHardwareInfo())) { + auto &hwInfo = pClDevice->getHardwareInfo(); + auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); + if (hwHelper.isForceEmuInt32DivRemSPWARequired(hwInfo)) { CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::forceEmuInt32DivRemSP); } + if (hwInfo.capabilityTable.supportsImages) { + CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::enableImageSupport); + } + CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::preserveVec3Type); } diff --git a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp index 118ca1b6a3..87a1d716aa 100644 --- a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp @@ -279,6 +279,12 @@ TEST_F(OfflineCompilerTests, givenVariousClStdValuesWhenCompilingSourceThenCorre EXPECT_THAT(internalOptions, ::testing::Not(::testing::HasSubstr(std::string{feature.name}))); } } + + if (DEFAULT_PLATFORM::hwInfo.capabilityTable.supportsImages) { + EXPECT_THAT(internalOptions, ::testing::HasSubstr(CompilerOptions::enableImageSupport.data())); + } else { + EXPECT_THAT(internalOptions, ::testing::Not(::testing::HasSubstr(CompilerOptions::enableImageSupport.data()))); + } } } diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index e9d5b4c712..f9b42e5b7e 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2020 Intel Corporation + * Copyright (C) 2017-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -2223,6 +2223,20 @@ TEST_F(ProgramTests, givenNewProgramThenStatelessToStatefulBufferOffsetOptimizat } } +TEST(ProgramTest, givenImagesSupportedWhenCreatingProgramThenInternalOptionsAreCorrectlyInitialized) { + VariableBackup supportsImagesCapability{&defaultHwInfo->capabilityTable.supportsImages}; + + for (auto areImagesSupported : ::testing::Bool()) { + supportsImagesCapability = areImagesSupported; + UltClDeviceFactory clDeviceFactory{1, 0}; + MockContext context{clDeviceFactory.rootDevices[0]}; + MockProgram program(&context, false, toClDeviceVector(*clDeviceFactory.rootDevices[0])); + + auto internalOptions = program.getInitInternalOptions(); + EXPECT_EQ(areImagesSupported, CompilerOptions::contains(internalOptions, CompilerOptions::enableImageSupport)); + } +} + template struct CreateProgramFromBinaryMock : public MockProgram { using MockProgram::MockProgram; diff --git a/shared/offline_compiler/source/offline_compiler.cpp b/shared/offline_compiler/source/offline_compiler.cpp index 2f3add1686..3af9d9bd2b 100644 --- a/shared/offline_compiler/source/offline_compiler.cpp +++ b/shared/offline_compiler/source/offline_compiler.cpp @@ -394,8 +394,6 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector & if (deviceName.empty()) { internalOptions = CompilerOptions::concatenate("-ocl-version=300 -cl-ext=-all,+cl_khr_3d_image_writes", internalOptions); } else { - auto oclVersion = getOclVersionCompilerInternalOption(hwInfo.capabilityTable.clVersionSupport); - std::string extensionsList = getExtensionsList(hwInfo); if (requiresAdditionalExtensions(options)) { extensionsList += "cl_khr_3d_image_writes "; @@ -404,8 +402,14 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector & if (requiresOpenClCFeatures(options)) { getOpenclCFeaturesList(hwInfo, openclCFeatures); } + auto compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str(), openclCFeatures); + auto oclVersion = getOclVersionCompilerInternalOption(hwInfo.capabilityTable.clVersionSupport); internalOptions = CompilerOptions::concatenate(oclVersion, compilerExtensions, internalOptions); + + if (hwInfo.capabilityTable.supportsImages) { + CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::enableImageSupport); + } } parseDebugSettings(); diff --git a/shared/source/compiler_interface/compiler_options/compiler_options_base.h b/shared/source/compiler_interface/compiler_options/compiler_options_base.h index dd7b7fe4a0..143ed58b7d 100644 --- a/shared/source/compiler_interface/compiler_options/compiler_options_base.h +++ b/shared/source/compiler_interface/compiler_options/compiler_options_base.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -31,6 +31,7 @@ static constexpr ConstStringRef uniformWorkgroupSize = "-cl-uniform-work-group-s static constexpr ConstStringRef forceEmuInt32DivRem = "-cl-intel-force-emu-int32divrem"; static constexpr ConstStringRef forceEmuInt32DivRemSP = "-cl-intel-force-emu-sp-int32divrem"; static constexpr ConstStringRef allowZebin = "-allow-zebin"; +static constexpr ConstStringRef enableImageSupport = "-D__IMAGE_SUPPORT__=1"; constexpr size_t nullterminateSize = 1U; constexpr size_t spaceSeparatorSize = 1U;