Skip to content

ensure thread termination tools only run in initialized threads

Charles Leggett requested to merge leggett/Gaudi:dev/checkThreadInit into master

no matter how many threads you configure a tbb thread pool to have, it seems that tbb will create NCORES-1 threads, where NCORES is the number of available cores on the system. (You can artificially limit this by using taskset -c.) Of these threads, tbb will only activate the number you have requested for the thread pool at any one time. This means that jobs that have thread local initialization need to proceed carefully. We check for thread initialization via the thread local variable Gaudi::Concurrency::ThreadInitDone which is set during the thread init at the start of the job and as well the first time AlgoExecutionTask::execute() is called for a newly activated thread. However, sometimes one of the tbb threads is activated after the last event has been processed, meaning that the Gaudi::Concurrency::ThreadInitDone is false. This means that IThreadInitTool::terminateThread() of the ThreadInitTools should NOT be called, as the initialization method has not been called (and it's a waste of resources to call it just to terminate it immediately afterwards).

This MR also removes the forced thread initialization during ThreadPoolSvc::initialize, and lets it happen on demand when the AlgoExecutionTask sees a new thread.

Also uses the new tbb::global_control class to limit concurrency (which seems to work better in recent versions of TBB than task_scheduler_init)

Edited by Charles Leggett

Merge request reports