summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl110
-rw-r--r--clang/test/SemaOpenCL/cl20-device-side-enqueue.cl172
2 files changed, 282 insertions, 0 deletions
diff --git a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
new file mode 100644
index 00000000000..08b24bdc5be
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -O0 -emit-llvm -o - | FileCheck %s
+
+typedef void (^bl_t)(local void *);
+
+const bl_t block_G = (bl_t) ^ (local void *a) {};
+
+kernel void device_side_enqueue(global int *a, global int *b, int i) {
+ // CHECK: %default_queue = alloca %opencl.queue_t*
+ queue_t default_queue;
+ // CHECK: %flags = alloca i32
+ unsigned flags = 0;
+ // CHECK: %ndrange = alloca %opencl.ndrange_t*
+ ndrange_t ndrange;
+ // CHECK: %clk_event = alloca %opencl.clk_event_t*
+ clk_event_t clk_event;
+ // CHECK: %event_wait_list = alloca %opencl.clk_event_t*
+ clk_event_t event_wait_list;
+ // CHECK: %event_wait_list2 = alloca [1 x %opencl.clk_event_t*]
+ clk_event_t event_wait_list2[] = {clk_event};
+
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block to void ()*
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
+ // CHECK: call i32 @__enqueue_kernel_basic(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* [[BL_I8]])
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(void) {
+ a[i] = b[i];
+ });
+
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()*
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
+ // CHECK: call i32 @__enqueue_kernel_basic_events(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** %event_wait_list, %opencl.clk_event_t** %clk_event, i8* [[BL_I8]])
+ enqueue_kernel(default_queue, flags, ndrange, 2, &event_wait_list, &clk_event,
+ ^(void) {
+ a[i] = b[i];
+ });
+
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i8*, i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 256)
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *p) {
+ return;
+ },
+ 256);
+ char c;
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: [[SIZE:%[0-9]+]] = zext i8 {{%[0-9]+}} to i32
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i8*, i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 [[SIZE]])
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *p) {
+ return;
+ },
+ c);
+
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: [[AD:%arraydecay[0-9]*]] = getelementptr inbounds [1 x %opencl.clk_event_t*], [1 x %opencl.clk_event_t*]* %event_wait_list2, i32 0, i32 0
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i32, %opencl.clk_event_t**, %opencl.clk_event_t**, i8*, i32, ...) @__enqueue_kernel_events_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** [[AD]], %opencl.clk_event_t** %clk_event, i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 256)
+ enqueue_kernel(default_queue, flags, ndrange, 2, event_wait_list2, &clk_event,
+ ^(local void *p) {
+ return;
+ },
+ 256);
+
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: [[AD:%arraydecay[0-9]*]] = getelementptr inbounds [1 x %opencl.clk_event_t*], [1 x %opencl.clk_event_t*]* %event_wait_list2, i32 0, i32 0
+ // CHECK: [[SIZE:%[0-9]+]] = zext i8 {{%[0-9]+}} to i32
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i32, %opencl.clk_event_t**, %opencl.clk_event_t**, i8*, i32, ...) @__enqueue_kernel_events_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** [[AD]], %opencl.clk_event_t** %clk_event, i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 [[SIZE]])
+ enqueue_kernel(default_queue, flags, ndrange, 2, event_wait_list2, &clk_event,
+ ^(local void *p) {
+ return;
+ },
+ c);
+
+ void (^const block_A)(void) = ^{
+ return;
+ };
+ void (^const block_B)(local void *) = ^(local void *a) {
+ return;
+ };
+
+ // CHECK: [[BL:%[0-9]+]] = load void ()*, void ()** %block_A
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
+ // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* [[BL_I8]])
+ unsigned size = get_kernel_work_group_size(block_A);
+ // CHECK: [[BL:%[0-9]+]] = load void (i8 addrspace(2)*)*, void (i8 addrspace(2)*)** %block_B
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void (i8 addrspace(2)*)* [[BL]] to i8*
+ // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* [[BL_I8]])
+ size = get_kernel_work_group_size(block_B);
+ // CHECK: [[BL:%[0-9]+]] = load void ()*, void ()** %block_A
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
+ // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* [[BL_I8]])
+ size = get_kernel_preferred_work_group_size_multiple(block_A);
+ // CHECK: [[BL:%[0-9]+]] = load void (i8 addrspace(2)*)*, void (i8 addrspace(2)*)* addrspace(1)* @block_G
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void (i8 addrspace(2)*)* [[BL]] to i8*
+ // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* [[BL_I8]])
+ size = get_kernel_preferred_work_group_size_multiple(block_G);
+}
diff --git a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
new file mode 100644
index 00000000000..298b8109881
--- /dev/null
+++ b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -Wconversion -DWCONV
+
+// Diagnostic tests for different overloads of enqueue_kernel from Table 6.13.17.1 of OpenCL 2.0 Spec.
+kernel void enqueue_kernel_tests() {
+ queue_t default_queue;
+ unsigned flags = 0;
+ ndrange_t ndrange;
+ clk_event_t evt;
+ clk_event_t event_wait_list;
+ clk_event_t event_wait_list2[] = {evt, evt};
+ void *vptr;
+
+ // Testing the first overload type
+ enqueue_kernel(default_queue, flags, ndrange, ^(void) {
+ return 0;
+ });
+
+ enqueue_kernel(vptr, flags, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'queue_t' argument type}}
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, vptr, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'kernel_enqueue_flags_t' (i.e. uint) argument type}}
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, flags, vptr, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'ndrange_t' argument type}}
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, flags, ndrange, vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}}
+
+ 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}}
+ return 0;
+ });
+
+ // Testing the second overload type
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, ^(void) {
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, flags, ndrange, 1, vptr, &evt, ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}}
+ {
+ return 0;
+ });
+
+ 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}}
+ {
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}}
+
+ // Testing the third overload type
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 1024, 1024);
+
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 1024, 1024L); // expected-error{{local memory sizes need to be specified as uint}}
+
+ char c;
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ c, 1024);
+#ifdef WCONV
+// expected-warning@-2{{implicit conversion changes signedness: 'char' to 'unsigned int'}}
+#endif
+
+ typedef void (^bl_A_t)(local void *);
+
+ const bl_A_t block_A = (bl_A_t) ^ (local void *a) {};
+
+ enqueue_kernel(default_queue, flags, ndrange, block_A, 1024);
+
+ typedef void (^bl_B_t)(local void *, local int *);
+
+ const bl_B_t block_B = (bl_B_t) ^ (local void *a, local int *b) {};
+
+ 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*'}}
+
+ enqueue_kernel(default_queue, flags, ndrange, // expected-error{{mismatch in number of block parameters and local size arguments passed}}
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 1024);
+
+ float illegal_mem_size = (float)0.5f;
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 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}}
+#ifdef WCONV
+// 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'}}
+#endif
+
+ // Testing the forth overload type
+ enqueue_kernel(default_queue, flags, ndrange, 1, event_wait_list2, &evt,
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 1024, 1024);
+
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, // expected-error{{mismatch in number of block parameters and local size arguments passed}}
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 1024, 1024, 1024);
+
+ // More random misc cases that can't be deduced
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
+
+ enqueue_kernel(default_queue, flags, ndrange, 1, 1); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
+}
+
+// Diagnostic tests for get_kernel_work_group_size and allowed block parameter types in dynamic parallelism.
+kernel void work_group_size_tests() {
+ void (^const block_A)(void) = ^{
+ return;
+ };
+ void (^const block_B)(int) = ^(int a) {
+ return;
+ };
+ void (^const block_C)(local void *) = ^(local void *a) {
+ return;
+ };
+ void (^const block_D)(local int *) = ^(local int *a) {
+ return;
+ };
+
+ unsigned size = get_kernel_work_group_size(block_A);
+ size = get_kernel_work_group_size(block_C);
+ size = get_kernel_work_group_size(^(local void *a) {
+ return;
+ });
+ 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*'}}
+ return;
+ });
+ 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*'}}
+ 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*'}}
+ 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*'}}
+ return;
+ });
+ size = get_kernel_work_group_size(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+ size = get_kernel_work_group_size(1); // expected-error{{expected block argument}}
+ size = get_kernel_work_group_size(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
+
+ size = get_kernel_preferred_work_group_size_multiple(block_A);
+ size = get_kernel_preferred_work_group_size_multiple(block_C);
+ size = get_kernel_preferred_work_group_size_multiple(^(local void *a) {
+ return;
+ });
+ 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*'}}
+ return;
+ });
+ 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*'}}
+ return;
+ });
+ 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*'}}
+ 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*'}}
+ size = get_kernel_preferred_work_group_size_multiple(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+ size = get_kernel_preferred_work_group_size_multiple(1); // expected-error{{expected block argument}}
+ size = get_kernel_preferred_work_group_size_multiple(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
+}
OpenPOWER on IntegriCloud