Skip to content

Use value types to store model parameters #320

@Mikolaj-A-Kowalski

Description

@Mikolaj-A-Kowalski

This issue is to track/investigate potential improvement opportunity by allowing compiler to specialise on the values on model parameters.

At the moment, various models (e.g. SugarKelp) use a large number of parameters, which are stored as fields in an immutable struct. The performance problem of this approach is that they are not technically compile-time constants and compiler must generate code that will support multiple values. As the result, the values need to be loaded (and consume) GPU registers and expressions like exp(param_1)/param_2 runtime evaluated. If the values are instead made type parameters, compiler will be free to pre-evaluate expressions involving them and keep the constants in instruction, freeing GPU registers.

Generally julia discourages doing something like that, but in this case I think it makes sense since we expect parameters to be set only once at the start of a long simulation, hence cases where we would pay a price of extra compile time when changing the parameter values should be rare.

First thing will be to try brutally hardcoding parameters for some model to see what kind of improvement we can get. Then, if it is indeed favorable, we will need to make/find a macro that will make making structs that are a pack of Value types easy.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions