1 // RUN
: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ..
/..
/lib
/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s
2 // RUN
: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ..
/..
/lib
/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std
=CL1.1 | FileCheck %s
3 // RUN
: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ..
/..
/lib
/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std
=CL1.2 | FileCheck %s
4 // RUN
: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ..
/..
/lib
/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std
=clc
++1.0 | FileCheck %s --check-prefix
=CHECK20
5 // RUN
: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ..
/..
/lib
/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std
=CL3.0 | FileCheck %s
6 // RUN
: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ..
/..
/lib
/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std
=clc
++2021 | FileCheck %s
8 // RUN
: %clang_cc1 -O0 -triple spirv32-unknown-unknown -internal-isystem ..
/..
/lib
/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s
11 // Test including the default header as a module.
12 // The module should be compiled only once and loaded from cache afterwards.
13 // Change the directory mode to read only to make sure no new modules are created.
14 // Check time report to make sure module is used.
15 // Check that some builtins occur in the generated IR when called.
18 // Clear current directory.
23 // Compile for OpenCL
1.0 for the first time. A module should be generated.
24 // RUN
: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path
=%t -fdisable-module-hash -ftime-report %s
2>&1 | FileCheck --check-prefix
=CHECK --check-prefix
=CHECK-MOD %s
25 // RUN
: chmod u-w %t
/opencl_c.pcm
28 // Compile for OpenCL
1.0 for the second time. The module should not be re-created.
29 // RUN
: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path
=%t -fdisable-module-hash -ftime-report %s
2>&1 | FileCheck --check-prefix
=CHECK --check-prefix
=CHECK-MOD %s
30 // RUN
: chmod u
+w %t
/opencl_c.pcm
31 // RUN
: mv %t
/opencl_c.pcm %t
/1_0.pcm
34 // Compile for OpenCL
2.0 for the first time. The module should change.
35 // 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
37 // RUN
: chmod u-w %t
/opencl_c.pcm
40 // Compile for OpenCL
2.0 for the second time. The module should not change.
41 // 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
43 // Check cached module works for different OpenCL versions.
46 // 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
49 // 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
53 // Verify that called builtins occur in the generated IR.
55 // CHECK-NOT
: intel_sub_group_avc_mce_get_default_inter_base_multi_reference_penalty
56 // CHECK-NOT
: ndrange_t
58 // CHECK
: _Z16convert_char_rtec
61 // CHECK20
: _Z16convert_char_rtec
63 // Check functionality from OpenCL
2.0 onwards
64 #if
(__OPENCL_CPP_VERSION__ == 100) ||
(__OPENCL_C_VERSION__ == CL_VERSION_2_0
)
67 #endif
//__OPENCL_C_VERSION__
68 return convert_char_rte
(x);
71 // Verify that a builtin using a write_only image3d_t type is available
72 // from OpenCL
2.0 onwards.
74 // CHECK20
: _Z12write_imagef14ocl_image3d_wo
75 #if defined
(__OPENCL_CPP_VERSION__) ||
(__OPENCL_C_VERSION__ >= CL_VERSION_2_0
)
76 void test_image3dwo
(write_only image3d_t img
) {
77 write_imagef
(img, (0), (0.0f
));
79 #endif
//__OPENCL_C_VERSION__
81 #if defined
(__OPENCL_CPP_VERSION__)
82 // Test old atomic overloaded with generic addr space.
83 void test_atomics
(__generic volatile unsigned int
* a
) {
88 // Verify that ATOMIC_VAR_INIT is defined.
89 #if
(__OPENCL_CPP_VERSION__ == 100) ||
(__OPENCL_C_VERSION__ == CL_VERSION_2_0
)
90 global atomic_int z
= ATOMIC_VAR_INIT
(99);
91 #endif
//__OPENCL_C_VERSION__
92 // CHECK-MOD
: Reading modules
94 // Check that extension macros are defined correctly.
96 // For SPIR all extensions are supported.
97 #if defined
(__SPIR__) || defined
(__SPIRV__)
99 // Verify that cl_intel_planar_yuv extension is defined from OpenCL
1.2 onwards.
100 #if defined
(__OPENCL_CPP_VERSION__) ||
(__OPENCL_C_VERSION__ >= CL_VERSION_1_2
)
101 // expected-no-diagnostics
102 #else
//__OPENCL_C_VERSION__
103 // expected-warning
@+2{{OpenCL extension
'cl_intel_planar_yuv
' unknown or does not require pragma - ignoring
}}
104 #endif
//__OPENCL_C_VERSION__
105 #pragma OPENCL EXTENSION cl_intel_planar_yuv
: enable
107 #if
(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__
>= 200)
109 #if cl_khr_subgroup_extended_types
!= 1
110 #error
"Incorrectly defined cl_khr_subgroup_extended_types"
112 #if cl_khr_subgroup_non_uniform_vote
!= 1
113 #error
"Incorrectly defined cl_khr_subgroup_non_uniform_vote"
115 #if cl_khr_subgroup_ballot
!= 1
116 #error
"Incorrectly defined cl_khr_subgroup_ballot"
118 #if cl_khr_subgroup_non_uniform_arithmetic
!= 1
119 #error
"Incorrectly defined cl_khr_subgroup_non_uniform_arithmetic"
121 #if cl_khr_subgroup_shuffle
!= 1
122 #error
"Incorrectly defined cl_khr_subgroup_shuffle"
124 #if cl_khr_subgroup_shuffle_relative
!= 1
125 #error
"Incorrectly defined cl_khr_subgroup_shuffle_relative"
127 #if cl_khr_subgroup_clustered_reduce
!= 1
128 #error
"Incorrectly defined cl_khr_subgroup_clustered_reduce"
130 #if cl_khr_subgroup_rotate
!= 1
131 #error
"Incorrectly defined cl_khr_subgroup_rotate"
133 #if cl_khr_extended_bit_ops
!= 1
134 #error
"Incorrectly defined cl_khr_extended_bit_ops"
136 #if cl_khr_integer_dot_product
!= 1
137 #error
"Incorrectly defined cl_khr_integer_dot_product"
139 #if __opencl_c_integer_dot_product_input_4x8bit
!= 1
140 #error
"Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit"
142 #if __opencl_c_integer_dot_product_input_4x8bit_packed
!= 1
143 #error
"Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit_packed"
145 #if cl_ext_float_atomics
!= 1
146 #error
"Incorrectly defined cl_ext_float_atomics"
148 #if __opencl_c_ext_fp16_global_atomic_load_store
!= 1
149 #error
"Incorrectly defined __opencl_c_ext_fp16_global_atomic_load_store"
151 #if __opencl_c_ext_fp16_local_atomic_load_store
!= 1
152 #error
"Incorrectly defined __opencl_c_ext_fp16_local_atomic_load_store"
154 #if __opencl_c_ext_fp16_global_atomic_add
!= 1
155 #error
"Incorrectly defined __opencl_c_ext_fp16_global_atomic_add"
157 #if __opencl_c_ext_fp32_global_atomic_add
!= 1
158 #error
"Incorrectly defined __opencl_c_ext_fp32_global_atomic_add"
160 #if __opencl_c_ext_fp64_global_atomic_add
!= 1
161 #error
"Incorrectly defined __opencl_c_ext_fp64_global_atomic_add"
163 #if __opencl_c_ext_fp16_local_atomic_add
!= 1
164 #error
"Incorrectly defined __opencl_c_ext_fp16_local_atomic_add"
166 #if __opencl_c_ext_fp32_local_atomic_add
!= 1
167 #error
"Incorrectly defined __opencl_c_ext_fp32_local_atomic_add"
169 #if __opencl_c_ext_fp64_local_atomic_add
!= 1
170 #error
"Incorrectly defined __opencl_c_ext_fp64_local_atomic_add"
172 #if __opencl_c_ext_fp16_global_atomic_min_max
!= 1
173 #error
"Incorrectly defined __opencl_c_ext_fp16_global_atomic_min_max"
175 #if __opencl_c_ext_fp32_global_atomic_min_max
!= 1
176 #error
"Incorrectly defined __opencl_c_ext_fp32_global_atomic_min_max"
178 #if __opencl_c_ext_fp64_global_atomic_min_max
!= 1
179 #error
"Incorrectly defined __opencl_c_ext_fp64_global_atomic_min_max"
181 #if __opencl_c_ext_fp16_local_atomic_min_max
!= 1
182 #error
"Incorrectly defined __opencl_c_ext_fp16_local_atomic_min_max"
184 #if __opencl_c_ext_fp32_local_atomic_min_max
!= 1
185 #error
"Incorrectly defined __opencl_c_ext_fp32_local_atomic_min_max"
187 #if __opencl_c_ext_fp64_local_atomic_min_max
!= 1
188 #error
"Incorrectly defined __opencl_c_ext_fp64_local_atomic_min_max"
193 #ifdef cl_khr_subgroup_extended_types
194 #error
"Incorrect cl_khr_subgroup_extended_types define"
196 #ifdef cl_khr_subgroup_non_uniform_vote
197 #error
"Incorrect cl_khr_subgroup_non_uniform_vote define"
199 #ifdef cl_khr_subgroup_ballot
200 #error
"Incorrect cl_khr_subgroup_ballot define"
202 #ifdef cl_khr_subgroup_non_uniform_arithmetic
203 #error
"Incorrect cl_khr_subgroup_non_uniform_arithmetic define"
205 #ifdef cl_khr_subgroup_shuffle
206 #error
"Incorrect cl_khr_subgroup_shuffle define"
208 #ifdef cl_khr_subgroup_shuffle_relative
209 #error
"Incorrect cl_khr_subgroup_shuffle_relative define"
211 #ifdef cl_khr_subgroup_clustered_reduce
212 #error
"Incorrect cl_khr_subgroup_clustered_reduce define"
214 #ifdef cl_khr_subgroup_rotate
215 #error
"Incorrect cl_khr_subgroup_rotate define"
217 #ifdef cl_khr_extended_bit_ops
218 #error
"Incorrect cl_khr_extended_bit_ops define"
220 #ifdef cl_khr_integer_dot_product
221 #error
"Incorrect cl_khr_integer_dot_product define"
223 #ifdef __opencl_c_integer_dot_product_input_4x8bit
224 #error
"Incorrect __opencl_c_integer_dot_product_input_4x8bit define"
226 #ifdef __opencl_c_integer_dot_product_input_4x8bit_packed
227 #error
"Incorrect __opencl_c_integer_dot_product_input_4x8bit_packed define"
229 #ifdef cl_ext_float_atomics
230 #error
"Incorrect cl_ext_float_atomics define"
232 #ifdef __opencl_c_ext_fp16_global_atomic_load_store
233 #error
"Incorrectly __opencl_c_ext_fp16_global_atomic_load_store defined"
235 #ifdef __opencl_c_ext_fp16_local_atomic_load_store
236 #error
"Incorrectly __opencl_c_ext_fp16_local_atomic_load_store defined"
238 #ifdef __opencl_c_ext_fp16_global_atomic_add
239 #error
"Incorrectly __opencl_c_ext_fp16_global_atomic_add defined"
241 #ifdef __opencl_c_ext_fp32_global_atomic_add
242 #error
"Incorrectly __opencl_c_ext_fp32_global_atomic_add defined"
244 #ifdef __opencl_c_ext_fp64_global_atomic_add
245 #error
"Incorrectly __opencl_c_ext_fp64_global_atomic_add defined"
247 #ifdef __opencl_c_ext_fp16_local_atomic_add
248 #error
"Incorrectly __opencl_c_ext_fp16_local_atomic_add defined"
250 #ifdef __opencl_c_ext_fp32_local_atomic_add
251 #error
"Incorrectly __opencl_c_ext_fp32_local_atomic_add defined"
253 #ifdef __opencl_c_ext_fp64_local_atomic_add
254 #error
"Incorrectly __opencl_c_ext_fp64_local_atomic_add defined"
256 #ifdef __opencl_c_ext_fp16_global_atomic_min_max
257 #error
"Incorrectly __opencl_c_ext_fp16_global_atomic_min_max defined"
259 #ifdef __opencl_c_ext_fp32_global_atomic_min_max
260 #error
"Incorrectly __opencl_c_ext_fp32_global_atomic_min_max defined"
262 #ifdef __opencl_c_ext_fp64_global_atomic_min_max
263 #error
"Incorrectly __opencl_c_ext_fp64_global_atomic_min_max defined"
265 #ifdef __opencl_c_ext_fp16_local_atomic_min_max
266 #error
"Incorrectly __opencl_c_ext_fp16_local_atomic_min_max defined"
268 #ifdef __opencl_c_ext_fp32_local_atomic_min_max
269 #error
"Incorrectly __opencl_c_ext_fp32_local_atomic_min_max defined"
271 #ifdef __opencl_c_ext_fp64_local_atomic_min_max
272 #error
"Incorrectly __opencl_c_ext_fp64_local_atomic_min_max defined"
275 #endif
//(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__
>= 200)
277 // OpenCL C features.
278 #if
(__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__
== 300)
280 #if __opencl_c_atomic_scope_all_devices
!= 1
281 #error
"Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices"
284 #elif
(__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__
== 200)
286 #ifndef __opencl_c_pipes
287 #error
"Feature macro __opencl_c_pipes should be defined"
289 #ifndef __opencl_c_generic_address_space
290 #error
"Feature macro __opencl_c_generic_address_space should be defined"
292 #ifndef __opencl_c_work_group_collective_functions
293 #error
"Feature macro __opencl_c_work_group_collective_functions should be defined"
295 #ifndef __opencl_c_atomic_order_acq_rel
296 #error
"Feature macro __opencl_c_atomic_order_acq_rel should be defined"
298 #ifndef __opencl_c_atomic_order_seq_cst
299 #error
"Feature macro __opencl_c_atomic_order_seq_cst should be defined"
301 #ifndef __opencl_c_atomic_scope_device
302 #error
"Feature macro __opencl_c_atomic_scope_device should be defined"
304 #ifndef __opencl_c_atomic_scope_all_devices
305 #error
"Feature macro __opencl_c_atomic_scope_all_devices should be defined"
307 #ifndef __opencl_c_device_enqueue
308 #error
"Feature macro __opencl_c_device_enqueue should be defined"
310 #ifndef __opencl_c_read_write_images
311 #error
"Feature macro __opencl_c_read_write_images should be defined"
313 #ifndef __opencl_c_program_scope_global_variables
314 #error
"Feature macro __opencl_c_program_scope_global_variables should be defined"
316 #ifndef __opencl_c_images
317 #error
"Feature macro __opencl_c_images should be defined"
320 #elif
(__OPENCL_C_VERSION__ < 200)
322 #ifdef __opencl_c_pipes
323 #error
"Incorrect feature macro __opencl_c_pipes define"
325 #ifdef __opencl_c_generic_address_space
326 #error
"Incorrect feature macro __opencl_c_generic_address_space define"
328 #ifdef __opencl_c_work_group_collective_functions
329 #error
"Incorrect feature macro __opencl_c_work_group_collective_functions define"
331 #ifdef __opencl_c_atomic_order_acq_rel
332 #error
"Incorrect feature macro __opencl_c_atomic_order_acq_rel define"
334 #ifdef __opencl_c_atomic_order_seq_cst
335 #error
"Incorrect feature macro __opencl_c_atomic_order_seq_cst define"
337 #ifdef __opencl_c_atomic_scope_device
338 #error
"Incorrect feature macro __opencl_c_atomic_scope_device define"
340 #ifdef __opencl_c_atomic_scope_all_devices
341 #error
"Incorrect feature macro __opencl_c_atomic_scope_all_devices define"
343 #ifdef __opencl_c_device_enqueue
344 #error
"Incorrect feature macro __opencl_c_device_enqueue define"
346 #ifdef __opencl_c_read_write_images
347 #error
"Incorrect feature macro __opencl_c_read_write_images define"
349 #ifdef __opencl_c_program_scope_global_variables
350 #error
"Incorrect feature macro __opencl_c_program_scope_global_variables define"
352 #ifdef __opencl_c_images
353 #error
"Incorrect feature macro __opencl_c_images define"
355 #ifdef __opencl_c_3d_image_writes
356 #error
"Incorrect feature macro __opencl_c_3d_image_writes define"
358 #ifdef __opencl_c_fp64
359 #error
"Incorrect feature macro __opencl_c_fp64 define"
361 #ifdef __opencl_c_subgroups
362 #error
"Incorrect feature macro __opencl_c_subgroups define"
365 #endif
// (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__
== 300)
367 #endif
// defined
(__SPIR__)