Automate detection of homogeneous parameters #646
Draft
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.
One of the really awkward things with the initial implementation of merging groups was that we had to add a manual mechanism for detecting whether parameters (and derived parameters) were heterogeneous across the merged group or not and handle them separately. With the improved type information present in GeNN 5, it was always on my todo list to simplify and automate it so it could be applied to 'internal' parameters like number of neurons etc.
In
EnvironmentGroupMergedField::addField
, we now just check that the type is const, numeric and the values match (this is the key thing as, in GeNN 4, all fields basically were just strings) and if their value is the same for all groups that are being merged together, we just substitute a constant. This means for models which don't really benefit from merging i.e. ones with a small number of populations, the code will be as efficient as it was before merging was added and this removes a load of ugly boilerplate.For example, after this change, generated code for a merged neuron update group with one 256 neuron group in looks like:
rather than: