celeritas-project / celeritas

Celeritas is a new Monte Carlo transport code designed to accelerate scientific discovery in high energy physics by improving detector simulation throughput and energy efficiency using GPUs.
https://celeritas-project.github.io/celeritas/user/index.html
Other
58 stars 32 forks source link

Optimize track vector data layout for particle types #1312

Open sethrj opened 2 weeks ago

sethrj commented 2 weeks ago

I have another optimization idea related to sorting but maybe less intrusive, along the lines of how AdePT has separate state vectors for each particle type. To do something similar, what about we instantiate charged and neutral particles at opposite ends of the state vector? This will naturally partition them to some extent (though we'd need to consider cases like annihilation and pair production, where the track slot basically changes type, and how to handle when the two stacks meet in the middle). We don't have to worry about "mixing" breaking anything due to how we launch kernels.

@amandalund suggested sorting the last num_vacancies track initializers by particle type before initializing which should be equivalent.

I think there has to be an additional toggle between "filling" and "filled": that suggestion would work during the "filled" stage but we'd still have to push to opposite ends of the vector while filling.

See related work from AdePT: https://cds.cern.ch/record/2856531