Skip to content

Commit 8dd56ad

Browse files
author
Alexander Batashev
committed
[SYCL] Join thread pool threads on Scheduler destruction
Threads from default queue thread pool can access scheduler after its destruction has begun. To avoid such illegal access, wait for all threads to join in scheduler destructor.
1 parent 645db17 commit 8dd56ad

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

sycl/source/detail/queue_impl.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ class queue_impl {
366366
return *MHostTaskThreadPool;
367367
}
368368

369+
void stopThreadPool() {
370+
if (MHostTaskThreadPool) {
371+
MHostTaskThreadPool->finishAndWait();
372+
}
373+
}
374+
369375
/// Gets the native handle of the SYCL queue.
370376
///
371377
/// \return a native handle.

sycl/source/detail/scheduler/scheduler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ Scheduler::Scheduler() {
306306
}
307307

308308
Scheduler::~Scheduler() {
309+
DefaultHostQueue->stopThreadPool();
309310
// By specification there are several possible sync points: buffer
310311
// destruction, wait() method of a queue or event. Stream doesn't introduce
311312
// any synchronization point. It is guaranteed that stream is flushed and

0 commit comments

Comments
 (0)