Skip to content

Conversation

@heplesser
Copy link
Contributor

This PR re-organizes the way in which node and connection models are registered in modelsmodule. Up to now, compiling modelsmodule.cpp triggers a large number of template instantiations and compiling this file alone takes about 112 seconds on my MacBook Pro with Apple Clang 15. This causes a noticeable wait during compilation around 96% complete. And this happens every time you touch the h-file for a single model. Experiments indicate that of the 112s, about 90s were spent on synapse models and 11s on node models. Even with all register* calls commented out compiling the file took still about 9s—not really surprising given that modelsmodule.ii is some 166.000 lines long after all #includes have been handle (yes onehundredandsixtysixthousand).

To avoid this single stumbling block, this PR ensures that each model forces its own template instantiation. It does to by declaring (in the h-file) and defining (in the cpp-file) a function

void
register_multimeter()
{
  kernel().model_manager.register_node_model< multimeter >( "multimeter" );
}

This function is then called from multimeter.cpp. The function is not declared as a (static) method because some neuron models are templated classes themselves, so we need a method outside the class.

Since there is now a specific function to register each model, I decided to call the function register_<name> for all kind of models, with no distinction between nodes and synapses.

I had to add cpp-files for all synapses which did not yet have one to have a compilation unit in which the respective templates can be instantiated.

I auto-generated the changes with an ipython notebook (you can find it accidentally commited a few commits back), so the placement of declarations and definitions might not be perfect but was dictated by what a reasonably simple parser could achieve.

So what is the outcome?

  1. On my MacBook Pro with four cores, overall build times do not differ much (close to 5 minutes).
  2. On a dual processor EPYC Rome system with 128 cores in total, build time with make -j128 is down from about 5 minutes to about 3.5 minutes.
  3. The real gain is when you change a single model file, e.g. touch iaf_psc_alpha.h: With current master, you will wait for about 2 minutes, with the change here you will be done after less than 20 seconds.

Many files are changed here, but practically all files are changed in the same way.

I give this one high priority because it will make developers so much happier and more productive :).

@heplesser heplesser added S: High Should be handled next T: Maintenance Work to keep up the quality of the code and documentation. I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Sep 23, 2023
@heplesser heplesser requested review from jougs and pnbabu September 23, 2023 21:01
@heplesser heplesser changed the title Code re-organization for shorter build times (aka taming the 96% troll) Code re-organization for shorter build times (or taming the 96% troll) Sep 24, 2023
Copy link
Contributor

@jougs jougs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a heroic effort! 👏 🎉

I have added two inline comments that apply to all of the models changed here.

And one more thing: Could it be smart to change the function signature of register_*() to accept the name under which the model will be registered as an argument?

That way, the call to the function could decide what the name should be and the generator for the modelsmodule could be extended later on to support a modelset syntax like "iaf_psc_alpha -> standard_neuron"

@heplesser
Copy link
Contributor Author

What a heroic effort! 👏 🎉

Thanks 😊!

And one more thing: Could it be smart to change the function signature of register_*() to accept the name under which the model will be registered as an argument?

That way, the call to the function could decide what the name should be and the generator for the modelsmodule could be extended later on to support a modelset syntax like "iaf_psc_alpha -> standard_neuron"

You are right, should not be hard to fix.

@jougs
Copy link
Contributor

jougs commented Oct 24, 2023

@heplesser: can you maybe prioritize this? I'd love to have this in the module refactoring PR and time is running out...

@heplesser
Copy link
Contributor Author

@heplesser: can you maybe prioritize this? I'd love to have this in the module refactoring PR and time is running out...

On it!

@heplesser
Copy link
Contributor Author

@jougs @pnbabu I have revised the code now. Could you review again?

@heplesser heplesser requested a review from jougs October 25, 2023 14:22
@heplesser heplesser removed the request for review from pnbabu October 27, 2023 13:27
Copy link
Contributor

@jougs jougs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for addressing my concerns. I wholeheartedly approve ;-)

Copy link
Contributor

@terhorstd terhorstd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The register_* functions are an unnecessary trigger for the template instantiation which could also be achieved in a oneline declaration, but seeing the symmetry to the other "register" mechanisms could be OK here. These template considerations should go to into a different PR.
Thanks for fighting this troll! 👍

@heplesser heplesser deleted the local-instantiation branch April 24, 2024 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: High Should be handled next T: Maintenance Work to keep up the quality of the code and documentation.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants