Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion sycl/include/sycl/backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,42 @@ get_native<backend::ext_oneapi_cuda, device>(const device &Obj) {
return static_cast<backend_return_t<backend::ext_oneapi_cuda, device>>(
Obj.getNative());
}
#endif

#ifndef SYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL
template <>
__SYCL_DEPRECATED(
"Context interop is deprecated for CUDA. If a native context is required,"
" use cuDevicePrimaryCtxRetain with a native device")
inline backend_return_t<backend::ext_oneapi_cuda, context> get_native<
backend::ext_oneapi_cuda, context>(const context &Obj) {
if (Obj.get_backend() != backend::ext_oneapi_cuda) {
throw sycl::exception(make_error_code(errc::backend_mismatch),
"Backends mismatch");
}
return reinterpret_cast<backend_return_t<backend::ext_oneapi_cuda, context>>(
Obj.getNative());
}

#endif // SYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL
#endif // SYCL_EXT_ONEAPI_BACKEND_CUDA

#if SYCL_EXT_ONEAPI_BACKEND_HIP

template <>
__SYCL_DEPRECATED(
"Context interop is deprecated for HIP. If a native context is required,"
" use hipDevicePrimaryCtxRetain with a native device")
inline backend_return_t<backend::ext_oneapi_hip, context> get_native<
backend::ext_oneapi_hip, context>(const context &Obj) {
if (Obj.get_backend() != backend::ext_oneapi_hip) {
throw sycl::exception(make_error_code(errc::backend_mismatch),
"Backends mismatch");
}
return reinterpret_cast<backend_return_t<backend::ext_oneapi_hip, context>>(
Obj.getNative());
}

#endif // SYCL_EXT_ONEAPI_BACKEND_HIP

template <backend BackendName, typename DataT, int Dimensions,
access::mode AccessMode, access::target AccessTarget,
Expand Down
5 changes: 4 additions & 1 deletion sycl/test/basic_tests/interop-cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
/// Also test the experimental CUDA interop interface
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -D__SYCL_INTERNAL_API -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s
// expected-no-diagnostics

// Test for legacy and experimental CUDA interop API

#ifdef SYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL
// expected-no-diagnostics
#include <sycl/ext/oneapi/experimental/backend/cuda.hpp>
#endif

Expand Down Expand Up @@ -59,6 +59,9 @@ int main() {
// backend-defined and specified in the backend specification.

cu_device = get_native<backend::ext_oneapi_cuda>(Device);
#ifndef SYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL
// expected-warning@+2{{'get_native<sycl::backend::ext_oneapi_cuda, sycl::context>' is deprecated: Context interop is deprecated for CUDA. If a native context is required, use cuDevicePrimaryCtxRetain with a native device}}
#endif
cu_context = get_native<backend::ext_oneapi_cuda>(Context);
cu_event = get_native<backend::ext_oneapi_cuda>(Event);
cu_queue = get_native<backend::ext_oneapi_cuda>(Queue);
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/interop-hip.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// REQUIRES: hip_be
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -D__SYCL_INTERNAL_API %s
// expected-no-diagnostics

// Test for HIP interop API

Expand Down Expand Up @@ -52,6 +51,7 @@ int main() {
// backend-defined and specified in the backend specification.

hip_device = get_native<backend::ext_oneapi_hip>(Device);
// expected-warning@+1{{'get_native<sycl::backend::ext_oneapi_hip, sycl::context>' is deprecated: Context interop is deprecated for HIP. If a native context is required, use hipDevicePrimaryCtxRetain with a native device}}
hip_context = get_native<backend::ext_oneapi_hip>(Context);
hip_event = get_native<backend::ext_oneapi_hip>(Event);
hip_queue = get_native<backend::ext_oneapi_hip>(Queue);
Expand Down