-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Clang] Add support for missing OpenCL extensions #129777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This patch adds handling for the following OpenCL extensions, passed as `-cl-ext` arguments to Clang: - cl_khr_extended_bit_ops - cl_khr_integer_dot_product - cl_khr_subgroup_ballot - cl_khr_subgroup_clustered_reduce - cl_khr_subgroup_extended_types - cl_khr_subgroup_named_barrier - cl_khr_subgroup_non_uniform_arithmetic - cl_khr_subgroup_non_uniform_vote - cl_khr_subgroup_rotate - cl_khr_subgroup_shuffle - cl_khr_subgroup_shuffle_relative - cl_khr_work_group_uniform_arithmetic - cl_intel_subgroups_char - cl_intel_subgroups_long
|
@llvm/pr-subscribers-clang Author: Victor Mustya (vmustya) ChangesThis patch adds handling for the following OpenCL extensions, passed as
Full diff: https://github.com/llvm/llvm-project/pull/129777.diff 2 Files Affected:
diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def
index 6f73b26137500..09ab1245a6a9a 100644
--- a/clang/include/clang/Basic/OpenCLExtensions.def
+++ b/clang/include/clang/Basic/OpenCLExtensions.def
@@ -90,13 +90,29 @@ OPENCL_EXTENSION(__cl_clang_variadic_functions, true, 100)
OPENCL_EXTENSION(__cl_clang_non_portable_kernel_param_types, true, 100)
OPENCL_EXTENSION(__cl_clang_bitfields, true, 100)
+// Khronos OpenCL extensions
+OPENCL_EXTENSION(cl_khr_extended_bit_ops, true, 100)
+OPENCL_EXTENSION(cl_khr_integer_dot_product, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_ballot, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_clustered_reduce, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_extended_types, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_named_barrier, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_arithmetic, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_rotate, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_shuffle, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_shuffle_relative, true, 100)
+OPENCL_EXTENSION(cl_khr_work_group_uniform_arithmetic, true, 200)
+
// AMD OpenCL extensions
OPENCL_EXTENSION(cl_amd_media_ops, true, 100)
OPENCL_EXTENSION(cl_amd_media_ops2, true, 100)
// Intel OpenCL extensions
OPENCL_EXTENSION(cl_intel_subgroups, true, 120)
+OPENCL_EXTENSION(cl_intel_subgroups_char, true, 120)
OPENCL_EXTENSION(cl_intel_subgroups_short, true, 120)
+OPENCL_EXTENSION(cl_intel_subgroups_long, true, 120)
OPENCL_EXTENSION(cl_intel_device_side_avc_motion_estimation, true, 120)
// OpenCL C 3.0 features (6.2.1. Features)
@@ -112,6 +128,11 @@ OPENCL_OPTIONALCOREFEATURE(__opencl_c_program_scope_global_variables, false, 300
OPENCL_OPTIONALCOREFEATURE(__opencl_c_fp64, false, 300, OCL_C_30)
OPENCL_OPTIONALCOREFEATURE(__opencl_c_images, false, 300, OCL_C_30)
+// Features enabled by the Khronos extensions
+OPENCL_GENERIC_EXTENSION(__opencl_c_work_group_collective_functions, false, 300, 0)
+OPENCL_GENERIC_EXTENSION(__opencl_c_integer_dot_product_input_4x8bit, false, 300, 0)
+OPENCL_GENERIC_EXTENSION(__opencl_c_integer_dot_product_input_4x8bit_packed, false, 300, 0)
+
#undef OPENCL_OPTIONALCOREFEATURE
#undef OPENCL_COREFEATURE
#undef OPENCL_GENERIC_EXTENSION
diff --git a/clang/lib/Basic/OpenCLOptions.cpp b/clang/lib/Basic/OpenCLOptions.cpp
index d39686ea688e5..9a58605294873 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -18,7 +18,14 @@ static const std::pair<StringRef, StringRef> DependentFeaturesList[] = {
{"__opencl_c_3d_image_writes", "__opencl_c_images"},
{"__opencl_c_pipes", "__opencl_c_generic_address_space"},
{"__opencl_c_device_enqueue", "__opencl_c_generic_address_space"},
- {"__opencl_c_device_enqueue", "__opencl_c_program_scope_global_variables"}};
+ {"__opencl_c_device_enqueue", "__opencl_c_program_scope_global_variables"},
+ {"__opencl_c_work_group_collective_functions",
+ "cl_khr_work_group_uniform_arithmetic"},
+ {"__opencl_c_integer_dot_product_input_4x8bit",
+ "cl_khr_integer_dot_product"},
+ {"__opencl_c_integer_dot_product_input_4x8bit_packed",
+ "cl_khr_integer_dot_product"},
+};
// Extensions and equivalent feature pairs.
static const std::pair<StringRef, StringRef> FeatureExtensionMap[] = {
|
svenvh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation for this change? We are trying to move away from adding extensions to this file for extensions that only add builtin functions, see e.g. https://reviews.llvm.org/D92231 . What functionality are you gaining by adding them here?
@svenvh, I'm trying to unify the extensions enablement in the user interface. We can enable or disable some of the extensions with the |
Got it, thanks for looking into this! I'm trying to refresh my memory on this, as this is something Anton, Anastasia and myself looked at back in 2021, but we never concluded the work. From the most recent discussion I could find on this topic, I think the consensus was that for header-only extensions given to |
@svenvh, in any case, we need a list of all the supported extensions, including the header ones. When someone passes the |
Indeed; we already have such a list in |
This patch adds handling for the following OpenCL extensions, passed as
-cl-extarguments to Clang: