Eliminate Python overhead from synapses_create_array and synapses_create_generator templates _resize() and _update_synapse_numbers() methods #1717
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.
What was the problem?
In our larger effort to remove python indirection from cython runtime , there were some changes left for the synapses_create_array and synapses_create_generator templates.
Every time we created new synapses, the fast Cython code had to stop and call back to Python (
_owner._resize()and_owner._update_synapse_numbers()). This Python step was in charge of resizing all the synaptic arrays (like weights, delays, etc.) and updating counters likeN_incoming. This back-and-forth between Cython and Python is super slow and was a real bottleneck.What's the fix?
I've moved all that logic directly into the Cython templates, just like how standalone mode already does it.
This means when you create synapses now:
varname_ptr.resize(...)).N_incoming,N_outgoing, and totalNcounters are updated right there in Cython.synapse_number(for multisynaptic connections) is also calculated in Cython.Note : This is still WIP as I need to verify a few cases and also do the changes ofr the synapses_create_generator template