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"
190 #if __opencl_c_ext_image_raw10_raw12
!= 1
191 #error
"Incorrectly defined __opencl_c_ext_image_raw10_raw12"
193 #if __opencl_c_ext_image_unorm_int_2_101010
!= 1
194 #error
"Incorrectly defined __opencl_c_ext_image_unorm_int_2_101010"
199 #ifdef cl_khr_subgroup_extended_types
200 #error
"Incorrect cl_khr_subgroup_extended_types define"
202 #ifdef cl_khr_subgroup_non_uniform_vote
203 #error
"Incorrect cl_khr_subgroup_non_uniform_vote define"
205 #ifdef cl_khr_subgroup_ballot
206 #error
"Incorrect cl_khr_subgroup_ballot define"
208 #ifdef cl_khr_subgroup_non_uniform_arithmetic
209 #error
"Incorrect cl_khr_subgroup_non_uniform_arithmetic define"
211 #ifdef cl_khr_subgroup_shuffle
212 #error
"Incorrect cl_khr_subgroup_shuffle define"
214 #ifdef cl_khr_subgroup_shuffle_relative
215 #error
"Incorrect cl_khr_subgroup_shuffle_relative define"
217 #ifdef cl_khr_subgroup_clustered_reduce
218 #error
"Incorrect cl_khr_subgroup_clustered_reduce define"
220 #ifdef cl_khr_subgroup_rotate
221 #error
"Incorrect cl_khr_subgroup_rotate define"
223 #ifdef cl_khr_extended_bit_ops
224 #error
"Incorrect cl_khr_extended_bit_ops define"
226 #ifdef cl_khr_integer_dot_product
227 #error
"Incorrect cl_khr_integer_dot_product define"
229 #ifdef __opencl_c_integer_dot_product_input_4x8bit
230 #error
"Incorrect __opencl_c_integer_dot_product_input_4x8bit define"
232 #ifdef __opencl_c_integer_dot_product_input_4x8bit_packed
233 #error
"Incorrect __opencl_c_integer_dot_product_input_4x8bit_packed define"
235 #ifdef cl_ext_float_atomics
236 #error
"Incorrect cl_ext_float_atomics define"
238 #ifdef __opencl_c_ext_fp16_global_atomic_load_store
239 #error
"Incorrect __opencl_c_ext_fp16_global_atomic_load_store define"
241 #ifdef __opencl_c_ext_fp16_local_atomic_load_store
242 #error
"Incorrect __opencl_c_ext_fp16_local_atomic_load_store define"
244 #ifdef __opencl_c_ext_fp16_global_atomic_add
245 #error
"Incorrect __opencl_c_ext_fp16_global_atomic_add define"
247 #ifdef __opencl_c_ext_fp32_global_atomic_add
248 #error
"Incorrect __opencl_c_ext_fp32_global_atomic_add define"
250 #ifdef __opencl_c_ext_fp64_global_atomic_add
251 #error
"Incorrect __opencl_c_ext_fp64_global_atomic_add define"
253 #ifdef __opencl_c_ext_fp16_local_atomic_add
254 #error
"Incorrect __opencl_c_ext_fp16_local_atomic_add define"
256 #ifdef __opencl_c_ext_fp32_local_atomic_add
257 #error
"Incorrect __opencl_c_ext_fp32_local_atomic_add define"
259 #ifdef __opencl_c_ext_fp64_local_atomic_add
260 #error
"Incorrect __opencl_c_ext_fp64_local_atomic_add define"
262 #ifdef __opencl_c_ext_fp16_global_atomic_min_max
263 #error
"Incorrect __opencl_c_ext_fp16_global_atomic_min_max define"
265 #ifdef __opencl_c_ext_fp32_global_atomic_min_max
266 #error
"Incorrect __opencl_c_ext_fp32_global_atomic_min_max define"
268 #ifdef __opencl_c_ext_fp64_global_atomic_min_max
269 #error
"Incorrect __opencl_c_ext_fp64_global_atomic_min_max define"
271 #ifdef __opencl_c_ext_fp16_local_atomic_min_max
272 #error
"Incorrect __opencl_c_ext_fp16_local_atomic_min_max define"
274 #ifdef __opencl_c_ext_fp32_local_atomic_min_max
275 #error
"Incorrect __opencl_c_ext_fp32_local_atomic_min_max define"
277 #ifdef __opencl_c_ext_fp64_local_atomic_min_max
278 #error
"Incorrect __opencl_c_ext_fp64_local_atomic_min_max define"
280 #ifdef __opencl_c_ext_image_raw10_raw12
281 #error
"Incorrect __opencl_c_ext_image_raw10_raw12 define"
283 #ifdef __opencl_c_ext_image_unorm_int_2_101010
284 #error
"Incorrect __opencl_c_ext_image_unorm_int_2_101010 define"
287 #endif
//(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__
>= 200)
289 // OpenCL C features.
290 #if
(__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__
== 300)
292 #if __opencl_c_atomic_scope_all_devices
!= 1
293 #error
"Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices"
296 #elif
(__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__
== 200)
298 #ifndef __opencl_c_pipes
299 #error
"Feature macro __opencl_c_pipes should be defined"
301 #ifndef __opencl_c_generic_address_space
302 #error
"Feature macro __opencl_c_generic_address_space should be defined"
304 #ifndef __opencl_c_work_group_collective_functions
305 #error
"Feature macro __opencl_c_work_group_collective_functions should be defined"
307 #ifndef __opencl_c_atomic_order_acq_rel
308 #error
"Feature macro __opencl_c_atomic_order_acq_rel should be defined"
310 #ifndef __opencl_c_atomic_order_seq_cst
311 #error
"Feature macro __opencl_c_atomic_order_seq_cst should be defined"
313 #ifndef __opencl_c_atomic_scope_device
314 #error
"Feature macro __opencl_c_atomic_scope_device should be defined"
316 #ifndef __opencl_c_atomic_scope_all_devices
317 #error
"Feature macro __opencl_c_atomic_scope_all_devices should be defined"
319 #ifndef __opencl_c_device_enqueue
320 #error
"Feature macro __opencl_c_device_enqueue should be defined"
322 #ifndef __opencl_c_read_write_images
323 #error
"Feature macro __opencl_c_read_write_images should be defined"
325 #ifndef __opencl_c_program_scope_global_variables
326 #error
"Feature macro __opencl_c_program_scope_global_variables should be defined"
328 #ifndef __opencl_c_images
329 #error
"Feature macro __opencl_c_images should be defined"
332 #elif
(__OPENCL_C_VERSION__ < 200)
334 #ifdef __opencl_c_pipes
335 #error
"Incorrect feature macro __opencl_c_pipes define"
337 #ifdef __opencl_c_generic_address_space
338 #error
"Incorrect feature macro __opencl_c_generic_address_space define"
340 #ifdef __opencl_c_work_group_collective_functions
341 #error
"Incorrect feature macro __opencl_c_work_group_collective_functions define"
343 #ifdef __opencl_c_atomic_order_acq_rel
344 #error
"Incorrect feature macro __opencl_c_atomic_order_acq_rel define"
346 #ifdef __opencl_c_atomic_order_seq_cst
347 #error
"Incorrect feature macro __opencl_c_atomic_order_seq_cst define"
349 #ifdef __opencl_c_atomic_scope_device
350 #error
"Incorrect feature macro __opencl_c_atomic_scope_device define"
352 #ifdef __opencl_c_atomic_scope_all_devices
353 #error
"Incorrect feature macro __opencl_c_atomic_scope_all_devices define"
355 #ifdef __opencl_c_device_enqueue
356 #error
"Incorrect feature macro __opencl_c_device_enqueue define"
358 #ifdef __opencl_c_read_write_images
359 #error
"Incorrect feature macro __opencl_c_read_write_images define"
361 #ifdef __opencl_c_program_scope_global_variables
362 #error
"Incorrect feature macro __opencl_c_program_scope_global_variables define"
364 #ifdef __opencl_c_images
365 #error
"Incorrect feature macro __opencl_c_images define"
367 #ifdef __opencl_c_3d_image_writes
368 #error
"Incorrect feature macro __opencl_c_3d_image_writes define"
370 #ifdef __opencl_c_fp64
371 #error
"Incorrect feature macro __opencl_c_fp64 define"
373 #ifdef __opencl_c_subgroups
374 #error
"Incorrect feature macro __opencl_c_subgroups define"
377 #endif
// (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__
== 300)
379 #endif
// defined
(__SPIR__)