@@ -213,6 +213,74 @@ get_native<backend::ext_oneapi_cuda, device>(const device &Obj) {
213
213
return static_cast <backend_return_t <backend::ext_oneapi_cuda, device>>(
214
214
Obj.getNative ());
215
215
}
216
+
217
+ template <>
218
+ __SYCL_DEPRECATED (
219
+ " Context interop is deprecated for CUDA. If a native context is required,"
220
+ " use cuDevicePrimaryCtxRetain with a native device" )
221
+ inline backend_return_t<backend::ext_oneapi_cuda, context> get_native<
222
+ backend::ext_oneapi_cuda, context>(const context &Obj) {
223
+ if (Obj.get_backend () != backend::ext_oneapi_cuda) {
224
+ throw sycl::exception (make_error_code (errc::backend_mismatch),
225
+ " Backends mismatch" );
226
+ }
227
+ return reinterpret_cast <backend_return_t <backend::ext_oneapi_cuda, context>>(
228
+ Obj.getNative ());
229
+ }
230
+
231
+ template <>
232
+ __SYCL_DEPRECATED (" Context interop is deprecated for CUDA. If a native context"
233
+ " is required, use cuDevicePrimaryCtxRetain with a native"
234
+ " device" )
235
+ inline backend_return_t<backend::ext_oneapi_cuda, context> interop_handle::
236
+ get_native_context<backend::ext_oneapi_cuda>() const {
237
+ if (get_backend () != backend::ext_oneapi_cuda) {
238
+ throw sycl::runtime_error (errc::backend_mismatch, " Backends mismatch" ,
239
+ PI_ERROR_INVALID_OPERATION);
240
+ }
241
+ #ifndef __SYCL_DEVICE_ONLY__
242
+ return reinterpret_cast <backend_return_t <backend::ext_oneapi_cuda, context>>(
243
+ getNativeContext ());
244
+ #else
245
+ return 0 ;
246
+ #endif
247
+ }
248
+
249
+ #endif
250
+ #if SYCL_EXT_ONEAPI_BACKEND_HIP
251
+
252
+ template <>
253
+ __SYCL_DEPRECATED (
254
+ " Context interop is deprecated for HIP. If a native context is required,"
255
+ " use hipDevicePrimaryCtxRetain with a native device" )
256
+ inline backend_return_t<backend::ext_oneapi_hip, context> get_native<
257
+ backend::ext_oneapi_hip, context>(const context &Obj) {
258
+ if (Obj.get_backend () != backend::ext_oneapi_hip) {
259
+ throw sycl::exception (make_error_code (errc::backend_mismatch),
260
+ " Backends mismatch" );
261
+ }
262
+ return reinterpret_cast <backend_return_t <backend::ext_oneapi_hip, context>>(
263
+ Obj.getNative ());
264
+ }
265
+
266
+ template <>
267
+ __SYCL_DEPRECATED (" Context interop is deprecated for HIP. If a native context"
268
+ " is required, use hipDevicePrimaryCtxRetain with a native"
269
+ " device" )
270
+ inline backend_return_t<backend::ext_oneapi_hip, context> interop_handle::
271
+ get_native_context<backend::ext_oneapi_hip>() const {
272
+ if (get_backend () != backend::ext_oneapi_hip) {
273
+ throw sycl::runtime_error (errc::backend_mismatch, " Backends mismatch" ,
274
+ PI_ERROR_INVALID_OPERATION);
275
+ }
276
+ #ifndef __SYCL_DEVICE_ONLY__
277
+ return reinterpret_cast <backend_return_t <backend::ext_oneapi_hip, context>>(
278
+ getNativeContext ());
279
+ #else
280
+ return 0 ;
281
+ #endif
282
+ }
283
+
216
284
#endif
217
285
218
286
template <backend BackendName, typename DataT, int Dimensions,
0 commit comments