Skip to content

Commit

Permalink
Consistently name adjust_number_of..._only parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
heplesser committed Mar 13, 2024
1 parent 4b380aa commit e17951e
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 40 deletions.
4 changes: 2 additions & 2 deletions nestkernel/connection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ nest::ConnectionManager::~ConnectionManager()
}

void
nest::ConnectionManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
nest::ConnectionManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( not adjust_number_of_threads_or_rng_seed_only )
if ( not adjust_number_of_threads_or_rng_only )
{
keep_source_table_ = true;
connections_have_changed_ = false;
Expand Down
4 changes: 2 additions & 2 deletions nestkernel/event_delivery_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ EventDeliveryManager::~EventDeliveryManager()
}

void
EventDeliveryManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
EventDeliveryManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( not adjust_number_of_threads_or_rng_seed_only )
if ( not adjust_number_of_threads_or_rng_only )
{
init_moduli();
reset_timers_for_preparation();
Expand Down
4 changes: 2 additions & 2 deletions nestkernel/io_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ IOManager::set_data_path_prefix_( const DictionaryDatum& dict )
}

void
IOManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
IOManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( not adjust_number_of_threads_or_rng_seed_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
Expand Down
8 changes: 4 additions & 4 deletions nestkernel/kernel_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ nest::KernelManager::initialize()
{
for ( auto& manager : managers )
{
manager->initialize( /* adjust_number_of_threads_only */ false );
manager->initialize( /* adjust_number_of_threads_or_rng_only */ false );
}

++fingerprint_;
Expand Down Expand Up @@ -122,7 +122,7 @@ nest::KernelManager::finalize()

for ( auto&& m_it = managers.rbegin(); m_it != managers.rend(); ++m_it )
{
( *m_it )->finalize( /* adjust_number_of_threads_only */ false );
( *m_it )->finalize( /* adjust_number_of_threads_or_rng_only */ false );
}
initialized_ = false;
}
Expand All @@ -147,15 +147,15 @@ nest::KernelManager::change_number_of_threads( size_t new_num_threads )
// Finalize in reverse order of initialization with old thread number set
for ( auto mgr_it = managers.rbegin(); mgr_it != managers.rend(); ++mgr_it )
{
( *mgr_it )->finalize( /* adjust_number_of_threads_or_rng_seed_only */ true );
( *mgr_it )->finalize( /* adjust_number_of_threads_or_rng_only */ true );
}

vp_manager.set_num_threads( new_num_threads );

// Initialize in original order with new number of threads set
for ( auto& manager : managers )
{
manager->initialize( /* adjust_number_of_threads_or_rng_seed_only */ true );
manager->initialize( /* adjust_number_of_threads_or_rng_only */ true );
}

// Finalizing deleted all register components. Now that all infrastructure
Expand Down
4 changes: 2 additions & 2 deletions nestkernel/logging_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ nest::LoggingManager::LoggingManager()
}

void
nest::LoggingManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
nest::LoggingManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( not adjust_number_of_threads_or_rng_seed_only )
if ( not adjust_number_of_threads_or_rng_only )
{
dict_miss_is_error_ = true;
}
Expand Down
13 changes: 7 additions & 6 deletions nestkernel/manager_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ class ManagerInterface
* is responsible for calling the initialization routines on the
* specific managers in correct order.
*
* @param adjust_number_of_threads_only Pass true if calling from kernel_manager::change_number_of_threads() to limit
* operations to those necessary for thread adjustment.
* @param adjust_number_of_threads_or_rng_only Pass true if calling from kernel_manager::change_number_of_threads()
* or RandomManager::get_status() to limit operations to those necessary for thread adjustment or switch or re-seeding
* of RNG.
*
* @see finalize()
*/
virtual void initialize( const bool adjust_number_of_threads_only ) = 0;
virtual void initialize( const bool adjust_number_of_threads_or_rng_only ) = 0;

/**
* Take down manager after operation.
Expand All @@ -88,12 +89,12 @@ class ManagerInterface
* specific managers in correct order, i.e., the opposite order of
* initialize() calls.
*
* @param adjust_number_of_threads_only Pass true if calling from kernel_manager::change_number_of_threads() to limit
* operations to those necessary for thread adjustment.
* @param adjust_number_of_threads_or_rng_only Pass true if calling from kernel_manager::change_number_of_threads()
* to limit operations to those necessary for thread adjustment.
*
* @see initialize()
*/
virtual void finalize( const bool adjust_number_of_threads_only ) = 0;
virtual void finalize( const bool adjust_number_of_threads_or_rng_only ) = 0;

/**
* Set the status of the manager
Expand Down
6 changes: 3 additions & 3 deletions nestkernel/module_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ModuleManager::ModuleManager()

ModuleManager::~ModuleManager()
{
finalize( /* adjust_number_of_threads_or_rng_seed_only */ false ); // closes dynamically loaded modules
finalize( /* adjust_number_of_threads_or_rng_only */ false ); // closes dynamically loaded modules
lt_dlexit();
}

Expand All @@ -71,9 +71,9 @@ ModuleManager::initialize( const bool )
}

void
ModuleManager::finalize( const bool adjust_number_of_threads_or_rng_seed_only )
ModuleManager::finalize( const bool adjust_number_of_threads_or_rng_only )
{
if ( adjust_number_of_threads_or_rng_seed_only )
if ( adjust_number_of_threads_or_rng_only )
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion nestkernel/module_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ModuleManager : public ManagerInterface
void initialize( const bool ) override;

//! Unload modules but only on full ResetKernel(), not when just changing then number of threads
void finalize( const bool adjust_number_of_threads_only ) override;
void finalize( const bool adjust_number_of_threads_or_rng_only ) override;

//! To be called after change of number of threads to re-register components provided by modules
void reinitialize_dynamic_modules();
Expand Down
4 changes: 2 additions & 2 deletions nestkernel/mpi_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ nest::MPIManager::init_mpi( int* argc, char** argv[] )
#endif /* #ifdef HAVE_MPI */

void
nest::MPIManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
nest::MPIManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( adjust_number_of_threads_or_rng_seed_only )
if ( adjust_number_of_threads_or_rng_only )
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions nestkernel/music_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ MUSICManager::MUSICManager()
}

void
MUSICManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
MUSICManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( adjust_number_of_threads_or_rng_seed_only )
if ( adjust_number_of_threads_or_rng_only )
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions nestkernel/node_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ NodeManager::~NodeManager()
}

void
NodeManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
NodeManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
// explicitly force construction of wfr_nodes_vec_ to ensure consistent state
wfr_network_size_ = 0;
local_nodes_.resize( kernel().vp_manager.get_num_threads() );
num_thread_local_devices_.resize( kernel().vp_manager.get_num_threads(), 0 );
ensure_valid_thread_local_ids();

if ( not adjust_number_of_threads_or_rng_seed_only )
if ( not adjust_number_of_threads_or_rng_only )
{
sw_construction_create_.reset();
}
Expand Down
12 changes: 6 additions & 6 deletions nestkernel/random_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ nest::RandomManager::~RandomManager()
}

void
nest::RandomManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
nest::RandomManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( not adjust_number_of_threads_or_rng_seed_only )
if ( not adjust_number_of_threads_or_rng_only )
{
register_rng_type< std::mt19937 >( "mt19937" );
register_rng_type< std::mt19937_64 >( "mt19937_64" );
Expand Down Expand Up @@ -97,7 +97,7 @@ nest::RandomManager::initialize( const bool adjust_number_of_threads_or_rng_seed
}

void
nest::RandomManager::finalize( const bool adjust_number_of_threads_or_rng_seed_only )
nest::RandomManager::finalize( const bool adjust_number_of_threads_or_rng_only )
{
// Delete existing RNGs
auto delete_rngs = []( std::vector< RngPtr >& rng_vec )
Expand All @@ -114,7 +114,7 @@ nest::RandomManager::finalize( const bool adjust_number_of_threads_or_rng_seed_o
vp_synced_rngs_.clear();
vp_specific_rngs_.clear();

if ( not adjust_number_of_threads_or_rng_seed_only )
if ( not adjust_number_of_threads_or_rng_only )
{
for ( auto& it : rng_types_ )
{
Expand Down Expand Up @@ -171,8 +171,8 @@ nest::RandomManager::set_status( const DictionaryDatum& d )

if ( rng_seed_updated or rng_type_updated )
{
finalize( /* adjust_number_of_threads_only */ true );
initialize( /* adjust_number_of_threads_only */ true );
finalize( /* adjust_number_of_threads_or_rng_only */ true );
initialize( /* adjust_number_of_threads_or_rng_only */ true );
}
}

Expand Down
4 changes: 2 additions & 2 deletions nestkernel/simulation_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ nest::SimulationManager::SimulationManager()
}

void
nest::SimulationManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
nest::SimulationManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( adjust_number_of_threads_or_rng_seed_only )
if ( adjust_number_of_threads_or_rng_only )
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions nestkernel/sp_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ SPManager::~SPManager()
}

void
SPManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
SPManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( adjust_number_of_threads_or_rng_seed_only )
if ( adjust_number_of_threads_or_rng_only )
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions nestkernel/vp_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ nest::VPManager::VPManager()
}

void
nest::VPManager::initialize( const bool adjust_number_of_threads_or_rng_seed_only )
nest::VPManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( adjust_number_of_threads_or_rng_seed_only )
if ( adjust_number_of_threads_or_rng_only )
{
return;
}
Expand Down

0 comments on commit e17951e

Please sign in to comment.