Skip to content

Commit 39d93d6

Browse files
committed
[OpenCL] Allow undefining cl_khr_integer_dot_product features macros
Add header-side undef hooks for: __opencl_c_integer_dot_product_input_4x8bit __opencl_c_integer_dot_product_input_4x8bit_packed Motivation: our downstream legacy targets lack cl_khr_integer_dot_product builtins (similar to a60b8f4). Providing __undef__* macros lets users suppress the feature macros without patching headers. Fix intel/compute-runtime#817
1 parent 6f3d765 commit 39d93d6

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
#define __opencl_c_kernel_clock_scope_work_group 1
5454
#define __opencl_c_kernel_clock_scope_sub_group 1
5555

56+
#ifdef __undef___opencl_c_integer_dot_product_input_4x8bit
57+
#undef __opencl_c_integer_dot_product_input_4x8bit
58+
#endif
59+
#ifdef __undef___opencl_c_integer_dot_product_input_4x8bit_packed
60+
#undef __opencl_c_integer_dot_product_input_4x8bit_packed
61+
#endif
62+
5663
#endif // defined(__SPIR__) || defined(__SPIRV__)
5764
#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
5865

clang/test/SemaOpenCL/features.cl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \
2727
// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES
2828

29+
// For OpenCL C 2.0, header-only features can be disabled using macros.
30+
// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header \
31+
// RUN: -D__undef___opencl_c_integer_dot_product_input_4x8bit \
32+
// RUN: -D__undef___opencl_c_integer_dot_product_input_4x8bit_packed \
33+
// RUN: | FileCheck %s --check-prefix=NO-HEADERONLY-FEATURES-CL20
34+
2935
// For OpenCL C 3.0, header-only features can be disabled using macros.
3036
// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \
3137
// RUN: -D__undef___opencl_c_work_group_collective_functions=1 \
@@ -64,6 +70,9 @@
6470
// NO-FEATURES-NOT: #define __opencl_c_read_write_images
6571
// NO-FEATURES-NOT: #define __opencl_c_subgroups
6672

73+
// NO-HEADERONLY-FEATURES-CL20-NOT: #define __opencl_c_integer_dot_product_input_4x8bit
74+
// NO-HEADERONLY-FEATURES-CL20-NOT: #define __opencl_c_integer_dot_product_input_4x8bit_packed
75+
6776
// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_work_group_collective_functions
6877
// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst
6978
// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_device

0 commit comments

Comments
 (0)