Skip to content

[SYCL][ROCm] Fix context destruction on AMD #4104

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

Merged
merged 1 commit into from
Jul 15, 2021
Merged
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
7 changes: 5 additions & 2 deletions sycl/plugins/rocm/pi_rocm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,17 +1696,20 @@ pi_result rocm_piContextRelease(pi_context ctxt) {

if (!ctxt->is_primary()) {
hipCtx_t hipCtxt = ctxt->get();
// hipCtxSynchronize is not supported for AMD platform so we can just
// destroy the context, for NVIDIA make sure it's synchronized.
#if defined(__HIP_PLATFORM_NVIDIA__)
hipCtx_t current = nullptr;
PI_CHECK_ERROR(hipCtxGetCurrent(&current));
if (hipCtxt != current) {
PI_CHECK_ERROR(hipCtxPushCurrent(hipCtxt));
}
// hipErrorNotSupported this API
// PI_CHECK_ERROR(hipCtxSynchronize());
PI_CHECK_ERROR(hipCtxSynchronize());
PI_CHECK_ERROR(hipCtxGetCurrent(&current));
if (hipCtxt == current) {
PI_CHECK_ERROR(hipCtxPopCurrent(&current));
}
#endif
return PI_CHECK_ERROR(hipCtxDestroy(hipCtxt));
} else {
// Primary context is not destroyed, but released
Expand Down