Closed Thanduriel closed 1 month ago
A greater problem is the static data at the foundation of every Module<>
.
Also check the rest of the infrastructure in core/src/include/*.hpp
for static data members.
Classes to look at:
ConfigMap
Configurator
Configured<>
ConfiguredModule
FileCallbackCloser
Iterator
MissingData
ModelComponent
ModelConfig
Module<>
ParaGridIO
ScopedTimer
Timer
Currently significant parts of the model are constructed and managed through
ConfiguredModule::configuredModules
and therefore have static lifetimes. This makes resource management via RAII challenging since the order of init/release is hard to track and destructors will only be called during the epilogue ofmain
.A concrete example for a problem this causes can be found in the GPU code. Usage of the GPU requires both manual
initialize
andfinalize
calls and the management of memory buffers. Currently the simulation will always terminate with an exception because the buffers are freed by a destructor which is only called after thefinalize
.The easiest solution would probably be to make the
ConfiguredModule
data non-static and to introduce a finalize call.