| Anastasia Stulova | db7a31c | 2016-07-05 11:31:24 +0000 | [diff] [blame] | 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. |
| 5 | kernel 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) { |
| Anastasia Stulova | 2b46120 | 2016-11-14 15:34:01 +0000 | [diff] [blame^] | 39 | return 0; |
| 40 | }); |
| 41 | |
| 42 | enqueue_kernel(default_queue, flags, ndrange, 1, 0, 0, ^(void) { |
| 43 | return 0; |
| 44 | }); |
| Anastasia Stulova | db7a31c | 2016-07-05 11:31:24 +0000 | [diff] [blame] | 45 | |
| 46 | enqueue_kernel(default_queue, flags, ndrange, 1, vptr, &evt, ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}} |
| 47 | { |
| 48 | return 0; |
| 49 | }); |
| 50 | |
| 51 | 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}} |
| 52 | { |
| 53 | return 0; |
| 54 | }); |
| 55 | |
| 56 | enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}} |
| 57 | |
| 58 | // Testing the third overload type |
| 59 | enqueue_kernel(default_queue, flags, ndrange, |
| 60 | ^(local void *a, local void *b) { |
| 61 | return 0; |
| 62 | }, |
| 63 | 1024, 1024); |
| 64 | |
| 65 | enqueue_kernel(default_queue, flags, ndrange, |
| 66 | ^(local void *a, local void *b) { |
| 67 | return 0; |
| 68 | }, |
| 69 | 1024, 1024L); // expected-error{{local memory sizes need to be specified as uint}} |
| 70 | |
| 71 | char c; |
| 72 | enqueue_kernel(default_queue, flags, ndrange, |
| 73 | ^(local void *a, local void *b) { |
| 74 | return 0; |
| 75 | }, |
| 76 | c, 1024); |
| 77 | #ifdef WCONV |
| 78 | // expected-warning@-2{{implicit conversion changes signedness: 'char' to 'unsigned int'}} |
| 79 | #endif |
| 80 | |
| 81 | typedef void (^bl_A_t)(local void *); |
| 82 | |
| 83 | const bl_A_t block_A = (bl_A_t) ^ (local void *a) {}; |
| 84 | |
| 85 | enqueue_kernel(default_queue, flags, ndrange, block_A, 1024); |
| 86 | |
| 87 | typedef void (^bl_B_t)(local void *, local int *); |
| 88 | |
| 89 | const bl_B_t block_B = (bl_B_t) ^ (local void *a, local int *b) {}; |
| 90 | |
| 91 | 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*'}} |
| 92 | |
| 93 | enqueue_kernel(default_queue, flags, ndrange, // expected-error{{mismatch in number of block parameters and local size arguments passed}} |
| 94 | ^(local void *a, local void *b) { |
| 95 | return 0; |
| 96 | }, |
| 97 | 1024); |
| 98 | |
| 99 | float illegal_mem_size = (float)0.5f; |
| 100 | enqueue_kernel(default_queue, flags, ndrange, |
| 101 | ^(local void *a, local void *b) { |
| 102 | return 0; |
| 103 | }, |
| 104 | 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}} |
| 105 | #ifdef WCONV |
| 106 | // 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'}} |
| 107 | #endif |
| 108 | |
| 109 | // Testing the forth overload type |
| 110 | enqueue_kernel(default_queue, flags, ndrange, 1, event_wait_list2, &evt, |
| 111 | ^(local void *a, local void *b) { |
| 112 | return 0; |
| 113 | }, |
| 114 | 1024, 1024); |
| 115 | |
| Anastasia Stulova | 2b46120 | 2016-11-14 15:34:01 +0000 | [diff] [blame^] | 116 | enqueue_kernel(default_queue, flags, ndrange, 1, 0, 0, |
| 117 | ^(local void *a, local void *b) { |
| 118 | return 0; |
| 119 | }, |
| 120 | 1024, 1024); |
| 121 | |
| Anastasia Stulova | db7a31c | 2016-07-05 11:31:24 +0000 | [diff] [blame] | 122 | enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, // expected-error{{mismatch in number of block parameters and local size arguments passed}} |
| 123 | ^(local void *a, local void *b) { |
| 124 | return 0; |
| 125 | }, |
| 126 | 1024, 1024, 1024); |
| 127 | |
| 128 | // More random misc cases that can't be deduced |
| 129 | enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}} |
| 130 | |
| 131 | enqueue_kernel(default_queue, flags, ndrange, 1, 1); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}} |
| 132 | } |
| 133 | |
| 134 | // Diagnostic tests for get_kernel_work_group_size and allowed block parameter types in dynamic parallelism. |
| 135 | kernel void work_group_size_tests() { |
| 136 | void (^const block_A)(void) = ^{ |
| 137 | return; |
| 138 | }; |
| 139 | void (^const block_B)(int) = ^(int a) { |
| 140 | return; |
| 141 | }; |
| 142 | void (^const block_C)(local void *) = ^(local void *a) { |
| 143 | return; |
| 144 | }; |
| 145 | void (^const block_D)(local int *) = ^(local int *a) { |
| 146 | return; |
| 147 | }; |
| 148 | |
| 149 | unsigned size = get_kernel_work_group_size(block_A); |
| 150 | size = get_kernel_work_group_size(block_C); |
| 151 | size = get_kernel_work_group_size(^(local void *a) { |
| 152 | return; |
| 153 | }); |
| 154 | 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*'}} |
| 155 | return; |
| 156 | }); |
| 157 | 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*'}} |
| 158 | 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*'}} |
| 159 | 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*'}} |
| 160 | return; |
| 161 | }); |
| 162 | size = get_kernel_work_group_size(); // expected-error {{too few arguments to function call, expected 1, have 0}} |
| 163 | size = get_kernel_work_group_size(1); // expected-error{{expected block argument}} |
| 164 | size = get_kernel_work_group_size(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}} |
| 165 | |
| 166 | size = get_kernel_preferred_work_group_size_multiple(block_A); |
| 167 | size = get_kernel_preferred_work_group_size_multiple(block_C); |
| 168 | size = get_kernel_preferred_work_group_size_multiple(^(local void *a) { |
| 169 | return; |
| 170 | }); |
| 171 | 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*'}} |
| 172 | return; |
| 173 | }); |
| 174 | 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*'}} |
| 175 | return; |
| 176 | }); |
| 177 | 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*'}} |
| 178 | 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*'}} |
| 179 | size = get_kernel_preferred_work_group_size_multiple(); // expected-error {{too few arguments to function call, expected 1, have 0}} |
| 180 | size = get_kernel_preferred_work_group_size_multiple(1); // expected-error{{expected block argument}} |
| 181 | size = get_kernel_preferred_work_group_size_multiple(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}} |
| 182 | } |