Node Manager

The NodeManager in NEST manages node creation and distribution across computational threads, ensuring parallel execution efficiency. It tracks node IDs, handles special node types like MUSIC interfaces, and detects network changes to update states, while storing exceptions from parallel operations for error resolution.

class NodeManager : public nest::ManagerInterface

Public Functions

virtual void initialize(const bool) override

Prepare manager for operation.

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

See also

finalize()

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_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.

virtual void finalize(const bool) override

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.

See also

initialize()

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_only – Pass true if calling from kernel_manager::change_number_of_threads() to limit operations to those necessary for thread adjustment.

virtual void set_status(const DictionaryDatum&) override

Set the status of the manager.

See also

get_status()

virtual void get_status(DictionaryDatum&) override

Retrieve the status of the manager.

See also

set_status()

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().

DictionaryDatum get_status(size_t)

Get properties of a node.

The specified node must exist.

Throws:

nest::UnknownNode – Target does not exist in the network.

void set_status(size_t, const DictionaryDatum&)

Set properties of a Node.

The specified node must exist.

Throws:
  • nest::UnknownNode – Target does not exist in the network.

  • nest::UnaccessedDictionaryEntry – Non-proxy target did not read dict entry.

  • TypeMismatch – Array is not a flat & homogeneous array of integers.

NodeCollectionPTR add_node(size_t m, long n = 1)

Add a number of nodes to the network.

This function creates n Node objects of Model m and adds them to the Network at the current position.

Parameters:
  • m – valid Model ID.

  • n – Number of Nodes to be created. Defaults to 1 if not specified.

Returns:

NodeCollection as lock pointer

NodeCollectionPTR get_nodes(const DictionaryDatum &dict, const bool local_only)

Get node ID’s of all nodes with the given properties.

Only node ID’s of nodes matching the properties given in the dictionary exactly will be returned. If the dictionary is empty, all nodes will be returned. If the local_only bool is true, only node IDs of nodes simulated on the local MPI process will be returned.

Parameters:
  • dict – parameter dictionary of selection properties

  • local_only – bool indicating whether all nodes, or just mpi local nodes should be returned.

Returns:

NodeCollection as lock pointer

inline size_t size() const

Return total number of network nodes.

size_t get_max_num_local_nodes() const

Returns the maximal number of nodes per virtual process.

size_t get_num_thread_local_devices(size_t t) const

Returns the number of devices per thread.

void print(std::ostream&) const

Print network information.

bool is_local_node(Node*) const

Return true, if the given Node is on the local machine.

bool is_local_node_id(size_t node_id) const

Return true, if the given node ID is on the local machine.

Node *get_node_or_proxy(size_t node_id, size_t tid)

Return pointer to the specified Node.

The function expects that the given node ID and thread are valid. If they are not, an assertion will fail. In case the given Node does not exist on the given thread, a proxy is returned instead.

Parameters:
  • node_id – index of the Node

  • tid – local thread index of the Node

Node *get_node_or_proxy(size_t)

Return pointer of the specified Node.

Parameters:

i – Index of the specified Node.

Node *get_mpi_local_node_or_device_head(size_t)

Return pointer of Node on the thread we are on.

If the node has proxies, it returns the node on the first thread (used by recorders).

@params node_id Index of the Node.

std::vector<Node*> get_thread_siblings(size_t n) const

Return a vector that contains the thread siblings.

Parameters:

i – Index of the specified Node.

Throws:

nest::NoThreadSiblingsAvailable – Node does not have thread siblings.

void ensure_valid_thread_local_ids()

Ensure that all nodes in the network have valid thread-local IDs.

Create up-to-date vector of local nodes, nodes_vec_. This method also sets the thread-local ID on all local nodes.

inline const std::vector<Node*> &get_wfr_nodes_on_thread(size_t) const

Get list of nodes on given thread.

void prepare_nodes()

Prepare nodes for simulation and register nodes in node_list.

Calls prepare_node_() for each pertaining Node.

See also

prepare_node_()

inline size_t get_num_active_nodes()

Get the number of nodes created by last prepare_nodes() call.

See also

prepare_nodes()

Returns:

number of active nodes

void post_run_cleanup()

Invoke post_run_cleanup() on all nodes.

void finalize_nodes()

Invoke finalize() on all nodes.

This function is called only if the thread data structures are properly set up.

inline bool wfr_is_used() const

Returns whether any node uses waveform relaxation.

void check_wfr_use()

Checks whether waveform relaxation is used by any node.

inline const SparseNodeArray &get_local_nodes(size_t) const

Return a reference to the thread-local nodes of thread t.

NodeCollectionPTR node_id_to_node_collection(const size_t node_id) const

Map the node ID to its original primitive NodeCollection object.

Parameters:

node_id – The node ID

Returns:

The primitive NodeCollection object containing the node ID that falls in [first, last)

NodeCollectionPTR node_id_to_node_collection(Node *node) const

Map the node to its original primitive NodeCollection object.

Parameters:

node – Node instance

Returns:

The primitive NodeCollection object containing the node with node ID falls in [first, last)