NEST main@caf0ae8
 
Loading...
Searching...
No Matches
nest::ModelManager Class Reference

#include <model_manager.h>

Inheritance diagram for nest::ModelManager:
[legend]
Collaboration diagram for nest::ModelManager:
[legend]

Public Member Functions

 ModelManager ()
 
 ~ModelManager () override
 
void initialize (const bool) override
 Prepare manager for operation.
 
void finalize (const bool) override
 Take down manager after operation.
 
void set_status (const Dictionary &) override
 Set the status of the manager.
 
void get_status (Dictionary &) override
 Retrieve the status of the manager.
 
void calibrate (const TimeConverter &)
 Resize the structures for the Connector objects if necessary.
 
Node * get_proxy_node (size_t tid, size_t node_id)
 
ConnectorModel & get_connection_model (synindex syn_id, size_t thread_id)
 Return pointer to protoype for given synapse id.
 
const std::vector< ConnectorModel * > & get_connection_models (size_t tid)
 
template<class ModelT >
size_t register_node_model (const std::string &name, std::string deprecation_info=std::string())
 Register a node-model prototype.
 
template<template< typename targetidentifierT > class ConnectionT>
void register_connection_model (const std::string &name)
 Register a synape model with a custom Connector model and without any common properties.
 
void copy_model (const std::string &old_name, const std::string &new_name, const Dictionary &params)
 Copy an existing model and register it as a new model.
 
bool set_model_defaults (const std::string &name, const Dictionary &params)
 Set the default parameters of a model.
 
size_t get_node_model_id (const std::string) const
 
Model * get_node_model (size_t) const
 
size_t get_synapse_model_id (std::string model_name)
 
Dictionary get_connector_defaults (synindex syn_id) const
 
void set_connector_defaults (synindex syn_id, const Dictionary &d)
 
void assert_valid_syn_id (synindex syn_id, size_t t) const
 Asserts validity of synapse index, otherwise throws exception.
 
bool are_model_defaults_modified () const
 
size_t get_num_connection_models () const
 
void memory_info () const
 Print out the memory information for each node model.
 
std::unique_ptr< SecondaryEvent > get_secondary_event_prototype (const synindex syn_id, const size_t tid)
 
- Public Member Functions inherited from nest::ManagerInterface
 ManagerInterface (ManagerInterface const &)=delete
 
void operator= (ManagerInterface const &)=delete
 
 ManagerInterface ()
 
virtual ~ManagerInterface ()
 
virtual void prepare ()
 
virtual void cleanup ()
 

Private Member Functions

void clear_node_models_ ()
 Delete all models and clear the modeldict.
 
void clear_connection_models_ ()
 
size_t register_node_model_ (Model *model)
 
template<typename CompleteConnecionT >
void register_specific_connection_model_ (const std::string &name)
 
void copy_node_model_ (const size_t old_id, const std::string &new_name, const Dictionary &params)
 Copy an existing node model and register it as a new model.
 
void copy_connection_model_ (const size_t old_id, const std::string &new_name, const Dictionary &params)
 Copy an existing synapse model and register it as a new model.
 
void set_node_defaults_ (size_t model_id, const Dictionary &params)
 Set the default parameters of a model.
 
void set_synapse_defaults_ (size_t model_id, const Dictionary &params)
 Set the default parameters of a model.
 
Node * create_proxynode_ (size_t t, int model_id)
 

Static Private Member Functions

static bool compare_model_by_id_ (const int a, const int b)
 Compares model ids for sorting in memory_info.
 

Private Attributes

std::vector< Model * > node_models_
 List of node models.
 
std::vector< std::vector< ConnectorModel * > > connection_models_
 The list of connection models.
 
Dictionary modeldict_
 Dictionary of all node models.
 
Dictionary synapsedict_
 Dictionary of all synapse models.
 
Model * proxynode_model_
 
std::vector< std::vector< Node * > > proxy_nodes_
 Placeholders for remote nodes, one per thread.
 
bool model_defaults_modified_
 True if any model defaults have been modified.
 

Constructor & Destructor Documentation

◆ ModelManager()

nest::ModelManager::ModelManager ( )

◆ ~ModelManager()

nest::ModelManager::~ModelManager ( )
override

References clear_connection_models_(), and clear_node_models_().

Here is the call graph for this function:

Member Function Documentation

◆ are_model_defaults_modified()

bool nest::ModelManager::are_model_defaults_modified ( ) const
inline

◆ assert_valid_syn_id()

void nest::ModelManager::assert_valid_syn_id ( synindex  syn_id,
size_t  t 
) const
inline

Asserts validity of synapse index, otherwise throws exception.

Exceptions
UnknownSynapseType

References connection_models_.

Referenced by nest::ConnectionManager::connect(), nest::ConnectionManager::connect(), get_connection_model(), get_connector_defaults(), get_secondary_event_prototype(), nest::ConnectionManager::get_synapse_status(), set_synapse_defaults_(), and nest::ConnectionManager::set_synapse_status().

Here is the caller graph for this function:

◆ calibrate()

void nest::ModelManager::calibrate ( const TimeConverter &  tc)

Resize the structures for the Connector objects if necessary.

Functor to compare Models by their name.

This function should be called after number of threads, min_delay, max_delay, and time representation have been changed in the scheduler. The TimeConverter is used to convert times from the old to the new representation. It is also forwarding the calibration request to all ConnectorModel objects.

References connection_models_, nest::kernel(), and node_models_.

Referenced by nest::SimulationManager::set_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_connection_models_()

void nest::ModelManager::clear_connection_models_ ( )
private

References Dictionary::clear(), connection_models_, nest::IS_PRIMARY, and synapsedict_.

Referenced by finalize(), and ~ModelManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_node_models_()

void nest::ModelManager::clear_node_models_ ( )
private

Delete all models and clear the modeldict.

This function deletes all models, which will as a side-effect also delete all nodes. The built-in models will be re-registered in initialize()

References Dictionary::clear(), model_defaults_modified_, modeldict_, node_models_, proxy_nodes_, and proxynode_model_.

Referenced by finalize(), and ~ModelManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare_model_by_id_()

bool nest::ModelManager::compare_model_by_id_ ( const int  a,
const int  b 
)
staticprivate

Compares model ids for sorting in memory_info.

References nest::Model::get_name(), get_node_model(), nest::kernel(), and nest::KernelManager::model_manager.

Referenced by memory_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_connection_model_()

void nest::ModelManager::copy_connection_model_ ( const size_t  old_id,
const std::string &  new_name,
const Dictionary &  params 
)
private

Copy an existing synapse model and register it as a new model.

Parameters
old_idID of existing model.
new_namename of new model.
See also
copy_model(), copy_node_model_()

References nest::VPManager::assert_single_threaded(), nest::KernelManager::connection_manager, connection_models_, nest::ERROR, get_connection_model(), nest::VPManager::get_thread_id(), nest::invalid_synindex, nest::kernel(), LOG, nest::MAX_SYN_ID, nest::ConnectionManager::resize_connections(), set_synapse_defaults_(), synapsedict_, and nest::KernelManager::vp_manager.

Referenced by copy_model().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_model()

void nest::ModelManager::copy_model ( const std::string &  old_name,
const std::string &  new_name,
const Dictionary &  params 
)

Copy an existing model and register it as a new model.

This function allows users to create their own, cloned models.

Parameters
old_namename of existing model.
new_namename of new model.
paramsdefault parameters of new model.
See also
copy_node_model_, copy_connection_model_

References copy_connection_model_(), copy_node_model_(), Dictionary::get(), Dictionary::known(), modeldict_, and synapsedict_.

Referenced by nest::copy_model().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_node_model_()

void nest::ModelManager::copy_node_model_ ( const size_t  old_id,
const std::string &  new_name,
const Dictionary &  params 
)
private

Copy an existing node model and register it as a new model.

Parameters
old_idID of existing model.
new_namename of new model.
See also
copy_model(), copy_connection_model_()

References nest::Model::clone(), create_proxynode_(), nest::Model::deprecation_warning(), get_node_model(), nest::VPManager::get_thread_id(), nest::kernel(), modeldict_, node_models_, proxy_nodes_, nest::Model::set_model_id(), set_node_defaults_(), and nest::KernelManager::vp_manager.

Referenced by copy_model().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_proxynode_()

Node * nest::ModelManager::create_proxynode_ ( size_t  t,
int  model_id 
)
private

References nest::Model::create(), proxynode_model_, and nest::Node::set_model_id().

Referenced by copy_node_model_(), and register_node_model_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalize()

void nest::ModelManager::finalize ( const bool  adjust_number_of_threads_or_rng_only)
overridevirtual

Take down manager after operation.

After this method has completed, all dynamic data structures created by the manager shall be deallocated and containers emptied. Plain variables need not be reset.

Note
Finalization of any given manager may depend on other managers not having been finalized yet. KernelManager::finalize() is responsible for calling the initialization routines on the specific managers in correct order, i.e., the opposite order of initialize() calls.
Parameters
adjust_number_of_threads_or_rng_onlyPass true if calling from kernel_manager::change_number_of_threads() to limit operations to those necessary for thread adjustment.
See also
initialize()

Implements nest::ManagerInterface.

References clear_connection_models_(), and clear_node_models_().

Here is the call graph for this function:

◆ get_connection_model()

ConnectorModel & nest::ModelManager::get_connection_model ( synindex  syn_id,
size_t  thread_id 
)
inline

Return pointer to protoype for given synapse id.

Exceptions
UnknownSynapseType
Todo:
: make the return type const, after the increment of num_connections and the min_ and max_delay setting in ConnectorBase was moved out to the ConnectionManager

References assert_valid_syn_id(), and connection_models_.

Referenced by nest::TargetTableDevices::add_connection_from_device(), nest::TargetTableDevices::add_connection_to_device(), nest::SourceTable::compute_buffer_pos_for_unique_secondary_sources(), nest::ConnectionManager::compute_compressed_secondary_recv_buffer_positions(), nest::BipartiteConnBuilder::connect(), nest::ConnectionManager::connect_(), copy_connection_model_(), nest::ConnectionManager::deliver_secondary_events(), nest::ConnectionManager::fill_target_buffer(), get_secondary_event_prototype(), nest::SPManager::get_status(), nest::ConnectionManager::get_synapse_status(), nest::BipartiteConnBuilder::set_synapse_model_(), and nest::ConnectionManager::set_synapse_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_connection_models()

const std::vector< ConnectorModel * > & nest::ModelManager::get_connection_models ( size_t  tid)
inline

References connection_models_.

Referenced by nest::EventDeliveryManager::deliver_events_(), and nest::ConnectionManager::deliver_secondary_events().

Here is the caller graph for this function:

◆ get_connector_defaults()

Dictionary nest::ModelManager::get_connector_defaults ( synindex  syn_id) const

References assert_valid_syn_id(), nest::KernelManager::connection_manager, connection_models_, nest::names::element_type(), nest::ConnectionManager::get_num_connections(), nest::kernel(), and nest::names::num_connections().

Referenced by nest::BipartiteConnBuilder::BipartiteConnBuilder(), nest::ConnectionManager::connect_arrays(), nest::ConnectionCreator::ConnectionCreator(), nest::ConnectionCreator::extract_params_(), nest::get_model_defaults(), nest::BipartiteConnBuilder::set_default_weight_or_delay_(), and nest::SPBuilder::update_delay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_node_model()

◆ get_node_model_id()

size_t nest::ModelManager::get_node_model_id ( const std::string  model_name) const
Returns
The model ID for a Model with a given name
Exceptions
UnknownModelNameif the model is not available

References Dictionary::get(), Dictionary::known(), and modeldict_.

Referenced by nest::create(), nest::AbstractLayer::create_layer(), nest::get_model_defaults(), nest::eprop_readout::handles_test_event(), and nest::eprop_readout_bsshslm_2020::handles_test_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_num_connection_models()

size_t nest::ModelManager::get_num_connection_models ( ) const

References connection_models_, and nest::kernel().

Referenced by nest::SourceTable::fill_compressed_spike_data(), nest::ConnectionManager::get_connections(), nest::ConnectionManager::initialize(), register_specific_connection_model_(), and nest::SourceTable::resize_compressible_sources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_proxy_node()

Node * nest::ModelManager::get_proxy_node ( size_t  tid,
size_t  node_id 
)
inline

References nest::ModelRangeManager::get_model_id(), nest::kernel(), nest::KernelManager::modelrange_manager, proxy_nodes_, nest::Node::set_node_id_(), and nest::Node::set_vp().

Referenced by nest::NodeManager::get_mpi_local_node_or_device_head(), nest::NodeManager::get_node_or_proxy(), and nest::NodeManager::get_node_or_proxy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_secondary_event_prototype()

std::unique_ptr< SecondaryEvent > nest::ModelManager::get_secondary_event_prototype ( const synindex  syn_id,
const size_t  tid 
)
inline

References assert_valid_syn_id(), get_connection_model(), and nest::ConnectorModel::get_secondary_event().

Referenced by nest::SourceTable::compute_buffer_pos_for_unique_secondary_sources(), and nest::ConnectionManager::deliver_secondary_events().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_status()

void nest::ModelManager::get_status ( Dictionary &  )
overridevirtual

Retrieve the status of the manager.

Note
This would ideally be a const function. However, some managers delay the update of internal variables up to the point where they are needed (e.g., before reporting their values to the user, or before simulate is called). An example for this pattern is the call to update_delay_extrema_() right at the beginning of ConnectionManager::get_status().
See also
set_status()

Implements nest::ManagerInterface.

References nest::names::max_num_syn_models(), nest::MAX_SYN_ID, modeldict_, nest::names::node_models(), nest::names::synapse_models(), and synapsedict_.

Here is the call graph for this function:

◆ get_synapse_model_id()

size_t nest::ModelManager::get_synapse_model_id ( std::string  model_name)
Returns
The numeric ID of a given synapse model
Exceptions
UnknownSynapseTypeif the model is not available

References Dictionary::get(), Dictionary::known(), and synapsedict_.

Referenced by nest::ConnectionManager::connect_arrays(), nest::ConnectionCreator::ConnectionCreator(), nest::SPManager::disconnect(), nest::ConnectionCreator::extract_params_(), nest::ConnectionManager::get_connections(), nest::get_model_defaults(), nest::GenericConnectorModel< ConnectionT >::get_status(), and nest::BipartiteConnBuilder::set_synapse_model_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize()

void nest::ModelManager::initialize ( const bool  adjust_number_of_threads_or_rng_only)
overridevirtual

Prepare manager for operation.

After this method has completed, the manager should be completely initialized and "ready for action".

Note
Initialization of any given manager may depend on other managers having been initialized before. KernelManager::initialize() is responsible for calling the initialization routines on the specific managers in correct order.
Parameters
adjust_number_of_threads_or_rng_onlyPass 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 also
finalize()

Implements nest::ManagerInterface.

References connection_models_, nest::VPManager::get_num_threads(), nest::kernel(), proxy_nodes_, proxynode_model_, nest::register_models(), nest::Model::set_threads(), nest::Model::set_type_id(), and nest::KernelManager::vp_manager.

Here is the call graph for this function:

◆ memory_info()

void nest::ModelManager::memory_info ( ) const

Print out the memory information for each node model.

References compare_model_by_id_(), nest::Model::get_name(), nest::mod(), and node_models_.

Here is the call graph for this function:

◆ register_connection_model()

template<template< typename targetidentifierT > class ConnectionT>
void nest::ModelManager::register_connection_model ( const std::string &  name)

Register a synape model with a custom Connector model and without any common properties.

"hpc synapses" use TargetIdentifierIndex for ConnectionT and store the target neuron in form of a 2 Byte index instead of an 8 Byte pointer. This limits the number of thread local neurons to 65,536. No support for different receptor types. Otherwise identical to non-hpc version.

When called, this function should be specialised by a class template, e.g. bernoulli_synapse< targetidentifierT >

Parameters
nameThe name under which the ConnectorModel will be registered.

References nest::ConnectorModel::has_property(), nest::SUPPORTS_HPC, and nest::SUPPORTS_LBL.

Referenced by nest::register_connection_model().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_node_model()

template<class ModelT >
size_t nest::ModelManager::register_node_model ( const std::string &  name,
std::string  deprecation_info = std::string() 
)

Register a node-model prototype.

This function must be called exactly once for each model class to make it known in the simulator. The natural place for a call to this function is in a *module.cpp file.

Parameters
nameof the new node model.
deprecation_infoIf non-empty string, deprecation warning will be issued for model with this info to user.
Returns
ID of the new model object.
See also
register_connection_model

References Dictionary::known(), modeldict_, and register_node_model_().

Referenced by nest::register_node_model().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_node_model_()

size_t nest::ModelManager::register_node_model_ ( Model *  model)
private

References create_proxynode_(), nest::VPManager::get_thread_id(), nest::kernel(), modeldict_, node_models_, proxy_nodes_, and nest::KernelManager::vp_manager.

Referenced by register_node_model().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_specific_connection_model_()

template<typename CompleteConnectionT >
void nest::ModelManager::register_specific_connection_model_ ( const std::string &  name)
private

◆ set_connector_defaults()

void nest::ModelManager::set_connector_defaults ( synindex  syn_id,
const Dictionary &  d 
)

◆ set_model_defaults()

bool nest::ModelManager::set_model_defaults ( const std::string &  name,
const Dictionary &  params 
)

Set the default parameters of a model.

Parameters
nameof model.
paramsdefault parameters to be set.
Returns
true if the operation succeeded, else false
See also
set_node_defaults_, set_synapse_defaults_

References Dictionary::get(), Dictionary::known(), modeldict_, set_node_defaults_(), set_synapse_defaults_(), and synapsedict_.

Here is the call graph for this function:

◆ set_node_defaults_()

void nest::ModelManager::set_node_defaults_ ( size_t  model_id,
const Dictionary &  params 
)
private

Set the default parameters of a model.

Parameters
model_idof model.
paramsdefault parameters to be set.
See also
set_model_defaults, set_synapse_defaults_

References get_node_model(), model_defaults_modified_, and nest::Model::set_status().

Referenced by copy_node_model_(), and set_model_defaults().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_status()

void nest::ModelManager::set_status ( const Dictionary &  )
overridevirtual

Set the status of the manager.

See also
get_status()

Implements nest::ManagerInterface.

◆ set_synapse_defaults_()

void nest::ModelManager::set_synapse_defaults_ ( size_t  model_id,
const Dictionary &  params 
)
private

Set the default parameters of a model.

Parameters
nameof model.
paramsdefault parameters to be set.
See also
set_model_defaults, set_node_defaults_

References assert_valid_syn_id(), connection_models_, nest::VPManager::get_thread_id(), nest::kernel(), model_defaults_modified_, and nest::KernelManager::vp_manager.

Referenced by copy_connection_model_(), and set_model_defaults().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ connection_models_

std::vector< std::vector< ConnectorModel* > > nest::ModelManager::connection_models_
private

The list of connection models.

This list contains all built-in connection models requested for compilation using -Dwith-models or -Dwith-modelset, models registered from within extension modules, and models created by calls to CopyModel().

The first dimension is thread-optimitzed by containing one vector with all models per thread, as to avoid colliding memory accesses during connection creation.

This list is cleared and built-in models are re-registered upon calls to ResetKernel, while those registered from user-modules and copies are not.

The elements of this list are used to create instances and are responsible for the storage of model defaults.

Referenced by assert_valid_syn_id(), calibrate(), clear_connection_models_(), copy_connection_model_(), get_connection_model(), get_connection_models(), get_connector_defaults(), get_num_connection_models(), initialize(), register_specific_connection_model_(), and set_synapse_defaults_().

◆ model_defaults_modified_

bool nest::ModelManager::model_defaults_modified_
private

True if any model defaults have been modified.

Referenced by are_model_defaults_modified(), clear_node_models_(), set_node_defaults_(), and set_synapse_defaults_().

◆ modeldict_

◆ node_models_

std::vector< Model* > nest::ModelManager::node_models_
private

List of node models.

The list contains all built-in node models requested for compilation using -Dwith-models or -Dwith-modelset, models registered from within extension modules, and models created by calls to CopyModel().

ResetKernel() clears this list and rebuilds it with built-in models only.

The elements of this list are used to create instances and are responsible for the storage of model defaults.

Referenced by calibrate(), clear_node_models_(), copy_node_model_(), get_node_model(), memory_info(), and register_node_model_().

◆ proxy_nodes_

std::vector< std::vector< Node* > > nest::ModelManager::proxy_nodes_
private

Placeholders for remote nodes, one per thread.

Referenced by clear_node_models_(), copy_node_model_(), get_proxy_node(), initialize(), and register_node_model_().

◆ proxynode_model_

Model* nest::ModelManager::proxynode_model_
private

◆ synapsedict_


The documentation for this class was generated from the following files: