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

Step 5 - Dynamic and typed parameters #607

Merged
merged 55 commits into from
Jan 9, 2024
Merged

Conversation

neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Nov 24, 2023

'Traditionally', in GeNN if you wanted to make parameters changable at runtime you had to change them to extra global parameters. Before GeNN 4.3.0, this used to be pretty efficient as they were all passed through to the device using kernel parameters (which are effectively implemented as a big block of constant cache). However, since adding the whole merging system way back in GeNN 4.3.0, this hasn't been possible so, for backward compatibility, they have been manually copied every timestep as there's no way to know when they change. Because they're very small and there are potentially lots of them this can be very inefficient. This functionality was totally removed in this trail of PRs but here we implement its replacement - dynamic parameters! Key things are:

  • You don't need to change your models if you want to fiddle with a parameter at runtime (only caveat is that derived parameters don't get updated)
  • You mark parameters as dynamic when you build a model with pop.set_param_dynamic("r0")
  • You update them at runtime with pop.set_dynamic_param_value("r0", current_r0)

Another issue with parameters is that they didn't previously have a type. This meant in extreme cases where you have a model with lots of heterogeneous integer parameters (so the conversion couldn't be done at compile time) e.g. a big convnet with different types of convolution implemented as Toeplitz connectivity init snippets, you could actually overload the GPU special function unit just through converting all the parameters passed as scalar to int. Also, scalar is typically a 32-bit float so cannot represent the full range of a 32-bit integer. Fixing this wasn't particularly difficult, just required passing types through from the ParamValues to the parameters. However you need to be able to specify parameters in some way and, back in #595, I added NumericValue which is now exposed to python and, in this PR, used for just this.

Fear not, there is only one step to go until we have something resembling a release candidate!

…load if there's only one visitor i.e. no overload!
…ariables require queues and of variable locations. Encapsulated variable location logic in little class and tidied various bits
* added simple DynamicParameterContainer class
…untime implementation

* Moved data structures into GeNN::Runtime::MergedDynamicFieldDestinations (as much to make it possible to forward declare as anything else)
* Made reference to runtime passed through to GroupMerged::GetFieldValueFunc non-const
* Added a third variant of GroupMerged::FieldValue which returns a value AND an associated MergedDynamicFieldDestinations
* Used to implement parameters in environment
@neworderofjamie neworderofjamie added this to the GeNN 5.0.0 milestone Nov 24, 2023
@neworderofjamie neworderofjamie changed the title Dynamic and typed parameters Step 5 -Dynamic and typed parameters Nov 24, 2023
@neworderofjamie neworderofjamie marked this pull request as ready for review December 5, 2023 13:42
@neworderofjamie neworderofjamie changed the title Step 5 -Dynamic and typed parameters Step 5 - Dynamic and typed parameters Dec 6, 2023
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.

Approving based on our general discussion of the aims and design decisions.

Base automatically changed from pre_post_var_references to genn_5 January 9, 2024 09:41
@neworderofjamie neworderofjamie merged commit a5a5cb1 into genn_5 Jan 9, 2024
@neworderofjamie neworderofjamie deleted the dynamic_parameters branch January 9, 2024 10:06
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