Skip to content

Improve model call to help the compiler #54

@VEZY

Description

@VEZY

At the moment, when we make a simulation, we traverse the (multiscale-) dependency graph of the models to run the models in the right order. This is fine, but we traverse the graph for every time-step if the models are not parallelizable over time.

This also means that the compiler cannot look into the models and optimize over them.

I don't know the best solution yet, but maybe we could use something like a macro to really "build" the model, i.e. define the calls to the functions, the outputs, etc... once in a new function, and then call this function to make a simulation. So instead of traversing a dependency graph, it would be as if it would be written by hand in a function. This way the compiler could optimize away a lot of things I think. Also we should @inline the models of course.

The benefits in summary:

  • no need to traverse the dependency graph every time-step
  • enable optimization pass by the compiler
  • avoid multiple dispatch on every call to the run! function when we call the models

We could start testing it by building a model by hand with e.g. 2-3 models in a function VS the same in a model list as usual.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestperformanceImproving simulation performance

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions