1 // RUN
: %clang_cc1 %s -cl-std
=CL2.0 -triple
"spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS
=
2 // RUN
: %clang_cc1 %s -cl-std
=CL2.0 -triple
"spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS
= -cl-ext
=-cl_khr_subgroups
3 // RUN
: %clang_cc1 %s -cl-std
=CL2.0 -triple
"spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS
="const volatile"
4 // RUN
: %clang_cc1 %s -cl-std
=CL2.0 -triple
"spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS
=
5 // RUN
: %clang_cc1 %s -cl-std
=CL2.0 -triple
"spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS
="const volatile"
6 // RUN
: %clang_cc1 %s -cl-std
=CL3.0 -triple
"spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS
=
7 // RUN
: %clang_cc1 %s -cl-std
=CL3.0 -triple
"spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS
= -cl-ext
=-cl_khr_subgroups
,-__opencl_c_subgroups
8 // RUN
: %clang_cc1 %s -cl-std
=CL3.0 -triple
"spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS
="const volatile"
9 // RUN
: %clang_cc1 %s -cl-std
=CL3.0 -triple
"spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS
=
10 // RUN
: %clang_cc1 %s -cl-std
=CL3.0 -triple
"spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS
="const volatile"
12 typedef struct
{int a
;} ndrange_t;
13 // Diagnostic tests for different overloads of enqueue_kernel from Table
6.13.17.1 of OpenCL
2.0 Spec.
14 kernel void enqueue_kernel_tests
(void) {
15 queue_t default_queue
;
17 QUALS ndrange_t ndrange
;
19 clk_event_t event_wait_list
;
20 clk_event_t event_wait_list2
[] = {evt
, evt
};
23 // Testing the first overload type
24 enqueue_kernel
(default_queue, flags
, ndrange
, ^
(void) {
28 enqueue_kernel
(vptr, flags
, ndrange
, ^
(void) { // expected-error
{{illegal call to
'enqueue_kernel
', expected
'queue_t
' argument type
}}
32 enqueue_kernel
(default_queue, vptr
, ndrange
, ^
(void) { // expected-error
{{illegal call to
'enqueue_kernel
', expected
'kernel_enqueue_flags_t
' (i.e. uint
) argument type
}}
36 enqueue_kernel
(default_queue, flags
, vptr
, ^
(void) { // expected-error
{{illegal call to
'enqueue_kernel
', expected
'ndrange_t
' argument type
}}
40 enqueue_kernel
(default_queue, flags
, ndrange
, vptr
); // expected-error{{illegal call to 'enqueue_kernel', expected block argument}}
42 enqueue_kernel
(default_queue, flags
, ndrange
, ^
(int i
) { // expected-error
{{blocks with parameters are not accepted in this prototype of enqueue_kernel call
}}
46 // Testing the second overload type
47 enqueue_kernel
(default_queue, flags
, ndrange
, 1, &event_wait_list
, &evt
, ^
(void) {
51 enqueue_kernel
(default_queue, flags
, ndrange
, 1, 0, 0, ^
(void) {
55 enqueue_kernel
(default_queue, flags
, ndrange
, vptr
, &event_wait_list
, &evt
, ^
(void) { // expected-error
{{illegal call to
'enqueue_kernel
', expected integer argument type
}}
59 enqueue_kernel
(default_queue, flags
, ndrange
, 1, vptr
, &evt
, ^
(void) // expected-error
{{illegal call to
'enqueue_kernel
', expected
'clk_event_t
*' argument type
}}
64 enqueue_kernel
(default_queue, flags
, ndrange
, 1, &event_wait_list
, vptr
, ^
(void) // expected-error
{{illegal call to
'enqueue_kernel
', expected
'clk_event_t
*' argument type
}}
69 enqueue_kernel
(default_queue, flags
, ndrange
, 1, &event_wait_list
, &evt
, vptr
); // expected-error{{illegal call to 'enqueue_kernel', expected block argument}}
71 // Testing the third overload type
72 enqueue_kernel
(default_queue, flags
, ndrange
,
73 ^
(local void
*a
, local void
*b
) {
78 enqueue_kernel
(default_queue, flags
, ndrange
,
79 ^
(local void
*a
, local void
*b
) {
84 enqueue_kernel
(default_queue, flags
, ndrange
,
85 ^
(local void
*a
, local void
*b
) {
90 // expected-warning
@-
2{{implicit conversion from
'long
' to
'unsigned int
' changes value from
4294967296 to
0}}
94 enqueue_kernel
(default_queue, flags
, ndrange
,
95 ^
(local void
*a
, local void
*b
) {
100 // expected-warning-re
@-
2{{implicit conversion changes signedness
: '__private char
' to
'unsigned
{{int|long
}}'}}
102 #define UINT_MAX
4294967295
104 enqueue_kernel
(default_queue, flags
, ndrange
,
105 ^
(local void
*a
, local void
*b
) {
108 sizeof
(int), sizeof
(int) * UINT_MAX
);
110 // expected-warning
@-
2{{implicit conversion from
'long
' to
'unsigned int
' changes value from
17179869180 to
4294967292}}
113 typedef void
(^bl_A_t
)(local void
*);
115 const bl_A_t block_A
= (bl_A_t) ^
(local void
*a
) {};
117 enqueue_kernel
(default_queue, flags
, ndrange
, block_A
, 1024);
119 typedef void
(^bl_B_t
)(local void
*, local int
*);
121 const bl_B_t block_B
= (bl_B_t) ^
(local void
*a
, local int
*b
) {};
123 enqueue_kernel
(default_queue, flags
, ndrange
, block_B
, 1024, 1024); // expected-error{{blocks used in enqueue_kernel call are expected to have parameters of type 'local void*'}}
125 enqueue_kernel
(default_queue, flags
, ndrange
, // expected-error
{{mismatch in number of block parameters and local size arguments passed
}}
126 ^
(local void
*a
, local void
*b
) {
131 float illegal_mem_size
= (float)0.5f
;
132 enqueue_kernel
(default_queue, flags
, ndrange
,
133 ^
(local void
*a
, local void
*b
) {
136 illegal_mem_size
, illegal_mem_size
); // expected-error{{illegal call to enqueue_kernel, parameter needs to be specified as integer type}} expected-error{{illegal call to enqueue_kernel, parameter needs to be specified as integer type}}
138 enqueue_kernel
(default_queue, flags
, ndrange
,
139 ^
(local void
*a
, local void
*b
) {
142 illegal_mem_size
, 1024); // expected-error{{illegal call to enqueue_kernel, parameter needs to be specified as integer type}}
144 // Testing the forth overload type
145 enqueue_kernel
(default_queue, flags
, ndrange
, 1, event_wait_list2
, &evt
,
146 ^
(local void
*a
, local void
*b
) {
151 enqueue_kernel
(default_queue, flags
, ndrange
, 1, 0, 0,
152 ^
(local void
*a
, local void
*b
) {
157 enqueue_kernel
(default_queue, flags
, ndrange
, 1, &event_wait_list
, &evt
, // expected-error
{{mismatch in number of block parameters and local size arguments passed
}}
158 ^
(local void
*a
, local void
*b
) {
163 // More random misc cases that can
't be deduced
164 enqueue_kernel
(default_queue, flags
, ndrange
, 1, &event_wait_list
, &evt
); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
166 enqueue_kernel
(default_queue, flags
, ndrange
, 1, 1); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
168 enqueue_kernel
(default_queue, ndrange
, ^
{}); // expected-error{{too few arguments to function call, expected at least 4, have 3}}
171 // Diagnostic tests for get_kernel_work_group_size and allowed block parameter types in dynamic parallelism.
172 kernel void work_group_size_tests
(void) {
173 void
(^const block_A
)(void) = ^
{
176 void
(^const block_B
)(int) = ^
(int a
) {
179 void
(^const block_C
)(local void
*) = ^
(local void
*a
) {
182 void
(^const block_D
)(local int
*) = ^
(local int
*a
) {
186 unsigned size
= get_kernel_work_group_size
(block_A);
187 size
= get_kernel_work_group_size
(block_C);
188 size
= get_kernel_work_group_size
(^
(local void
*a
) {
191 size
= get_kernel_work_group_size
(^
(local int
*a
) { // expected-error
{{blocks used in enqueue_kernel call are expected to have parameters of type
'local void
*'}}
194 size
= get_kernel_work_group_size
(block_B); // expected-error {{blocks used in enqueue_kernel call are expected to have parameters of type 'local void*'}}
195 size
= get_kernel_work_group_size
(block_D); // expected-error {{blocks used in enqueue_kernel call are expected to have parameters of type 'local void*'}}
196 size
= get_kernel_work_group_size
(^
(int a
) { // expected-error
{{blocks used in enqueue_kernel call are expected to have parameters of type
'local void
*'}}
199 size
= get_kernel_work_group_size
(); // expected-error {{too few arguments to function call, expected 1, have 0}}
200 size
= get_kernel_work_group_size
(1); // expected-error{{expected block argument}}
201 size
= get_kernel_work_group_size
(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
203 size
= get_kernel_preferred_work_group_size_multiple
(block_A);
204 size
= get_kernel_preferred_work_group_size_multiple
(block_C);
205 size
= get_kernel_preferred_work_group_size_multiple
(^
(local void
*a
) {
208 size
= get_kernel_preferred_work_group_size_multiple
(^
(local int
*a
) { // expected-error
{{blocks used in enqueue_kernel call are expected to have parameters of type
'local void
*'}}
211 size
= get_kernel_preferred_work_group_size_multiple
(^
(int a
) { // expected-error
{{blocks used in enqueue_kernel call are expected to have parameters of type
'local void
*'}}
214 size
= get_kernel_preferred_work_group_size_multiple
(block_B); // expected-error {{blocks used in enqueue_kernel call are expected to have parameters of type 'local void*'}}
215 size
= get_kernel_preferred_work_group_size_multiple
(block_D); // expected-error {{blocks used in enqueue_kernel call are expected to have parameters of type 'local void*'}}
216 size
= get_kernel_preferred_work_group_size_multiple
(); // expected-error {{too few arguments to function call, expected 1, have 0}}
217 size
= get_kernel_preferred_work_group_size_multiple
(1); // expected-error{{expected block argument}}
218 size
= get_kernel_preferred_work_group_size_multiple
(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
221 #ifdef cl_khr_subgroups
222 #pragma OPENCL EXTENSION cl_khr_subgroups
: enable
223 kernel void foo
(global unsigned int
*buf
)
226 buf
[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){});
227 buf[0] = get_kernel_max_sub_group_size_for_ndrange
(0, ^
(){}); // expected-error{{illegal call to 'get_kernel_max_sub_group_size_for_ndrange', expected 'ndrange_t' argument type}}
228 buf
[0] = get_kernel_max_sub_group_size_for_ndrange(n, 1); // expected-error{{illegal call to 'get_kernel_max_sub_group_size_for_ndrange', expected block argument type}}
231 kernel void bar(global unsigned int *buf)
233 __private ndrange_t n;
234 buf[0] = get_kernel_sub_group_count_for_ndrange
(n, ^
(){});
235 buf
[0] = get_kernel_sub_group_count_for_ndrange(0, ^(){}); // expected-error{{illegal call to 'get_kernel_sub_group_count_for_ndrange', expected 'ndrange_t' argument type}}
236 buf[0] = get_kernel_sub_group_count_for_ndrange
(n, 1); // expected-error{{illegal call to 'get_kernel_sub_group_count_for_ndrange', expected block argument type}}
239 #pragma OPENCL EXTENSION cl_khr_subgroups
: disable
241 kernel void foo1
(global unsigned int
*buf
)
244 buf
[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' requires cl_khr_subgroups or __opencl_c_subgroups support}}
247 kernel void bar1(global unsigned int *buf)
250 buf[0] = get_kernel_sub_group_count_for_ndrange
(n, ^
(){}); // expected-error {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires cl_khr_subgroups or __opencl_c_subgroups support}}
252 #endif
// ifdef cl_khr_subgroups