Skip to content

Commit 6b55f58

Browse files
[SYCL][L0] Fix use of deleted scoped_lock copy constructor (#6304)
#6244 changed the L0 backend to use std::scoped_lock for various occasions. However, when building with MSVC some of the uses are done through copying. Since std::scoped_lock has its copy-constructor deleted this causes the build to fail. This commit changes this pattern to avoid the copy. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent f84fc32 commit 6b55f58

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7486,9 +7486,8 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context,
74867486
// indirect access. This lock also protects access to the context's data
74877487
// structures. If indirect access tracking is not enabled then lock context
74887488
// mutex to protect access to context's data structures.
7489-
auto Lock = IndirectAccessTrackingEnabled
7490-
? std::scoped_lock(Plt->ContextsMutex)
7491-
: std::scoped_lock(Context->Mutex);
7489+
std::scoped_lock Lock(IndirectAccessTrackingEnabled ? Plt->ContextsMutex
7490+
: Context->Mutex);
74927491

74937492
if (IndirectAccessTrackingEnabled) {
74947493
// We are going to defer memory release if there are kernels with indirect
@@ -7729,9 +7728,8 @@ static pi_result USMFreeHelper(pi_context Context, void *Ptr,
77297728
pi_result piextUSMFree(pi_context Context, void *Ptr) {
77307729
pi_platform Plt = Context->getPlatform();
77317730

7732-
auto Lock = IndirectAccessTrackingEnabled
7733-
? std::scoped_lock(Plt->ContextsMutex)
7734-
: std::scoped_lock(Context->Mutex);
7731+
std::scoped_lock Lock(IndirectAccessTrackingEnabled ? Plt->ContextsMutex
7732+
: Context->Mutex);
77357733

77367734
return USMFreeHelper(Context, Ptr, true /* OwnZeMemHandle */);
77377735
}
@@ -8358,9 +8356,8 @@ pi_result _pi_buffer::free() {
83588356
break;
83598357
case allocation_t::free: {
83608358
pi_platform Plt = Context->getPlatform();
8361-
auto Lock = IndirectAccessTrackingEnabled
8362-
? std::scoped_lock(Plt->ContextsMutex)
8363-
: std::scoped_lock(Context->Mutex);
8359+
std::scoped_lock Lock(IndirectAccessTrackingEnabled ? Plt->ContextsMutex
8360+
: Context->Mutex);
83648361

83658362
PI_CALL(USMFreeHelper(Context, ZeHandle, true));
83668363
break;

0 commit comments

Comments
 (0)