Move ocl extensions logic to shared

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-11-04 15:39:09 +00:00
committed by Compute-Runtime-Automation
parent 4bf4b170f1
commit 21ef249961
17 changed files with 28 additions and 27 deletions

View File

@@ -7,6 +7,7 @@
#include "opencl/source/cl_device/cl_device.h"
#include "shared/source/compiler_interface/oclc_extensions.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/device/device.h"
#include "shared/source/device/sub_device.h"
@@ -18,7 +19,6 @@
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "opencl/source/helpers/cl_hw_helper.h"
#include "opencl/source/platform/extensions.h"
#include "opencl/source/platform/platform.h"
namespace NEO {

View File

@@ -5,6 +5,7 @@
*
*/
#include "shared/source/compiler_interface/oclc_extensions.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/device/device.h"
#include "shared/source/device/device_info.h"
@@ -16,7 +17,6 @@
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/helpers/cl_hw_helper.h"
#include "opencl/source/platform/extensions.h"
#include "opencl/source/sharings/sharing_factory.h"
#include "driver_version.h"

View File

@@ -7,8 +7,8 @@
#pragma once
#include "shared/source/compiler_interface/oclc_extensions.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/utilities/stackvec.h"
#include "opencl/extensions/public/cl_ext_private.h"
@@ -16,8 +16,6 @@
namespace NEO {
using OpenClCFeaturesContainer = StackVec<cl_name_version, 15>;
struct ClDeviceInfoParam {
union {
cl_bool boolean;

View File

@@ -9,5 +9,9 @@ set(RUNTIME_SRCS_COMPILER_INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/default_cl_cache_config.cpp
)
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_COMPILER_INTERFACE})
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE
${RUNTIME_SRCS_COMPILER_INTERFACE}
${NEO_SHARED_DIRECTORY}/compiler_interface/oclc_extensions.cpp
${NEO_SHARED_DIRECTORY}/compiler_interface/oclc_extensions.h
)
set_property(GLOBAL PROPERTY RUNTIME_SRCS_COMPILER_INTERFACE ${RUNTIME_SRCS_COMPILER_INTERFACE})

View File

@@ -1,13 +1,11 @@
#
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(RUNTIME_SRCS_PLATFORM
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/extensions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/extensions.h
${CMAKE_CURRENT_SOURCE_DIR}/platform.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platform.h
${CMAKE_CURRENT_SOURCE_DIR}/platform_info.h

View File

@@ -1,186 +0,0 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/source/platform/extensions.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/string.h"
#include <string>
namespace NEO {
const char *deviceExtensionsList = "cl_khr_byte_addressable_store "
"cl_khr_fp16 "
"cl_khr_global_int32_base_atomics "
"cl_khr_global_int32_extended_atomics "
"cl_khr_icd "
"cl_khr_local_int32_base_atomics "
"cl_khr_local_int32_extended_atomics "
"cl_intel_command_queue_families "
"cl_intel_subgroups "
"cl_intel_required_subgroup_size "
"cl_intel_subgroups_short "
"cl_khr_spir "
"cl_intel_accelerator "
"cl_intel_driver_diagnostics "
"cl_khr_priority_hints "
"cl_khr_throttle_hints "
"cl_khr_create_command_queue "
"cl_intel_subgroups_char "
"cl_intel_subgroups_long "
"cl_khr_il_program "
"cl_intel_mem_force_host_memory "
"cl_khr_subgroup_extended_types "
"cl_khr_subgroup_non_uniform_vote "
"cl_khr_subgroup_ballot "
"cl_khr_subgroup_non_uniform_arithmetic "
"cl_khr_subgroup_shuffle "
"cl_khr_subgroup_shuffle_relative "
"cl_khr_subgroup_clustered_reduce "
"cl_intel_device_attribute_query "
"cl_khr_suggested_local_work_size ";
std::string getExtensionsList(const HardwareInfo &hwInfo) {
std::string allExtensionsList;
allExtensionsList.reserve(1000);
allExtensionsList.append(deviceExtensionsList);
if (hwInfo.capabilityTable.supportsOcl21Features) {
allExtensionsList += "cl_khr_subgroups ";
if (hwInfo.capabilityTable.supportsVme) {
allExtensionsList += "cl_intel_spirv_device_side_avc_motion_estimation ";
}
if (hwInfo.capabilityTable.supportsMediaBlock) {
allExtensionsList += "cl_intel_spirv_media_block_io ";
}
allExtensionsList += "cl_intel_spirv_subgroups ";
allExtensionsList += "cl_khr_spirv_no_integer_wrap_decoration ";
}
if (hwInfo.capabilityTable.ftrSupportsFP64) {
allExtensionsList += "cl_khr_fp64 ";
}
if (hwInfo.capabilityTable.ftrSupportsInteger64BitAtomics) {
allExtensionsList += "cl_khr_int64_base_atomics ";
allExtensionsList += "cl_khr_int64_extended_atomics ";
}
if (hwInfo.capabilityTable.supportsImages) {
allExtensionsList += "cl_khr_3d_image_writes ";
}
if (hwInfo.capabilityTable.supportsVme) {
allExtensionsList += "cl_intel_motion_estimation cl_intel_device_side_avc_motion_estimation ";
}
return allExtensionsList;
}
void getOpenclCFeaturesList(const HardwareInfo &hwInfo, OpenClCFeaturesContainer &openclCFeatures) {
cl_name_version openClCFeature;
openClCFeature.version = CL_MAKE_VERSION(3, 0, 0);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_int64");
openclCFeatures.push_back(openClCFeature);
if (hwInfo.capabilityTable.supportsImages) {
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_3d_image_writes");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_images");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_read_write_images");
openclCFeatures.push_back(openClCFeature);
}
if (hwInfo.capabilityTable.supportsOcl21Features) {
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_atomic_order_acq_rel");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_atomic_order_seq_cst");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_atomic_scope_all_devices");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_atomic_scope_device");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_generic_address_space");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_program_scope_global_variables");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_work_group_collective_functions");
openclCFeatures.push_back(openClCFeature);
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_subgroups");
openclCFeatures.push_back(openClCFeature);
}
auto forceDeviceEnqueueSupport = DebugManager.flags.ForceDeviceEnqueueSupport.get();
if ((hwInfo.capabilityTable.supportsDeviceEnqueue && (forceDeviceEnqueueSupport == -1)) ||
(forceDeviceEnqueueSupport == 1)) {
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_device_enqueue");
openclCFeatures.push_back(openClCFeature);
}
auto forcePipeSupport = DebugManager.flags.ForcePipeSupport.get();
if ((hwInfo.capabilityTable.supportsPipes && (forcePipeSupport == -1)) ||
(forcePipeSupport == 1)) {
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_pipes");
openclCFeatures.push_back(openClCFeature);
}
auto forceFp64Support = DebugManager.flags.OverrideDefaultFP64Settings.get();
if ((hwInfo.capabilityTable.ftrSupportsFP64 && (forceFp64Support == -1)) ||
(forceFp64Support == 1)) {
strcpy_s(openClCFeature.name, CL_NAME_VERSION_MAX_NAME_SIZE, "__opencl_c_fp64");
openclCFeatures.push_back(openClCFeature);
}
}
std::string convertEnabledExtensionsToCompilerInternalOptions(const char *enabledExtensions,
OpenClCFeaturesContainer &openclCFeatures) {
std::string extensionsList = enabledExtensions;
extensionsList.reserve(1500);
extensionsList = " -cl-ext=-all,";
std::istringstream extensionsStringStream(enabledExtensions);
std::string extension;
while (extensionsStringStream >> extension) {
extensionsList.append("+");
extensionsList.append(extension);
extensionsList.append(",");
}
for (auto &feature : openclCFeatures) {
extensionsList.append("+");
extensionsList.append(feature.name);
extensionsList.append(",");
}
extensionsList[extensionsList.size() - 1] = ' ';
return extensionsList;
}
std::string getOclVersionCompilerInternalOption(unsigned int oclVersion) {
switch (oclVersion) {
case 30:
return "-ocl-version=300 ";
case 21:
return "-ocl-version=210 ";
default:
return "-ocl-version=120 ";
}
}
} // namespace NEO

View File

@@ -1,29 +0,0 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/hw_info.h"
#include "shared/source/utilities/stackvec.h"
#include "opencl/source/cl_device/cl_device_info.h"
#include <string>
namespace NEO {
namespace Extensions {
constexpr const char *const sharingFormatQuery = "cl_intel_sharing_format_query ";
}
extern const char *deviceExtensionsList;
std::string getExtensionsList(const HardwareInfo &hwInfo);
void getOpenclCFeaturesList(const HardwareInfo &hwInfo, OpenClCFeaturesContainer &openclCFeatures);
std::string convertEnabledExtensionsToCompilerInternalOptions(const char *deviceExtensions,
OpenClCFeaturesContainer &openclCFeatures);
std::string getOclVersionCompilerInternalOption(unsigned int oclVersion);
} // namespace NEO

View File

@@ -10,6 +10,7 @@
#include "shared/source/built_ins/sip.h"
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/compiler_interface/compiler_interface.h"
#include "shared/source/compiler_interface/oclc_extensions.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/device/root_device.h"
#include "shared/source/execution_environment/execution_environment.h"
@@ -27,7 +28,6 @@
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/gtpin/gtpin_notify.h"
#include "opencl/source/helpers/get_info_status_mapper.h"
#include "opencl/source/platform/extensions.h"
#include "opencl/source/sharings/sharing_factory.h"
#include "CL/cl_ext.h"

View File

@@ -10,6 +10,7 @@
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/compiler_interface/compiler_interface.h"
#include "shared/source/compiler_interface/intermediate_representations.h"
#include "shared/source/compiler_interface/oclc_extensions.h"
#include "shared/source/device_binary_format/device_binary_formats.h"
#include "shared/source/device_binary_format/elf/elf_encoder.h"
#include "shared/source/device_binary_format/elf/ocl_elf.h"
@@ -28,7 +29,6 @@
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/context/context.h"
#include "opencl/source/platform/extensions.h"
#include "opencl/source/platform/platform.h"
#include "opencl/source/program/block_kernel_manager.h"

View File

@@ -7,10 +7,9 @@
#include "sharing_factory.h"
#include "shared/source/compiler_interface/oclc_extensions.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "opencl/source/platform/extensions.h"
namespace NEO {
std::unique_ptr<SharingFactory> SharingFactory::build() {