| 1 | // RUN: %clang_cc1 -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=CL2.0 -o - %s | FileCheck %s |
| 2 | |
| 3 | // CHECK-DAG: %opencl.pipe_ro_t = type opaque |
| 4 | // CHECK-DAG: %opencl.pipe_wo_t = type opaque |
| 5 | // CHECK-DAG: %opencl.reserve_id_t = type opaque |
| 6 | |
| 7 | #pragma OPENCL EXTENSION cl_khr_subgroups : enable |
| 8 | |
| 9 | void test1(read_only pipe int p, global int *ptr) { |
| 10 | // CHECK: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) |
| 11 | read_pipe(p, ptr); |
| 12 | // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_ro_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) |
| 13 | reserve_id_t rid = reserve_read_pipe(p, 2); |
| 14 | // CHECK: call i32 @__read_pipe_4(%opencl.pipe_ro_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) |
| 15 | read_pipe(p, rid, 2, ptr); |
| 16 | // CHECK: call void @__commit_read_pipe(%opencl.pipe_ro_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) |
| 17 | commit_read_pipe(p, rid); |
| 18 | } |
| 19 | |
| 20 | void test2(write_only pipe int p, global int *ptr) { |
| 21 | // CHECK: call i32 @__write_pipe_2(%opencl.pipe_wo_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) |
| 22 | write_pipe(p, ptr); |
| 23 | // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_wo_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) |
| 24 | reserve_id_t rid = reserve_write_pipe(p, 2); |
| 25 | // CHECK: call i32 @__write_pipe_4(%opencl.pipe_wo_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) |
| 26 | write_pipe(p, rid, 2, ptr); |
| 27 | // CHECK: call void @__commit_write_pipe(%opencl.pipe_wo_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) |
| 28 | commit_write_pipe(p, rid); |
| 29 | } |
| 30 | |
| 31 | void test3(read_only pipe int p, global int *ptr) { |
| 32 | // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_ro_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) |
| 33 | reserve_id_t rid = work_group_reserve_read_pipe(p, 2); |
| 34 | // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_ro_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) |
| 35 | work_group_commit_read_pipe(p, rid); |
| 36 | } |
| 37 | |
| 38 | void test4(write_only pipe int p, global int *ptr) { |
| 39 | // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_wo_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) |
| 40 | reserve_id_t rid = work_group_reserve_write_pipe(p, 2); |
| 41 | // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_wo_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) |
| 42 | work_group_commit_write_pipe(p, rid); |
| 43 | } |
| 44 | |
| 45 | void test5(read_only pipe int p, global int *ptr) { |
| 46 | // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_ro_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) |
| 47 | reserve_id_t rid = sub_group_reserve_read_pipe(p, 2); |
| 48 | // CHECK: call void @__sub_group_commit_read_pipe(%opencl.pipe_ro_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) |
| 49 | sub_group_commit_read_pipe(p, rid); |
| 50 | } |
| 51 | |
| 52 | void test6(write_only pipe int p, global int *ptr) { |
| 53 | // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_write_pipe(%opencl.pipe_wo_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) |
| 54 | reserve_id_t rid = sub_group_reserve_write_pipe(p, 2); |
| 55 | // CHECK: call void @__sub_group_commit_write_pipe(%opencl.pipe_wo_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) |
| 56 | sub_group_commit_write_pipe(p, rid); |
| 57 | } |
| 58 | |
| 59 | void test7(read_only pipe int p, global int *ptr) { |
| 60 | // CHECK: call i32 @__get_pipe_num_packets_ro(%opencl.pipe_ro_t* %{{.*}}, i32 4, i32 4) |
| 61 | *ptr = get_pipe_num_packets(p); |
| 62 | // CHECK: call i32 @__get_pipe_max_packets_ro(%opencl.pipe_ro_t* %{{.*}}, i32 4, i32 4) |
| 63 | *ptr = get_pipe_max_packets(p); |
| 64 | } |
| 65 | |
| 66 | void test8(write_only pipe int p, global int *ptr) { |
| 67 | // CHECK: call i32 @__get_pipe_num_packets_wo(%opencl.pipe_wo_t* %{{.*}}, i32 4, i32 4) |
| 68 | *ptr = get_pipe_num_packets(p); |
| 69 | // CHECK: call i32 @__get_pipe_max_packets_wo(%opencl.pipe_wo_t* %{{.*}}, i32 4, i32 4) |
| 70 | *ptr = get_pipe_max_packets(p); |
| 71 | } |
| 72 | |