diff --git a/nestkernel/connection_manager.cpp b/nestkernel/connection_manager.cpp index b614e69d84..e2df068af8 100644 --- a/nestkernel/connection_manager.cpp +++ b/nestkernel/connection_manager.cpp @@ -41,8 +41,10 @@ // Includes from nestkernel: #include "clopath_archiving_node.h" #include "conn_builder.h" +#include "conn_builder_conngen.h" #include "conn_builder_factory.h" #include "connection_label.h" +#include "connection_manager_impl.h" #include "connector_base.h" #include "connector_model.h" #include "delay_checker.h" @@ -95,6 +97,20 @@ nest::ConnectionManager::initialize( const bool adjust_number_of_threads_or_rng_ { if ( not adjust_number_of_threads_or_rng_only ) { + // Add connection rules + register_conn_builder< OneToOneBuilder >( "one_to_one" ); + register_conn_builder< AllToAllBuilder >( "all_to_all" ); + register_conn_builder< FixedInDegreeBuilder >( "fixed_indegree" ); + register_conn_builder< FixedOutDegreeBuilder >( "fixed_outdegree" ); + register_conn_builder< BernoulliBuilder >( "pairwise_bernoulli" ); + register_conn_builder< PoissonBuilder >( "pairwise_poisson" ); + register_conn_builder< TripartiteBernoulliWithPoolBuilder >( "tripartite_bernoulli_with_pool" ); + register_conn_builder< SymmetricBernoulliBuilder >( "symmetric_pairwise_bernoulli" ); + register_conn_builder< FixedTotalNumberBuilder >( "fixed_total_number" ); +#ifdef HAVE_LIBNEUROSIM + register_conn_builder< ConnectionGeneratorBuilder >( "conngen" ); +#endif + keep_source_table_ = true; connections_have_changed_ = false; get_connections_has_been_called_ = false; @@ -137,7 +153,7 @@ nest::ConnectionManager::initialize( const bool adjust_number_of_threads_or_rng_ } void -nest::ConnectionManager::finalize( const bool ) +nest::ConnectionManager::finalize( const bool adjust_number_of_threads_or_rng_only ) { source_table_.finalize(); target_table_.finalize(); @@ -146,6 +162,16 @@ nest::ConnectionManager::finalize( const bool ) std::vector< std::vector< ConnectorBase* > >().swap( connections_ ); std::vector< std::vector< std::vector< size_t > > >().swap( secondary_recv_buffer_pos_ ); compressed_spike_data_.clear(); + + if ( not adjust_number_of_threads_or_rng_only ) + { + for ( auto cbf : connbuilder_factories_ ) + { + delete cbf; + } + connbuilder_factories_.clear(); + connruledict_->clear(); + } } void diff --git a/nestkernel/event_delivery_manager.cpp b/nestkernel/event_delivery_manager.cpp index 1f3b94bee4..dbb98504d5 100644 --- a/nestkernel/event_delivery_manager.cpp +++ b/nestkernel/event_delivery_manager.cpp @@ -497,7 +497,7 @@ EventDeliveryManager::collocate_spike_data_buffers_( SendBufferPosition& send_bu ++num_spikes_per_rank[ rank ]; // We do not break if condition is false, because there may be spikes that - // can be send to other ranks than the one that is full. + // can be sent to other ranks than the one that is full. if ( not send_buffer_position.is_chunk_filled( rank ) ) { send_buffer[ send_buffer_position.idx( rank ) ] = emitted_spike.spike_data; diff --git a/nestkernel/io_manager.cpp b/nestkernel/io_manager.cpp index 9f9647d48f..2d6bdf27e5 100644 --- a/nestkernel/io_manager.cpp +++ b/nestkernel/io_manager.cpp @@ -61,27 +61,83 @@ namespace nest IOManager::IOManager() : overwrite_files_( false ) { - register_recording_backend< RecordingBackendASCII >( "ascii" ); - register_recording_backend< RecordingBackendMemory >( "memory" ); - register_recording_backend< RecordingBackendScreen >( "screen" ); +} + +IOManager::~IOManager() +{ +} + +void +IOManager::initialize( const bool adjust_number_of_threads_or_rng_only ) +{ + if ( not adjust_number_of_threads_or_rng_only ) + { + // Register backends again, since finalize cleans up + // so backends from external modules are unloaded + register_recording_backend< RecordingBackendASCII >( "ascii" ); + register_recording_backend< RecordingBackendMemory >( "memory" ); + register_recording_backend< RecordingBackendScreen >( "screen" ); #ifdef HAVE_MPI - register_recording_backend< RecordingBackendMPI >( "mpi" ); - register_stimulation_backend< StimulationBackendMPI >( "mpi" ); + register_recording_backend< RecordingBackendMPI >( "mpi" ); + register_stimulation_backend< StimulationBackendMPI >( "mpi" ); #endif #ifdef HAVE_SIONLIB - register_recording_backend< RecordingBackendSIONlib >( "sionlib" ); + register_recording_backend< RecordingBackendSIONlib >( "sionlib" ); #endif + + DictionaryDatum dict( new Dictionary ); + // The properties data_path and data_prefix can be set via environment variables + char* data_path = std::getenv( "NEST_DATA_PATH" ); + if ( data_path ) + { + ( *dict )[ names::data_path ] = std::string( data_path ); + } + char* data_prefix = std::getenv( "NEST_DATA_PREFIX" ); + if ( data_prefix ) + { + ( *dict )[ names::data_prefix ] = std::string( data_prefix ); + } + + set_data_path_prefix_( dict ); + + overwrite_files_ = false; + } + + for ( const auto& it : recording_backends_ ) + { + it.second->initialize(); + } + for ( const auto& it : stimulation_backends_ ) + { + it.second->initialize(); + } } -IOManager::~IOManager() +void +IOManager::finalize( const bool adjust_number_of_threads_or_rng_only ) { - for ( auto& it : recording_backends_ ) + for ( const auto& it : recording_backends_ ) { - delete it.second; + it.second->finalize(); } - for ( auto& it : stimulation_backends_ ) + for ( const auto& it : stimulation_backends_ ) + { + it.second->finalize(); + } + + if ( not adjust_number_of_threads_or_rng_only ) { - delete it.second; + for ( const auto& it : recording_backends_ ) + { + delete it.second; + } + recording_backends_.clear(); + + for ( const auto& it : stimulation_backends_ ) + { + delete it.second; + } + stimulation_backends_.clear(); } } @@ -131,52 +187,6 @@ IOManager::set_data_path_prefix_( const DictionaryDatum& dict ) } } -void -IOManager::initialize( const bool adjust_number_of_threads_or_rng_only ) -{ - if ( not adjust_number_of_threads_or_rng_only ) - { - DictionaryDatum dict( new Dictionary ); - // The properties data_path and data_prefix can be set via environment variables - char* data_path = std::getenv( "NEST_DATA_PATH" ); - if ( data_path ) - { - ( *dict )[ names::data_path ] = std::string( data_path ); - } - char* data_prefix = std::getenv( "NEST_DATA_PREFIX" ); - if ( data_prefix ) - { - ( *dict )[ names::data_prefix ] = std::string( data_prefix ); - } - - set_data_path_prefix_( dict ); - - overwrite_files_ = false; - } - - for ( const auto& it : recording_backends_ ) - { - it.second->initialize(); - } - for ( const auto& it : stimulation_backends_ ) - { - it.second->initialize(); - } -} - -void -IOManager::finalize( const bool ) -{ - for ( const auto& it : recording_backends_ ) - { - it.second->finalize(); - } - for ( const auto& it : stimulation_backends_ ) - { - it.second->finalize(); - } -} - void IOManager::set_recording_backend_status( std::string recording_backend, const DictionaryDatum& d ) { diff --git a/nestkernel/kernel_manager.cpp b/nestkernel/kernel_manager.cpp index 63b5937ada..2e407b249a 100644 --- a/nestkernel/kernel_manager.cpp +++ b/nestkernel/kernel_manager.cpp @@ -57,9 +57,9 @@ nest::KernelManager::KernelManager() , connection_manager() , sp_manager() , event_delivery_manager() + , io_manager() , model_manager() , music_manager() - , io_manager() , node_manager() , managers( { &logging_manager, &mpi_manager, @@ -71,9 +71,9 @@ nest::KernelManager::KernelManager() &connection_manager, &sp_manager, &event_delivery_manager, + &io_manager, &model_manager, &music_manager, - &io_manager, &node_manager } ) , initialized_( false ) { diff --git a/nestkernel/kernel_manager.h b/nestkernel/kernel_manager.h index 78a31c52f3..216981b2b7 100644 --- a/nestkernel/kernel_manager.h +++ b/nestkernel/kernel_manager.h @@ -282,9 +282,9 @@ class KernelManager ConnectionManager connection_manager; SPManager sp_manager; EventDeliveryManager event_delivery_manager; + IOManager io_manager; ModelManager model_manager; MUSICManager music_manager; - IOManager io_manager; NodeManager node_manager; /**@}*/ private: diff --git a/nestkernel/nest_extension_interface.h b/nestkernel/nest_extension_interface.h index e185504bc8..ff4d519a21 100644 --- a/nestkernel/nest_extension_interface.h +++ b/nestkernel/nest_extension_interface.h @@ -38,6 +38,7 @@ #include "nest.h" #include "nest_impl.h" #include "nestmodule.h" +#include "sp_manager_impl.h" #include "target_identifier.h" // C++ includes diff --git a/nestkernel/nestmodule.cpp b/nestkernel/nestmodule.cpp index bf0675f3d2..639f886077 100644 --- a/nestkernel/nestmodule.cpp +++ b/nestkernel/nestmodule.cpp @@ -30,9 +30,7 @@ // Includes from nestkernel: #include "conn_builder.h" -#include "conn_builder_conngen.h" #include "connection_creator_impl.h" -#include "connection_manager_impl.h" #include "free_layer.h" #include "genericmodel.h" #include "grid_layer.h" @@ -48,7 +46,6 @@ #include "nest_types.h" #include "node.h" #include "parameter.h" -#include "sp_manager_impl.h" #include "spatial.h" // Includes from sli: @@ -2211,27 +2208,6 @@ NestModule::init( SLIInterpreter* i ) i->createcommand( "cvdict_M", &cvdict_Mfunction ); i->createcommand( "SelectNodesByMask_g_a_M", &selectnodesbymask_g_a_Mfunction ); - - // Add connection rules - kernel().connection_manager.register_conn_builder< OneToOneBuilder >( "one_to_one" ); - kernel().connection_manager.register_conn_builder< AllToAllBuilder >( "all_to_all" ); - kernel().connection_manager.register_conn_builder< FixedInDegreeBuilder >( "fixed_indegree" ); - kernel().connection_manager.register_conn_builder< FixedOutDegreeBuilder >( "fixed_outdegree" ); - kernel().connection_manager.register_conn_builder< BernoulliBuilder >( "pairwise_bernoulli" ); - kernel().connection_manager.register_conn_builder< PoissonBuilder >( "pairwise_poisson" ); - kernel().connection_manager.register_conn_builder< TripartiteBernoulliWithPoolBuilder >( - "tripartite_bernoulli_with_pool" ); - kernel().connection_manager.register_conn_builder< SymmetricBernoulliBuilder >( "symmetric_pairwise_bernoulli" ); - kernel().connection_manager.register_conn_builder< FixedTotalNumberBuilder >( "fixed_total_number" ); -#ifdef HAVE_LIBNEUROSIM - kernel().connection_manager.register_conn_builder< ConnectionGeneratorBuilder >( "conngen" ); -#endif - - // Add MSP growth curves - kernel().sp_manager.register_growth_curve< GrowthCurveSigmoid >( "sigmoid" ); - kernel().sp_manager.register_growth_curve< GrowthCurveGaussian >( "gaussian" ); - kernel().sp_manager.register_growth_curve< GrowthCurveLinear >( "linear" ); - Token statusd = i->baselookup( Name( "statusdict" ) ); DictionaryDatum dd = getValue< DictionaryDatum >( statusd ); dd->insert( Name( "kernelname" ), new StringDatum( "NEST" ) ); diff --git a/nestkernel/sp_manager.cpp b/nestkernel/sp_manager.cpp index 52e1f73d29..fb912b1f84 100644 --- a/nestkernel/sp_manager.cpp +++ b/nestkernel/sp_manager.cpp @@ -32,6 +32,7 @@ #include "connector_model.h" #include "kernel_manager.h" #include "nest_names.h" +#include "sp_manager_impl.h" namespace nest { @@ -53,9 +54,12 @@ SPManager::~SPManager() void SPManager::initialize( const bool adjust_number_of_threads_or_rng_only ) { - if ( adjust_number_of_threads_or_rng_only ) + if ( not adjust_number_of_threads_or_rng_only ) { - return; + // Add MSP growth curves + register_growth_curve< GrowthCurveSigmoid >( "sigmoid" ); + register_growth_curve< GrowthCurveGaussian >( "gaussian" ); + register_growth_curve< GrowthCurveLinear >( "linear" ); } structural_plasticity_update_interval_ = 10000.; @@ -63,13 +67,23 @@ SPManager::initialize( const bool adjust_number_of_threads_or_rng_only ) } void -SPManager::finalize( const bool ) +SPManager::finalize( const bool adjust_number_of_threads_or_rng_only ) { - for ( std::vector< SPBuilder* >::const_iterator i = sp_conn_builders_.begin(); i != sp_conn_builders_.end(); i++ ) + if ( not adjust_number_of_threads_or_rng_only ) { - delete *i; + for ( auto spcb : sp_conn_builders_ ) + { + delete spcb; + } + sp_conn_builders_.clear(); + + for ( auto gcf : growthcurve_factories_ ) + { + delete gcf; + } + growthcurve_factories_.clear(); + growthcurvedict_->clear(); } - sp_conn_builders_.clear(); } void