Skip to content

Commit 51438d5

Browse files
JackAKirkldrummkbenzie
authored
[sycl][hip] Exception for unsupported get_native<sycl::context> (#14476)
Add exception for unsupported get_native<sycl::context> specialization for HIP backend. This was previously marked deprecated. We keep the specialization in order to give an error message to users. --------- Signed-off-by: JackAKirk <[email protected]> Co-authored-by: ldrumm <[email protected]> Co-authored-by: Kenneth Benzie (Benie) <[email protected]>
1 parent ee05fbf commit 51438d5

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

sycl/cmake/modules/FetchUnifiedRuntime.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ if(SYCL_UR_USE_FETCH_CONTENT)
117117
endfunction()
118118

119119
set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
120-
# commit 9ca3ec7a9c1d2f4a362d7e5add103b30271a8a55
121-
# Merge: 7384e2d7 59e5e405
122-
# Author: Piotr Balcer <piotr.balcer@intel.com>
123-
# Date: Mon Sep 23 10:58:51 2024 +0200
124-
# Merge pull request #2113 from oneapi-src/revert-1698-counter-based-2
125-
# Revert "[L0] Phase 2 of Counter-Based Event Implementation"
126-
set(UNIFIED_RUNTIME_TAG 9ca3ec7a9c1d2f4a362d7e5add103b30271a8a55)
120+
# commit f5c907a0f74fd6729be5c2e137144f1a43f87111
121+
# Merge: 9ca3ec7 be38e567
122+
# Author: aarongreig <aaron.greig@codeplay.com>
123+
# Date: Mon Sep 23 08:27:12 2024 -0700
124+
# Merge pull request #1830 from JackAKirk/hip-set-device
125+
# [hip] Remove deprecated hip APIs, simplify urContext
126+
set(UNIFIED_RUNTIME_TAG f5c907a0f74fd6729be5c2e137144f1a43f87111)
127127

128128
set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
129129
# Due to the use of dependentloadflag and no installer for UMF and hwloc we need

sycl/include/sycl/backend.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,16 @@ inline backend_return_t<backend::ext_oneapi_cuda, context> get_native<
237237
#if SYCL_EXT_ONEAPI_BACKEND_HIP
238238

239239
template <>
240-
__SYCL_DEPRECATED(
241-
"Context interop is deprecated for HIP. If a native context is required,"
242-
" use hipDevicePrimaryCtxRetain with a native device")
243-
inline backend_return_t<backend::ext_oneapi_hip, context> get_native<
244-
backend::ext_oneapi_hip, context>(const context &Obj) {
240+
inline backend_return_t<backend::ext_oneapi_hip, context>
241+
get_native<backend::ext_oneapi_hip, context>(const context &Obj) {
245242
if (Obj.get_backend() != backend::ext_oneapi_hip) {
246243
throw sycl::exception(make_error_code(errc::backend_mismatch),
247244
"Backends mismatch");
248245
}
249-
return reinterpret_cast<backend_return_t<backend::ext_oneapi_hip, context>>(
250-
Obj.getNative());
246+
throw sycl::exception(
247+
make_error_code(sycl::errc::feature_not_supported),
248+
"Context interop is not supported for HIP. If a native context is "
249+
"required, use hipDevicePrimaryCtxRetain with a native device");
251250
}
252251

253252
#endif // SYCL_EXT_ONEAPI_BACKEND_HIP

sycl/test-e2e/Basic/interop/interop_all_backends.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ int main() {
8282
auto Event3 = InteropQueue.memcpy(&vec[0], A, N * sizeof(int), Event2);
8383
Event3.wait();
8484

85+
if constexpr (BACKEND == backend::ext_oneapi_hip) {
86+
try {
87+
backend_traits<BACKEND>::return_type<context> NativeContext =
88+
get_native<BACKEND>(Context);
89+
} catch (sycl::exception &e) {
90+
assert(e.code() == sycl::errc::feature_not_supported);
91+
}
92+
}
93+
8594
free(A, InteropQueue);
8695

8796
for (const auto &val : vec) {

sycl/test/basic_tests/interop-hip.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: hip
2-
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s
3-
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -D__SYCL_INTERNAL_API %s
2+
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify %s
3+
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -D__SYCL_INTERNAL_API %s
44

55
// Test for HIP interop API
66

@@ -51,7 +51,7 @@ int main() {
5151
// backend-defined and specified in the backend specification.
5252

5353
hip_device = get_native<backend::ext_oneapi_hip>(Device);
54-
// 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}}
54+
// expected-no-diagnostics
5555
hip_context = get_native<backend::ext_oneapi_hip>(Context);
5656
hip_event = get_native<backend::ext_oneapi_hip>(Event);
5757
hip_queue = get_native<backend::ext_oneapi_hip>(Queue);

0 commit comments

Comments
 (0)