From faba16f657e2ce9d3288e7af98ac711ea6a77055 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Tue, 14 Mar 2023 15:24:23 +0000 Subject: [PATCH] refactor: move extensions string creation to CompilerProductHelper Related-To: NEO-7800 Signed-off-by: Mateusz Jablonski --- opencl/source/cl_device/cl_device_caps.cpp | 53 ++------------ .../helpers/compiler_product_helper_base.inl | 73 +++++++++++++++++++ 2 files changed, 79 insertions(+), 47 deletions(-) diff --git a/opencl/source/cl_device/cl_device_caps.cpp b/opencl/source/cl_device/cl_device_caps.cpp index 93a8e8a920..fe0d864d68 100644 --- a/opencl/source/cl_device/cl_device_caps.cpp +++ b/opencl/source/cl_device/cl_device_caps.cpp @@ -147,8 +147,6 @@ void ClDevice::initializeCaps() { deviceInfo.spirVersions = spirVersions.c_str(); deviceInfo.ilsWithVersion[0].version = CL_MAKE_VERSION(1, 2, 0); strcpy_s(deviceInfo.ilsWithVersion[0].name, CL_NAME_VERSION_MAX_NAME_SIZE, spirvName.c_str()); - auto supportsVme = hwInfo.capabilityTable.supportsVme; - auto supportsAdvancedVme = hwInfo.capabilityTable.supportsVme; deviceInfo.independentForwardProgress = hwInfo.capabilityTable.supportsIndependentForwardProgress; deviceInfo.maxNumOfSubGroups = 0; @@ -165,25 +163,9 @@ void ClDevice::initializeCaps() { if (deviceInfo.independentForwardProgress) { deviceExtensions += "cl_khr_subgroups "; } - - if (supportsVme) { - deviceExtensions += "cl_intel_spirv_device_side_avc_motion_estimation "; - } - if (hwInfo.capabilityTable.supportsMediaBlock) { - deviceExtensions += "cl_intel_spirv_media_block_io "; - } - deviceExtensions += "cl_intel_spirv_subgroups "; - deviceExtensions += "cl_khr_spirv_no_integer_wrap_decoration "; - - deviceExtensions += "cl_intel_unified_shared_memory "; - if (hwInfo.capabilityTable.supportsImages) { - deviceExtensions += "cl_khr_mipmap_image cl_khr_mipmap_image_writes "; - } } if (enabledClVersion >= 20) { - deviceExtensions += "cl_ext_float_atomics "; - deviceInfo.singleFpAtomicCapabilities = defaultFpAtomicCapabilities; deviceInfo.halfFpAtomicCapabilities = 0; if (ocl21FeaturesEnabled && hwInfo.capabilityTable.supportsFloatAtomics) { @@ -203,48 +185,20 @@ void ClDevice::initializeCaps() { } if (DebugManager.flags.EnableNV12.get() && hwInfo.capabilityTable.supportsImages) { - deviceExtensions += "cl_intel_planar_yuv "; deviceInfo.nv12Extension = true; } if (DebugManager.flags.EnablePackedYuv.get() && hwInfo.capabilityTable.supportsImages) { - deviceExtensions += "cl_intel_packed_yuv "; deviceInfo.packedYuvExtension = true; } + auto supportsVme = hwInfo.capabilityTable.supportsVme; if (DebugManager.flags.EnableIntelVme.get() != -1) { supportsVme = !!DebugManager.flags.EnableIntelVme.get(); } if (supportsVme) { - deviceExtensions += "cl_intel_motion_estimation cl_intel_device_side_avc_motion_estimation "; deviceInfo.vmeExtension = true; } - if (DebugManager.flags.EnableIntelAdvancedVme.get() != -1) { - supportsAdvancedVme = !!DebugManager.flags.EnableIntelAdvancedVme.get(); - } - if (supportsAdvancedVme) { - deviceExtensions += "cl_intel_advanced_motion_estimation "; - } - - if (hwInfo.capabilityTable.ftrSupportsInteger64BitAtomics) { - deviceExtensions += "cl_khr_int64_base_atomics "; - deviceExtensions += "cl_khr_int64_extended_atomics "; - } - - if (hwInfo.capabilityTable.supportsImages) { - deviceExtensions += "cl_khr_image2d_from_buffer "; - deviceExtensions += "cl_khr_depth_images "; - deviceExtensions += "cl_khr_3d_image_writes "; - } - - if (hwInfo.capabilityTable.supportsMediaBlock) { - deviceExtensions += "cl_intel_media_block_io "; - } - - if (compilerProductHelper.isBFloat16ConversionSupported(hwInfo)) { - deviceExtensions += "cl_intel_bfloat16_conversions "; - } - auto sharingAllowed = (getNumGenericSubDevices() <= 1u); if (sharingAllowed) { deviceExtensions += sharingFactory.getExtensions(driverInfo.get()); @@ -272,6 +226,11 @@ void ClDevice::initializeCaps() { if (supportsVme) { exposedBuiltinKernelsVector.push_back("block_motion_estimate_intel"); } + auto supportsAdvancedVme = hwInfo.capabilityTable.supportsVme; + + if (DebugManager.flags.EnableIntelAdvancedVme.get() != -1) { + supportsAdvancedVme = !!DebugManager.flags.EnableIntelAdvancedVme.get(); + } if (supportsAdvancedVme) { exposedBuiltinKernelsVector.push_back("block_advanced_motion_estimate_check_intel"); exposedBuiltinKernelsVector.push_back("block_advanced_motion_estimate_bidirectional_check_intel"); diff --git a/shared/source/helpers/compiler_product_helper_base.inl b/shared/source/helpers/compiler_product_helper_base.inl index 95f88e5f58..50fe48a57c 100644 --- a/shared/source/helpers/compiler_product_helper_base.inl +++ b/shared/source/helpers/compiler_product_helper_base.inl @@ -7,6 +7,7 @@ #pragma once +#include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/helpers/cache_policy.h" #include "shared/source/helpers/compiler_product_helper.h" @@ -35,6 +36,78 @@ bool CompilerProductHelperHw::failBuildProgramWithStatefulAccessPref template std::string CompilerProductHelperHw::getExtensions(const HardwareInfo &hwInfo) const { std::string extensions = ""; + auto enabledClVersion = hwInfo.capabilityTable.clVersionSupport; + auto ocl21FeaturesEnabled = hwInfo.capabilityTable.supportsOcl21Features; + if (DebugManager.flags.ForceOCLVersion.get() != 0) { + enabledClVersion = DebugManager.flags.ForceOCLVersion.get(); + ocl21FeaturesEnabled = (enabledClVersion == 21); + } + if (DebugManager.flags.ForceOCL21FeaturesSupport.get() != -1) { + ocl21FeaturesEnabled = DebugManager.flags.ForceOCL21FeaturesSupport.get(); + } + auto supportsVme = hwInfo.capabilityTable.supportsVme; + auto supportsAdvancedVme = hwInfo.capabilityTable.supportsVme; + + if (ocl21FeaturesEnabled) { + + if (supportsVme) { + extensions += "cl_intel_spirv_device_side_avc_motion_estimation "; + } + if (hwInfo.capabilityTable.supportsMediaBlock) { + extensions += "cl_intel_spirv_media_block_io "; + } + extensions += "cl_intel_spirv_subgroups "; + extensions += "cl_khr_spirv_no_integer_wrap_decoration "; + + extensions += "cl_intel_unified_shared_memory "; + if (hwInfo.capabilityTable.supportsImages) { + extensions += "cl_khr_mipmap_image cl_khr_mipmap_image_writes "; + } + } + + if (enabledClVersion >= 20) { + extensions += "cl_ext_float_atomics "; + } + + if (DebugManager.flags.EnableNV12.get() && hwInfo.capabilityTable.supportsImages) { + extensions += "cl_intel_planar_yuv "; + } + if (DebugManager.flags.EnablePackedYuv.get() && hwInfo.capabilityTable.supportsImages) { + extensions += "cl_intel_packed_yuv "; + } + if (DebugManager.flags.EnableIntelVme.get() != -1) { + supportsVme = !!DebugManager.flags.EnableIntelVme.get(); + } + + if (supportsVme) { + extensions += "cl_intel_motion_estimation cl_intel_device_side_avc_motion_estimation "; + } + + if (DebugManager.flags.EnableIntelAdvancedVme.get() != -1) { + supportsAdvancedVme = !!DebugManager.flags.EnableIntelAdvancedVme.get(); + } + if (supportsAdvancedVme) { + extensions += "cl_intel_advanced_motion_estimation "; + } + + if (hwInfo.capabilityTable.ftrSupportsInteger64BitAtomics) { + extensions += "cl_khr_int64_base_atomics "; + extensions += "cl_khr_int64_extended_atomics "; + } + + if (hwInfo.capabilityTable.supportsImages) { + extensions += "cl_khr_image2d_from_buffer "; + extensions += "cl_khr_depth_images "; + extensions += "cl_khr_3d_image_writes "; + } + + if (hwInfo.capabilityTable.supportsMediaBlock) { + extensions += "cl_intel_media_block_io "; + } + + if (isBFloat16ConversionSupported(hwInfo)) { + extensions += "cl_intel_bfloat16_conversions "; + } if (isCreateBufferWithPropertiesSupported()) { extensions += "cl_intel_create_buffer_with_properties ";