@@ -3375,24 +3375,30 @@ pi_result piQueueFinish(pi_queue Queue) {
3375
3375
return PI_SUCCESS;
3376
3376
}
3377
3377
3378
+ std::unique_lock lock (Queue->Mutex );
3378
3379
std::vector<ze_command_queue_handle_t > ZeQueues;
3379
- {
3380
- // Lock automatically releases when this goes out of scope.
3381
- std::scoped_lock lock (Queue->Mutex );
3382
3380
3383
- // execute any command list that may still be open.
3384
- if (auto Res = Queue->executeAllOpenCommandLists ())
3385
- return Res;
3381
+ // execute any command list that may still be open.
3382
+ if (auto Res = Queue->executeAllOpenCommandLists ())
3383
+ return Res;
3386
3384
3387
- // Make a copy of queues to sync and release the lock.
3388
- ZeQueues = Queue->CopyQueueGroup .ZeQueues ;
3389
- std::copy (Queue->ComputeQueueGroup .ZeQueues .begin (),
3390
- Queue->ComputeQueueGroup .ZeQueues .end (),
3391
- std::back_inserter (ZeQueues));
3392
- }
3385
+ // Make a copy of queues to sync and release the lock.
3386
+ ZeQueues = Queue->CopyQueueGroup .ZeQueues ;
3387
+ std::copy (Queue->ComputeQueueGroup .ZeQueues .begin (),
3388
+ Queue->ComputeQueueGroup .ZeQueues .end (),
3389
+ std::back_inserter (ZeQueues));
3393
3390
3394
3391
// Don't hold a lock to the queue's mutex while waiting.
3395
3392
// This allows continue working with the queue from other threads.
3393
+ // TODO: this currently exhibits some issues in the driver, so
3394
+ // we control this with an env var. Remove this control when
3395
+ // we settle one way or the other.
3396
+ static bool HoldLock =
3397
+ std::getenv (" SYCL_PI_LEVEL_ZERO_QUEUE_FINISH_HOLD_LOCK" ) != nullptr ;
3398
+ if (!HoldLock) {
3399
+ lock.unlock ();
3400
+ }
3401
+
3396
3402
for (auto ZeQueue : ZeQueues) {
3397
3403
if (ZeQueue)
3398
3404
ZE_CALL (zeHostSynchronize, (ZeQueue));
0 commit comments