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 14 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
16 changes: 8 additions & 8 deletions sycl/cmake/modules/FetchUnifiedRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ if(SYCL_UR_USE_FETCH_CONTENT)
CACHE PATH "Path to external '${name}' adapter source dir" FORCE)
endfunction()

set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
# commit 897bcfb10a7e13b8e413278550e845322f6bd560 (HEAD, origin/main, origin/HEAD)
# Merge: 18514924 71cdf253
# Author: Omar Ahmed <omar.ahmed@codeplay.com>
# Date: Thu Sep 19 14:35:55 2024 +0100
# Merge pull request #2022 from nrspruit/add_3_channel_image_support
# [L0] Add 3-channel image support
set(UNIFIED_RUNTIME_TAG 897bcfb10a7e13b8e413278550e845322f6bd560)
set(UNIFIED_RUNTIME_REPO "https://github.com/JackAKirk/unified-runtime.git")
# commit 4d19115165b5497b647ae1b2e110488f84d1806a
# Merge: fb6df497 3f128d09
# Author: Piotr Balcer <piotr.balcer@intel.com>
# Date: Tue Sep 17 10:31:44 2024 +0200
# Merge pull request #2087 from nrspruit/fix_driver_inorder_event_wait
# [L0] Fix urEnqueueEventsWaitWithBarrier for driver in order lists
set(UNIFIED_RUNTIME_TAG 0ac56783090f481081edea84bacc236092a0f695)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oneapi-src/unified-runtime#1830 has been merged, please update

Copy link
Contributor Author

@JackAKirk JackAKirk Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.


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