Skip to content

Commit bc9abb4

Browse files
committed
[SYCL] Test SPIR-V builtins address space type
1 parent 20e2cba commit bc9abb4

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clang_cc1 %s -x cl -fdeclare-spirv-builtins -fsyntax-only -emit-llvm -o - -O0 | FileCheck %s
2+
//
3+
// Check that SPIR-V builtins are declared with OpenCL address spaces rather
4+
// than SYCL address spaces when using them with OpenCL. OpenCL address spaces
5+
// are mangled with the CL prefix and SYCL address spaces are mangled with the
6+
// SY prefix.
7+
8+
// CHECK: __spirv_ocl_modffPU8CLglobal
9+
void modf_global(float a, global float *ptr) { __spirv_ocl_modf(a, ptr); }
10+
11+
// CHECK: __spirv_ocl_modffPU7CLlocal
12+
void modf_local(float a, local float *ptr) { __spirv_ocl_modf(a, ptr); }
13+
14+
// CHECK: __spirv_ocl_modffPU9CLprivate
15+
void modf_private(float a) {
16+
float *ptr;
17+
__spirv_ocl_modf(a, ptr);
18+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %clang_cc1 %s -fsycl-is-device -fdeclare-spirv-builtins -fsyntax-only -emit-llvm -o - -O0 | FileCheck %s
2+
//
3+
// Check that SPIR-V builtins are declared with SYCL address spaces rather
4+
// than OpenCL address spaces when using them with SYCL. OpenCL address spaces
5+
// are mangled with the CL prefix and SYCL address spaces are mangled with the
6+
// SY prefix.
7+
//
8+
// The opencl_global, opencl_local, and opencl_private attributes get turned
9+
// into sycl_global, sycl_local and sycl_private address spaces by clang.
10+
11+
#include "Inputs/sycl.hpp"
12+
13+
// CHECK: __spirv_ocl_modffPU8SYglobal
14+
void modf_global(float a) {
15+
__attribute__((opencl_global)) float *ptr = nullptr;
16+
sycl::kernel_single_task<class fake_kernel>([=]() { __spirv_ocl_modf(a, ptr); });
17+
}
18+
19+
// CHECK: __spirv_ocl_modffPU7SYlocal
20+
void modf_local(float a) {
21+
__attribute__((opencl_local)) float *ptr = nullptr;
22+
sycl::kernel_single_task<class fake_kernel>([=]() { __spirv_ocl_modf(a, ptr); });
23+
}
24+
25+
// CHECK: __spirv_ocl_modffPU9SYprivate
26+
void modf_private(float a) {
27+
__attribute__((opencl_private)) float *ptr = nullptr;
28+
sycl::kernel_single_task<class fake_kernel>([=]() { __spirv_ocl_modf(a, ptr); });
29+
}

0 commit comments

Comments
 (0)