Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sycl][hip] Exception for unsupported get_native<sycl::context> #14476

Merged
merged 16 commits into from
Sep 24, 2024
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
14 changes: 7 additions & 7 deletions sycl/cmake/modules/FetchUnifiedRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ if(SYCL_UR_USE_FETCH_CONTENT)
endfunction()

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

set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
# Due to the use of dependentloadflag and no installer for UMF and hwloc we need
Expand Down
13 changes: 6 additions & 7 deletions sycl/include/sycl/backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,16 @@ inline backend_return_t<backend::ext_oneapi_cuda, context> get_native<
#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) {
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());
throw sycl::exception(
make_error_code(sycl::errc::feature_not_supported),
"Context interop is not supported for HIP. If a native context is "
"required, use hipDevicePrimaryCtxRetain with a native device");
}

#endif // SYCL_EXT_ONEAPI_BACKEND_HIP
Expand Down
9 changes: 9 additions & 0 deletions sycl/test-e2e/Basic/interop/interop_all_backends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ int main() {
auto Event3 = InteropQueue.memcpy(&vec[0], A, N * sizeof(int), Event2);
Event3.wait();

if constexpr (BACKEND == backend::ext_oneapi_hip) {
try {
backend_traits<BACKEND>::return_type<context> NativeContext =
get_native<BACKEND>(Context);
} catch (sycl::exception &e) {
assert(e.code() == sycl::errc::feature_not_supported);
}
}

free(A, InteropQueue);

for (const auto &val : vec) {
Expand Down
6 changes: 3 additions & 3 deletions sycl/test/basic_tests/interop-hip.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// REQUIRES: hip
// 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
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify %s
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -D__SYCL_INTERNAL_API %s

// Test for HIP interop API

Expand Down Expand Up @@ -51,7 +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}}
// expected-no-diagnostics
hip_context = get_native<backend::ext_oneapi_hip>(Context);
uditagarwal97 marked this conversation as resolved.
Show resolved Hide resolved
hip_event = get_native<backend::ext_oneapi_hip>(Event);
hip_queue = get_native<backend::ext_oneapi_hip>(Queue);
Expand Down
Loading