Skip to content

Multi-threaded material budget LUT creation - #15641

Open
trwenz wants to merge 1 commit into
AliceO2Group:devfrom
trwenz:matbud-parallel
Open

Multi-threaded material budget LUT creation#15641
trwenz wants to merge 1 commit into
AliceO2Group:devfrom
trwenz:matbud-parallel

Conversation

@trwenz

@trwenz trwenz commented Jul 28, 2026

Copy link
Copy Markdown

Introduces multi-threaded creation of the material budget lookup table, reducing it from hours to minutes. Creating the LUT walks every cell of every layer through TGeo and the cells are independent, so they are spread over TBB tasks with one TGeoNavigator per thread. The innermost 20 layers at 60 trials/cell drop from 28 min to 72 s on 28 cores.

Effective only with ROOT >= v6-36-10-alice3, which removes a per-query thread-id lookup and the false sharing between per-thread scratch buffers of TGeo shapes. On older ROOT the parallel path is correct, just slower -- it saturates near 12x.

All layers map onto a single flat cell index so the load stays balanced despite very different cell counts per layer; a binary search maps a flat index back to (layer, iz, iphi). The worker navigators are given back at the end.

meanMaterialBudget() takes an optional navigator: a caller passing its own runs lock-free, a caller passing none shares gGeoManager's and still takes the mutex. Deciding from the argument keeps it local, so process-global state cannot break it.

Thread count comes from the new populateFromTGeo() argument, falling back to NTHREADS_MATBUD; the default is the previous serial path. Results are independent of the thread count -- compareMatBudLUT.C checks a parallel LUT against a serial one cell by cell, and they match exactly over all 129523 cells.

Supervised-by: Sandro Wenzel sandro.wenzel@cern.ch

Introduces multi-threaded creation of the material budget lookup table, reducing it
from hours to minutes. Creating the LUT walks every cell of every layer through TGeo
and the cells are independent, so they are spread over TBB tasks with one
TGeoNavigator per thread. The innermost 20 layers at 60 trials/cell drop from 28 min
to 72 s on 28 cores.

Effective only with ROOT >= v6-36-10-alice3, which removes a per-query thread-id
lookup and the false sharing between per-thread scratch buffers of TGeo shapes. On
older ROOT the parallel path is correct, just slower -- it saturates near 12x.

All layers map onto a single flat cell index so the load stays balanced despite very
different cell counts per layer; a binary search maps a flat index back to
(layer, iz, iphi). The worker navigators are given back at the end.

meanMaterialBudget() takes an optional navigator: a caller passing its own runs
lock-free, a caller passing none shares gGeoManager's and still takes the mutex.
Deciding from the argument keeps it local, so process-global state cannot break it.

Thread count comes from the new populateFromTGeo() argument, falling back to
NTHREADS_MATBUD; the default is the previous serial path. Results are independent of
the thread count -- compareMatBudLUT.C checks a parallel LUT against a serial one cell
by cell, and they match exactly over all 129523 cells.

Supervised-by: Sandro Wenzel <sandro.wenzel@cern.ch>
@trwenz
trwenz requested review from sawenzel and shahor02 as code owners July 28, 2026 08:58
@trwenz

trwenz commented Jul 28, 2026

Copy link
Copy Markdown
Author
matbud_scaling This plot shows the measured Speedup of the parallel implementation using the old ROOT version and the patched ROOT version.

@shahor02 shahor02 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants