1
1
// REQUIRES: opencl
2
2
3
+ // RUN: %clangxx -fsycl -DSYCL2020_CONFORMANT_APIS -fsycl-targets=%sycl_triple %s -o %t.out
4
+ // RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
5
+ // RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
6
+ // RUN: env SYCL_DEVICE_FILTER=opencl %ACC_RUN_PLACEHOLDER %t.out
3
7
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
4
8
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
5
9
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
@@ -25,23 +29,50 @@ int main() {
25
29
auto Device = Queue.get_info <info::queue::device>();
26
30
auto Platform = Device.get_info <info::device::platform>();
27
31
32
+ int Data[1 ] = {0 };
33
+ sycl::buffer<int , 1 > Buffer (&Data[0 ], sycl::range<1 >(1 ));
34
+ {
35
+ Queue.submit ([&](sycl::handler &cgh) {
36
+ auto Acc = Buffer.get_access <sycl::access ::mode::read_write>(cgh);
37
+ cgh.host_task ([=](const sycl::interop_handle &ih) {
38
+ (void )Acc;
39
+ auto BufNative = ih.get_native_mem <sycl::backend::opencl>(Acc);
40
+ #ifdef SYCL2020_CONFORMANT_APIS
41
+ assert (BufNative.size () == 1 );
42
+ #endif
43
+ });
44
+ });
45
+ }
46
+
28
47
// Get native OpenCL handles
29
48
auto ocl_platform = Platform.get_native <backend::opencl>();
30
49
auto ocl_device = Device.get_native <backend::opencl>();
31
50
auto ocl_context = Context.get_native <backend::opencl>();
32
51
auto ocl_queue = Queue.get_native <backend::opencl>();
52
+ auto ocl_buffers = get_native<backend::opencl>(Buffer);
53
+ #ifdef SYCL2020_CONFORMANT_APIS
54
+ assert (ocl_buffers.size () == 1 );
55
+ #endif
33
56
34
57
// Re-create SYCL objects from native OpenCL handles
35
58
auto PlatformInterop = opencl::make<platform>(ocl_platform);
36
59
auto DeviceInterop = opencl::make<device>(ocl_device);
37
60
auto ContextInterop = opencl::make<context>(ocl_context);
38
61
auto QueueInterop = opencl::make<queue>(ContextInterop, ocl_queue);
62
+ #ifdef SYCL2020_CONFORMANT_APIS
63
+ auto BufferInterop =
64
+ sycl::make_buffer<backend::opencl, int >(ocl_buffers[0 ], ContextInterop);
65
+ #else
66
+ auto BufferInterop =
67
+ sycl::make_buffer<backend::opencl, int >(ocl_buffers, ContextInterop);
68
+ #endif
39
69
40
70
// Check native handles
41
71
assert (ocl_platform == PlatformInterop.get_native <backend::opencl>());
42
72
assert (ocl_device == DeviceInterop.get_native <backend::opencl>());
43
73
assert (ocl_context == ContextInterop.get_native <backend::opencl>());
44
74
assert (ocl_queue == QueueInterop.get_native <backend::opencl>());
75
+ assert (ocl_buffers == get_native<backend::opencl>(BufferInterop));
45
76
46
77
return 0 ;
47
78
}
0 commit comments