Skip to content

Commit fd73bdd

Browse files
authored
[OpenCL] Allow undefining cl_khr_integer_dot_product features macros (#162055)
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 e3a376f commit fd73bdd

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
#define __opencl_c_read_write_images 1
8383
#endif // defined(__SPIR__)
8484

85+
#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
86+
8587
// Undefine any feature macros that have been explicitly disabled using
8688
// an __undef_<feature> macro.
8789
#ifdef __undef___opencl_c_work_group_collective_functions
@@ -99,8 +101,12 @@
99101
#ifdef __undef___opencl_c_read_write_images
100102
#undef __opencl_c_read_write_images
101103
#endif
102-
103-
#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
104+
#ifdef __undef___opencl_c_integer_dot_product_input_4x8bit
105+
#undef __opencl_c_integer_dot_product_input_4x8bit
106+
#endif
107+
#ifdef __undef___opencl_c_integer_dot_product_input_4x8bit_packed
108+
#undef __opencl_c_integer_dot_product_input_4x8bit_packed
109+
#endif
104110

105111
#if !defined(__opencl_c_generic_address_space)
106112
// Internal feature macro to provide named (global, local, private) address

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)