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

Group merged refactor #475

Merged
merged 15 commits into from
Nov 10, 2021
Merged

Group merged refactor #475

merged 15 commits into from
Nov 10, 2021

Conversation

neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Nov 8, 2021

This has been annoying me for a while but I was faced with defining and passing through yet another callback and I decided to fix it. Basically, in GeNN 4 I split the generic code generation from the backend-specific code generation using a callback system like:

backend.genCustomUpdate(customUpdate, modelMerged,
        ...
        // Custom update handler
        [&modelMerged](CodeStream &os, const CustomUpdateGroupMerged &cg, Substitutions &popSubs)
        {
            genCustomUpdate(os, popSubs, cg, modelMerged, "id",
                            [&cg, &modelMerged](const Models::VarReference &varRef, const std::string &index)
                            {
                                return cg.getVarRefIndex(varRef.getDelayNeuronGroup() != nullptr,
                                                         modelMerged.getModel().getBatchSize(),
                                                         getVarAccessDuplication(varRef.getVar().access),
                                                         index);
                            });
        },
        ...

This made sense as there was no code-generation level object where this stuff could go. However, since adding support for kernel merging, the (slightly nightmarish) GroupMerged class hierarchy fits the bill exactly so all these callbacks can instead be added as methods to the appropriate GroupMerged classes. This tidies up a whole load of stuff and reduces the pain of adding new functionality:

  • There's no need to typedef a callback type for each type of merged group in BackendBase
  • The main BackendBase interface no longer needs updating and the main generating functions no longer need dozens of arguments:
virtual void genSynapseUpdate(CodeStream &os, const ModelSpecMerged &modelMerged, HostHandler preambleHandler,
                              PresynapticUpdateGroupMergedHandler wumThreshHandler, PresynapticUpdateGroupMergedHandler wumSimHandler,
                              PresynapticUpdateGroupMergedHandler wumEventHandler, PresynapticUpdateGroupMergedHandler wumProceduralConnectHandler,
                              PostsynapticUpdateGroupMergedHandler postLearnHandler, SynapseDynamicsGroupMergedHandler synapseDynamicsHandler,
                              HostHandler pushEGPHandler) const = 0;

@codecov
Copy link

codecov bot commented Nov 8, 2021

Codecov Report

Merging #475 (f12694f) into master (9d43b7c) will decrease coverage by 0.05%.
The diff coverage is 95.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #475      +/-   ##
==========================================
- Coverage   87.52%   87.46%   -0.06%     
==========================================
  Files          78       82       +4     
  Lines       17278    17266      -12     
==========================================
- Hits        15122    15102      -20     
- Misses       2156     2164       +8     
Impacted Files Coverage Δ
include/genn/backends/cuda/backend.h 96.29% <ø> (ø)
include/genn/backends/opencl/backend.h 98.86% <ø> (ø)
...nclude/genn/backends/single_threaded_cpu/backend.h 82.35% <ø> (ø)
include/genn/genn/code_generator/backendBase.h 91.52% <ø> (ø)
include/genn/genn/code_generator/backendSIMT.h 96.51% <ø> (ø)
include/genn/genn/code_generator/groupMerged.h 84.18% <ø> (-2.47%) ⬇️
include/genn/genn/code_generator/modelSpecMerged.h 97.40% <ø> (ø)
...enn/code_generator/presynapticUpdateStrategySIMT.h 100.00% <ø> (ø)
src/genn/backends/cuda/optimiser.cc 77.55% <ø> (ø)
src/genn/generator/generator.cc 90.00% <ø> (ø)
... and 19 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 9d43b7c...f12694f. Read the comment docs.

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.

Ok, I have lost track of how the code generation works after the group merging and splitting to backends etc. I have to trust you on this one.

@neworderofjamie neworderofjamie merged commit 33b81dc into master Nov 10, 2021
@neworderofjamie neworderofjamie deleted the group_merged_refactor branch November 10, 2021 11:53
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