Add atomicAdd for numerators, and remove denominators from kernel - #59
Merged
Conversation
Adding atomic add in the main kernel allow to sum over the helicity, reducing the dimensionality of the numerators array. Denominators are calculated starting from numerators.
roiser
reviewed
Aug 7, 2026
roiser
left a comment
Contributor
There was a problem hiding this comment.
amazing job !! first I thought that atomic add would actually cost, but probably the reduced memory is outweighing this? please have a look also at the comment in the code diff.
roiser
approved these changes
Aug 7, 2026
theoheimel
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding atomic add in the main kernel allow to sum over the helicity, reducing the dimensionality of the numerators array.
Denominators are calculated starting from numerators.
Results
Comparison of the implementations in
feat-atomic-add(f8ce451) withmain(5f2b574).Hardware:
Standalone tests
Every figure compares the two implementations at fixed process, block count, and 256 threads per block.
We tested only the following processes, obtained in
standalonemode:g g > t t~ g gg g > t t~ g g gThe upper x-axis reports CUDA blocks.
The lower x-axis reports grid size, blocks × threads, which is the effective batch size in these tests.
Results availability
Some tests failed more on the 3g side since it is more intensive on memory.
Validation: is the matrix element the same?
Yes, we obtain matrix element values equal digit by digit
Comparison
Here we compare both the throughput of the matrix element as obtained from the
check_sa.exeexecution, and the peak memory, as obtained bynvidia-smi:check_sa.exe perf <blocks> 246 10nvidia-smi --query-gpu=memory.used --loop-ms=50 --format=csv --filename=<memory_gpu.csv>Conclusions
The addition of the atomic addition seemed to have improved both the throughput, and most importantly, the memory imprint on the GPU.
Gridpack tests
Every figure shows a gridpack run executed with MadNIS, and generating 1000000 events.
We varied the two parameters:
gpu_thread_pool_sizegpu_batch_sizeWe tested only the following processes, obtained in
standalonemode:p p > t t~ j jp p > t t~ j j jSummary and validation
Throughput gains are evaluated only where both implementations completed the same configuration.
Generation throughput is
process.count_unweighted / run_times.generate.wall_time_sec.The mean pull is
Physics validation can be also seen by this plot:
Results availability
Some tests failed because they were going out of memory.
Peak memory comparison
Runs marked with a red cross failed.
Unweighting efficiency comparison
The unweighting efficiency has been calculated by the ratio
process.count_target / process.count_after_cuts_opt.Throughput scaling
Conclusions
These changes will be merge with the branch that will be used for the tests of the paper.