Skip to content

Commit 8118731

Browse files
committed
revert header-only feature macros for OpenCL C 2.0
1 parent da29d83 commit 8118731

File tree

6 files changed

+318
-120
lines changed

6 files changed

+318
-120
lines changed

clang/include/clang/Basic/OpenCLExtensions.def

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,55 @@ OPENCL_EXTENSION(cl_khr_depth_images, true, 120)
7878
OPENCL_EXTENSION(cl_khr_gl_msaa_sharing,true, 120)
7979

8080
// OpenCL 2.0.
81+
OPENCL_EXTENSION(cl_ext_float_atomics, true, 200)
82+
OPENCL_EXTENSION(cl_khr_extended_bit_ops, true, 200)
83+
OPENCL_EXTENSION(cl_khr_integer_dot_product, true, 200)
84+
OPENCL_EXTENSION(cl_khr_kernel_clock, true, 200)
8185
OPENCL_EXTENSION(cl_khr_mipmap_image, true, 200)
8286
OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 200)
8387
OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200)
88+
OPENCL_EXTENSION(cl_khr_subgroup_ballot, true, 200)
89+
OPENCL_EXTENSION(cl_khr_subgroup_clustered_reduce, true, 200)
90+
OPENCL_EXTENSION(cl_khr_subgroup_extended_types, true, 200)
91+
OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_arithmetic, true, 200)
92+
OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, true, 200)
93+
OPENCL_EXTENSION(cl_khr_subgroup_rotate, true, 200)
94+
OPENCL_EXTENSION(cl_khr_subgroup_shuffle_relative, true, 200)
95+
OPENCL_EXTENSION(cl_khr_subgroup_shuffle, true, 200)
8496
OPENCL_EXTENSION(cl_khr_subgroups, true, 200)
97+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 200, OCL_C_20)
98+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 200, OCL_C_20)
99+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_all_devices, false, 200, OCL_C_20)
100+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_device, false, 200, OCL_C_20)
101+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_device_enqueue, false, 200, OCL_C_20)
102+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_global_atomic_add, false, 200, OCL_C_20)
103+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_global_atomic_load_store, false, 200, OCL_C_20)
104+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_global_atomic_min_max, false, 200, OCL_C_20)
105+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_local_atomic_add, false, 200, OCL_C_20)
106+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_local_atomic_load_store, false, 200, OCL_C_20)
107+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_local_atomic_min_max, false, 200, OCL_C_20)
108+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp32_global_atomic_add, false, 200, OCL_C_20)
109+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp32_global_atomic_min_max, false, 200, OCL_C_20)
110+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp32_local_atomic_add, false, 200, OCL_C_20)
111+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp32_local_atomic_min_max, false, 200, OCL_C_20)
112+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp64_global_atomic_add, false, 200, OCL_C_20)
113+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp64_global_atomic_min_max, false, 200, OCL_C_20)
114+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp64_local_atomic_add, false, 200, OCL_C_20)
115+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp64_local_atomic_min_max, false, 200, OCL_C_20)
116+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_raw10_raw12, false, 200, OCL_C_20)
117+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unorm_int_2_101010, false, 200, OCL_C_20)
118+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unsigned_10x6_12x4_14x2, false, 200, OCL_C_20)
119+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_generic_address_space, false, 200, OCL_C_20)
120+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_images, false, 200, OCL_C_20)
121+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit, false, 200, OCL_C_20)
122+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit_packed, false, 200, OCL_C_20)
123+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_device, false, 200, OCL_C_20)
124+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_sub_group, false, 200, OCL_C_20)
125+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_work_group, false, 200, OCL_C_20)
126+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_pipes, false, 200, OCL_C_20)
127+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_program_scope_global_variables, false, 200, OCL_C_20)
128+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_read_write_images, false, 200, OCL_C_20)
129+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_work_group_collective_functions, false, 200, OCL_C_20)
85130

86131
// Clang Extensions.
87132
OPENCL_EXTENSION(cl_clang_storage_class_specifiers, true, 100)
@@ -100,27 +145,9 @@ OPENCL_EXTENSION(cl_intel_subgroups_short, true, 120)
100145
OPENCL_EXTENSION(cl_intel_device_side_avc_motion_estimation, true, 120)
101146

102147
// OpenCL C 3.0 features (6.2.1. Features)
103-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_pipes, false, 300, OCL_C_30)
104-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_generic_address_space, false, 300, OCL_C_30)
105-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 300, OCL_C_30)
106-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 300, OCL_C_30)
107-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_device, false, 300, OCL_C_30)
108-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_all_devices, false, 300, OCL_C_30)
109-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_subgroups, false, 300, OCL_C_30)
110148
OPENCL_OPTIONALCOREFEATURE(__opencl_c_3d_image_writes, false, 300, OCL_C_30)
111-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_device_enqueue, false, 300, OCL_C_30)
112-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_read_write_images, false, 300, OCL_C_30)
113-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_program_scope_global_variables, false, 300, OCL_C_30)
114149
OPENCL_OPTIONALCOREFEATURE(__opencl_c_fp64, false, 300, OCL_C_30)
115-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_images, false, 300, OCL_C_30)
116-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_work_group_collective_functions, false, 300, OCL_C_30)
117-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit_packed, false, 300, OCL_C_30)
118-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit, false, 300, OCL_C_30)
119-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_device, false, 300, OCL_C_30)
120-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_work_group, false, 300, OCL_C_30)
121-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_sub_group, false, 300, OCL_C_30)
122-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unorm_int_2_101010, false, 300, OCL_C_30)
123-
OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unsigned_10x6_12x4_14x2, false, 300, OCL_C_30)
150+
OPENCL_OPTIONALCOREFEATURE(__opencl_c_subgroups, false, 300, OCL_C_30)
124151

125152
#undef OPENCL_OPTIONALCOREFEATURE
126153
#undef OPENCL_COREFEATURE

clang/lib/Basic/Targets/AMDGPU.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
320320
Opts["__opencl_c_3d_image_writes"] = true;
321321
Opts["cl_khr_3d_image_writes"] = true;
322322
Opts["__opencl_c_program_scope_global_variables"] = true;
323+
Opts["__opencl_c_atomic_scope_all_devices"] = true;
324+
Opts["__opencl_c_atomic_order_seq_cst"] = true;
323325

324326
if (GPUKind >= llvm::AMDGPU::GK_GFX700) {
325327
Opts["__opencl_c_generic_address_space"] = true;

clang/lib/Headers/opencl-c-base.h

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -9,92 +9,6 @@
99
#ifndef _OPENCL_BASE_H_
1010
#define _OPENCL_BASE_H_
1111

12-
// Define extension macros
13-
14-
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
15-
// For SPIR and SPIR-V all extensions are supported.
16-
#if defined(__SPIR__) || defined(__SPIRV__)
17-
#define cl_khr_subgroup_extended_types 1
18-
#define cl_khr_subgroup_non_uniform_vote 1
19-
#define cl_khr_subgroup_ballot 1
20-
#define cl_khr_subgroup_non_uniform_arithmetic 1
21-
#define cl_khr_subgroup_shuffle 1
22-
#define cl_khr_subgroup_shuffle_relative 1
23-
#define cl_khr_subgroup_clustered_reduce 1
24-
#define cl_khr_subgroup_rotate 1
25-
#define cl_khr_extended_bit_ops 1
26-
#define cl_khr_integer_dot_product 1
27-
#define __opencl_c_integer_dot_product_input_4x8bit 1
28-
#define __opencl_c_integer_dot_product_input_4x8bit_packed 1
29-
#define cl_ext_float_atomics 1
30-
#ifdef cl_khr_fp16
31-
#define __opencl_c_ext_fp16_global_atomic_load_store 1
32-
#define __opencl_c_ext_fp16_local_atomic_load_store 1
33-
#define __opencl_c_ext_fp16_global_atomic_add 1
34-
#define __opencl_c_ext_fp16_local_atomic_add 1
35-
#define __opencl_c_ext_fp16_global_atomic_min_max 1
36-
#define __opencl_c_ext_fp16_local_atomic_min_max 1
37-
#endif
38-
#ifdef cl_khr_fp64
39-
#define __opencl_c_ext_fp64_global_atomic_add 1
40-
#define __opencl_c_ext_fp64_local_atomic_add 1
41-
#define __opencl_c_ext_fp64_global_atomic_min_max 1
42-
#define __opencl_c_ext_fp64_local_atomic_min_max 1
43-
#endif
44-
#define __opencl_c_ext_fp32_global_atomic_add 1
45-
#define __opencl_c_ext_fp32_local_atomic_add 1
46-
#define __opencl_c_ext_fp32_global_atomic_min_max 1
47-
#define __opencl_c_ext_fp32_local_atomic_min_max 1
48-
#define __opencl_c_ext_image_raw10_raw12 1
49-
#define __opencl_c_ext_image_unorm_int_2_101010 1
50-
#define __opencl_c_ext_image_unsigned_10x6_12x4_14x2 1
51-
#define cl_khr_kernel_clock 1
52-
#define __opencl_c_kernel_clock_scope_device 1
53-
#define __opencl_c_kernel_clock_scope_work_group 1
54-
#define __opencl_c_kernel_clock_scope_sub_group 1
55-
56-
#endif // defined(__SPIR__) || defined(__SPIRV__)
57-
#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
58-
59-
// Define feature macros for OpenCL C 2.0
60-
#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
61-
#define __opencl_c_pipes 1
62-
#define __opencl_c_generic_address_space 1
63-
#define __opencl_c_work_group_collective_functions 1
64-
#define __opencl_c_atomic_order_acq_rel 1
65-
#define __opencl_c_atomic_order_seq_cst 1
66-
#define __opencl_c_atomic_scope_device 1
67-
#define __opencl_c_atomic_scope_all_devices 1
68-
#define __opencl_c_device_enqueue 1
69-
#define __opencl_c_read_write_images 1
70-
#define __opencl_c_program_scope_global_variables 1
71-
#define __opencl_c_images 1
72-
#endif
73-
74-
// Undefine any feature macros that have been explicitly disabled using
75-
// an __undef_<feature> macro.
76-
#ifdef __undef___opencl_c_work_group_collective_functions
77-
#undef __opencl_c_work_group_collective_functions
78-
#endif
79-
#ifdef __undef___opencl_c_atomic_order_seq_cst
80-
#undef __opencl_c_atomic_order_seq_cst
81-
#endif
82-
#ifdef __undef___opencl_c_atomic_scope_device
83-
#undef __opencl_c_atomic_scope_device
84-
#endif
85-
#ifdef __undef___opencl_c_atomic_scope_all_devices
86-
#undef __opencl_c_atomic_scope_all_devices
87-
#endif
88-
#ifdef __undef___opencl_c_read_write_images
89-
#undef __opencl_c_read_write_images
90-
#endif
91-
#ifdef __undef___opencl_c_integer_dot_product_input_4x8bit
92-
#undef __opencl_c_integer_dot_product_input_4x8bit
93-
#endif
94-
#ifdef __undef___opencl_c_integer_dot_product_input_4x8bit_packed
95-
#undef __opencl_c_integer_dot_product_input_4x8bit_packed
96-
#endif
97-
9812
#if !defined(__opencl_c_generic_address_space)
9913
// Internal feature macro to provide named (global, local, private) address
10014
// space overloads for builtin functions that take a pointer argument.

clang/test/Headers/opencl-c-header.cl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// ===
3434
// Compile for OpenCL 2.0 for the first time. The module should change.
3535
// RUN: %clang_cc1 -triple spir-unknown-unknown -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
36-
// RUN: not diff %t/1_0.pcm %t/opencl_c.pcm
36+
// RUN: not diff %t/1_0.pcm %t/opencl_c.pcm > /dev/null
3737
// RUN: chmod u-w %t/opencl_c.pcm
3838

3939
// ===
@@ -44,10 +44,10 @@
4444
// RUN: rm -rf %t
4545
// RUN: mkdir -p %t
4646
// RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
47-
// RUN: %clang_cc1 -triple amdgcn--amdhsa -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
47+
// RUN: %clang_cc1 -triple amdgcn--amdhsa -target-cpu gfx700 -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
4848
// RUN: chmod u-w %t
4949
// RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
50-
// RUN: %clang_cc1 -triple amdgcn--amdhsa -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
50+
// RUN: %clang_cc1 -triple amdgcn--amdhsa -target-cpu gfx700 -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
5151
// RUN: chmod u+w %t
5252

5353
// Verify that called builtins occur in the generated IR.

0 commit comments

Comments
 (0)