• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
2// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -Wconversion -DWCONV
3
4// Diagnostic tests for different overloads of enqueue_kernel from Table 6.13.17.1 of OpenCL 2.0 Spec.
5kernel void enqueue_kernel_tests() {
6  queue_t default_queue;
7  unsigned flags = 0;
8  ndrange_t ndrange;
9  clk_event_t evt;
10  clk_event_t event_wait_list;
11  clk_event_t event_wait_list2[] = {evt, evt};
12  void *vptr;
13
14  // Testing the first overload type
15  enqueue_kernel(default_queue, flags, ndrange, ^(void) {
16    return 0;
17  });
18
19  enqueue_kernel(vptr, flags, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'queue_t' argument type}}
20    return 0;
21  });
22
23  enqueue_kernel(default_queue, vptr, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'kernel_enqueue_flags_t' (i.e. uint) argument type}}
24    return 0;
25  });
26
27  enqueue_kernel(default_queue, flags, vptr, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'ndrange_t' argument type}}
28    return 0;
29  });
30
31  enqueue_kernel(default_queue, flags, ndrange, vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}}
32
33  enqueue_kernel(default_queue, flags, ndrange, ^(int i) { // expected-error{{blocks in this form of device side enqueue call are expected to have have no parameters}}
34    return 0;
35  });
36
37  // Testing the second overload type
38  enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, ^(void) {
39    return 0;
40  });
41
42  enqueue_kernel(default_queue, flags, ndrange, 1, vptr, &evt, ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}}
43                                                               {
44                                                                 return 0;
45                                                               });
46
47  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}}
48                                                                           {
49                                                                             return 0;
50                                                                           });
51
52  enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}}
53
54  // Testing the third overload type
55  enqueue_kernel(default_queue, flags, ndrange,
56                 ^(local void *a, local void *b) {
57                   return 0;
58                 },
59                 1024, 1024);
60
61  enqueue_kernel(default_queue, flags, ndrange,
62                 ^(local void *a, local void *b) {
63                   return 0;
64                 },
65                 1024, 1024L); // expected-error{{local memory sizes need to be specified as uint}}
66
67  char c;
68  enqueue_kernel(default_queue, flags, ndrange,
69                 ^(local void *a, local void *b) {
70                   return 0;
71                 },
72                 c, 1024);
73#ifdef WCONV
74// expected-warning@-2{{implicit conversion changes signedness: 'char' to 'unsigned int'}}
75#endif
76
77  typedef void (^bl_A_t)(local void *);
78
79  const bl_A_t block_A = (bl_A_t) ^ (local void *a) {};
80
81  enqueue_kernel(default_queue, flags, ndrange, block_A, 1024);
82
83  typedef void (^bl_B_t)(local void *, local int *);
84
85  const bl_B_t block_B = (bl_B_t) ^ (local void *a, local int *b) {};
86
87  enqueue_kernel(default_queue, flags, ndrange, block_B, 1024, 1024); // expected-error{{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
88
89  enqueue_kernel(default_queue, flags, ndrange, // expected-error{{mismatch in number of block parameters and local size arguments passed}}
90                 ^(local void *a, local void *b) {
91                   return 0;
92                 },
93                 1024);
94
95  float illegal_mem_size = (float)0.5f;
96  enqueue_kernel(default_queue, flags, ndrange,
97                 ^(local void *a, local void *b) {
98                   return 0;
99                 },
100                 illegal_mem_size, illegal_mem_size); // expected-error{{local memory sizes need to be specified as uint}} expected-error{{local memory sizes need to be specified as uint}}
101#ifdef WCONV
102// expected-warning@-2{{implicit conversion turns floating-point number into integer: 'float' to 'unsigned int'}} expected-warning@-2{{implicit conversion turns floating-point number into integer: 'float' to 'unsigned int'}}
103#endif
104
105  // Testing the forth overload type
106  enqueue_kernel(default_queue, flags, ndrange, 1, event_wait_list2, &evt,
107                 ^(local void *a, local void *b) {
108                   return 0;
109                 },
110                 1024, 1024);
111
112  enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, // expected-error{{mismatch in number of block parameters and local size arguments passed}}
113                 ^(local void *a, local void *b) {
114                   return 0;
115                 },
116                 1024, 1024, 1024);
117
118  // More random misc cases that can't be deduced
119  enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
120
121  enqueue_kernel(default_queue, flags, ndrange, 1, 1); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
122}
123
124// Diagnostic tests for get_kernel_work_group_size and allowed block parameter types in dynamic parallelism.
125kernel void work_group_size_tests() {
126  void (^const block_A)(void) = ^{
127    return;
128  };
129  void (^const block_B)(int) = ^(int a) {
130    return;
131  };
132  void (^const block_C)(local void *) = ^(local void *a) {
133    return;
134  };
135  void (^const block_D)(local int *) = ^(local int *a) {
136    return;
137  };
138
139  unsigned size = get_kernel_work_group_size(block_A);
140  size = get_kernel_work_group_size(block_C);
141  size = get_kernel_work_group_size(^(local void *a) {
142    return;
143  });
144  size = get_kernel_work_group_size(^(local int *a) { // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
145    return;
146  });
147  size = get_kernel_work_group_size(block_B);   // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
148  size = get_kernel_work_group_size(block_D);   // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
149  size = get_kernel_work_group_size(^(int a) {  // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
150    return;
151  });
152  size = get_kernel_work_group_size();          // expected-error {{too few arguments to function call, expected 1, have 0}}
153  size = get_kernel_work_group_size(1);         // expected-error{{expected block argument}}
154  size = get_kernel_work_group_size(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
155
156  size = get_kernel_preferred_work_group_size_multiple(block_A);
157  size = get_kernel_preferred_work_group_size_multiple(block_C);
158  size = get_kernel_preferred_work_group_size_multiple(^(local void *a) {
159    return;
160  });
161  size = get_kernel_preferred_work_group_size_multiple(^(local int *a) { // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
162    return;
163  });
164  size = get_kernel_preferred_work_group_size_multiple(^(int a) {  // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
165    return;
166  });
167  size = get_kernel_preferred_work_group_size_multiple(block_B);   // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
168  size = get_kernel_preferred_work_group_size_multiple(block_D);   // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
169  size = get_kernel_preferred_work_group_size_multiple();          // expected-error {{too few arguments to function call, expected 1, have 0}}
170  size = get_kernel_preferred_work_group_size_multiple(1);         // expected-error{{expected block argument}}
171  size = get_kernel_preferred_work_group_size_multiple(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
172}
173