Skip to content

Commit c14a67b

Browse files
committed
[SYCL] remember the context to destroy
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 1ae9715 commit c14a67b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,8 @@ pi_result piContextRelease(pi_context Context) {
20462046
PI_ASSERT(Context, PI_INVALID_CONTEXT);
20472047

20482048
if (--(Context->RefCount) == 0) {
2049-
auto ZeContext = Context->ZeContext;
2049+
ze_context_handle_t DestoryZeContext =
2050+
Context->OwnZeContext ? Context->ZeContext : nullptr;
20502051

20512052
// Clean up any live memory associated with Context
20522053
pi_result Result = Context->finalize();
@@ -2060,9 +2061,8 @@ pi_result piContextRelease(pi_context Context) {
20602061
// and therefore it must be valid at that point.
20612062
// Technically it should be placed to the destructor of pi_context
20622063
// but this makes API error handling more complex.
2063-
if (Context->OwnZeContext) {
2064-
ZE_CALL(zeContextDestroy(ZeContext));
2065-
}
2064+
if (DestoryZeContext)
2065+
ZE_CALL(zeContextDestroy(DestoryZeContext));
20662066

20672067
return Result;
20682068
}

0 commit comments

Comments
 (0)