Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace synRemap mechanism with much simpler one #511

Merged
merged 2 commits into from
Apr 27, 2022

Conversation

neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Apr 14, 2022

In older versions of GeNN which used a plain CSR matrix format for sparse connectivity, figuring out what presynaptic and postsynaptic neuron a synapse dynamics kernel thread was associated with, required a data structure called indInG. When we switched to the new 'ragged' format, this was no longer necessary but, for some reason, I introduced a new (synRemap) lookup structure which maps contiguous (0, numSynapses] thread indices to indices into the ragged matrix. This adds another 32-bits of memory per sparse synapse, significantly slows down synapse dynamics as each synapse has to read the 32-bit from global memory and makes doing structural plasticity much harder than it needs to be as you need to keep the synRemap structure up to date with all the other bits of synapse state. Theoretically this could have saved a few idle threads but, it doesn't because GeNN has no way of knowing how many synapses there are at compile time so it launches sg.getSrcNeuronGroup()->getNumNeurons() * sg.getMaxConnections() anyway. The synRemap structure is an internal detail which users shouldn't ever be messing with so I have totally removed it and, in this PR, just divide the same number of threads into pre and post indices with / and % respectively (duh). On my machine this reduces the time spent in synapse dynamics kernels by around 25%!

@codecov
Copy link

codecov bot commented Apr 14, 2022

Codecov Report

Merging #511 (f3c1a0f) into custom_update_batching_reduce_strict (5fd492d) will decrease coverage by 0.22%.
The diff coverage is 100.00%.

@@                           Coverage Diff                            @@
##           custom_update_batching_reduce_strict     #511      +/-   ##
========================================================================
- Coverage                                 87.04%   86.81%   -0.23%     
========================================================================
  Files                                        84       84              
  Lines                                     18120    18063      -57     
========================================================================
- Hits                                      15773    15682      -91     
- Misses                                     2347     2381      +34     
Impacted Files Coverage Δ
...nclude/genn/backends/single_threaded_cpu/backend.h 81.81% <ø> (-0.54%) ⬇️
include/genn/genn/code_generator/backendBase.h 89.83% <ø> (ø)
include/genn/genn/code_generator/backendSIMT.h 96.51% <ø> (ø)
src/genn/genn/code_generator/generateRunner.cc 95.99% <ø> (-0.02%) ⬇️
src/genn/genn/code_generator/groupMerged.cc 88.77% <ø> (-0.06%) ⬇️
src/genn/genn/code_generator/modelSpecMerged.cc 95.51% <ø> (-0.02%) ⬇️
src/genn/genn/code_generator/backendSIMT.cc 94.51% <100.00%> (-1.55%) ⬇️
...enn/genn/code_generator/customUpdateGroupMerged.cc 94.73% <100.00%> (-0.17%) ⬇️
src/genn/genn/code_generator/codeGenUtils.cc 87.26% <0.00%> (-2.49%) ⬇️
src/genn/genn/code_generator/backendBase.cc 92.07% <0.00%> (-2.44%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5fd492d...f3c1a0f. Read the comment docs.

@neworderofjamie neworderofjamie marked this pull request as ready for review April 14, 2022 17:33
Copy link
Member

@tnowotny tnowotny left a comment

Choose a reason for hiding this comment

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

Ha ... interesting one. I guess the key is that the launched kernel grid is indeed full size (so to speak) so all the wizardry of remap completely unnecessary ...
Nice simplification.

Base automatically changed from custom_update_batching_reduce_strict to master April 27, 2022 17:18
@neworderofjamie neworderofjamie merged commit d941d60 into master Apr 27, 2022
@neworderofjamie neworderofjamie deleted the new_sparse_synapse_dynamics branch April 27, 2022 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants