Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 3236832

Browse files
authored
[SYCL][CUDA] Add experimental cuda queue interop test (#1054)
This PR add testing of the CUDA backend experimental queue interop. It checks that valid types are returned and that the created SYCL objects can be used to do work. It additionally creates a queue from an already existing sycl queue's native handle and makes sure it and the original work. Depends on: intel/llvm#6290
1 parent d22b329 commit 3236832

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

SYCL/Plugin/interop-cuda-experimental.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,31 @@ int main() {
9595
sycl::queue new_Q(sycl_ctx, sycl::default_selector());
9696
assert(check_queue(new_Q));
9797
}
98+
99+
// Create new queue
100+
CUstream cu_queue;
101+
CUDA_CHECK(cuCtxSetCurrent(cu_ctx));
102+
CUDA_CHECK(cuStreamCreate(&cu_queue, CU_STREAM_DEFAULT));
103+
104+
auto sycl_queue =
105+
sycl::make_queue<sycl::backend::ext_oneapi_cuda>(cu_queue, sycl_ctx);
106+
native_queue = sycl::get_native<sycl::backend::ext_oneapi_cuda>(sycl_queue);
107+
108+
check_type<sycl::queue>(sycl_queue);
109+
check_type<CUstream>(native_queue);
110+
111+
// Submit some work to new queue
112+
assert(check_queue(sycl_queue));
113+
114+
// Create new queue with Q's native type and submit some work
115+
{
116+
CUstream Q_native_stream =
117+
sycl::get_native<sycl::backend::ext_oneapi_cuda>(Q);
118+
sycl::queue new_Q = sycl::make_queue<sycl::backend::ext_oneapi_cuda>(
119+
Q_native_stream, Q_sycl_ctx);
120+
assert(check_queue(new_Q));
121+
}
122+
123+
// Check Q still works
124+
assert(check_queue(Q));
98125
}

0 commit comments

Comments
 (0)