23#ifndef CONNECTION_MANAGER_H
24#define CONNECTION_MANAGER_H
51class GenericBipartiteConnBuilderFactory;
52class GenericThirdConnBuilderFactory;
77 void finalize(
const bool )
override;
91 template <
typename ConnBuilder >
97 template <
typename ThirdConnBuilder >
106 const std::vector< Dictionary >& syn_specs );
114 const std::vector< Dictionary >& syn_specs );
122 const std::vector< Dictionary >& syn_specs );
145 void connect(
const size_t snode_id,
147 size_t target_thread,
169 const double* weights,
170 const double* delays,
171 const std::vector< std::string >& p_keys,
172 const double* p_values,
174 const std::string& syn_model );
198 const std::map< std::string, std::vector< Dictionary > >& synapse_specs );
205 size_t find_connection(
const size_t tid,
const synindex syn_id,
const size_t snode_id,
const size_t tnode_id );
207 void disconnect(
const size_t tid,
const synindex syn_id,
const size_t snode_id,
const size_t tnode_id );
220 const size_t target_node_id,
223 const size_t lcid )
const;
227 const size_t target_node_id,
254 long synapse_label )
const;
266 void get_sources(
const std::vector< size_t >& targets,
268 std::vector< std::vector< size_t > >& sources );
270 void get_targets(
const std::vector< size_t >& sources,
272 const std::string& post_synaptic_element,
273 std::vector< std::vector< size_t > >& targets );
287 trigger_update_weight(
const long vt_node_id,
const std::vector< spikecounter >& dopa_spikes,
const double t_trig );
303 void send(
const size_t tid,
306 const std::vector< ConnectorModel* >& cm,
358 const size_t rank_start,
359 const size_t rank_end,
364 const size_t rank_start,
365 const size_t rank_end,
366 std::vector< TargetData >& send_buffer_target_data,
426 const std::vector< size_t >&
435 const bool called_from_wfr_update,
436 std::vector< unsigned int >& recv_buffer );
472 std::deque< ConnectionID >& connectome,
476 long synapse_label )
const;
478 std::deque< ConnectionID >& connectome,
482 long synapse_label )
const;
484 std::deque< ConnectionID >& connectome,
488 long synapse_label )
const;
492 const size_t tnode_id,
493 std::vector< size_t >& sources );
506 std::vector< size_t >& neuron_node_ids,
507 std::vector< size_t >& device_node_ids )
const;
554 const size_t s_node_id,
581 const size_t s_node_id,
585 const double delay = NAN,
586 const double weight = NAN );
611 const double delay = NAN,
612 const double weight = NAN );
718 std::vector< std::pair< size_t, std::map< size_t, CSDMapEntry >::const_iterator > >
iteration_state_;
817inline const std::vector< Target >&
837 const size_t rank_start,
838 const size_t rank_end,
845inline const std::vector< size_t >&
856 const size_t lcid )
const
900 return connections_[ tid ][ syn_id ]->get_target_node_id( tid, lcid );
913 const std::vector< ConnectorModel* >& cm,
916 connections_[ tid ][ syn_id ]->send( tid, lcid, cm, e );
931 const bool more_targets )
933 connections_[ tid ][ syn_id ]->set_source_has_more_targets( lcid, more_targets );
936inline const std::vector< SpikeData >&
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
bool known(const std::string &key) const
Check whether there exists a value with specified key in the dictionary.
Definition dictionary.h:677
Abstract base class for Bipartite ConnBuilders which form the components of ConnBuilder.
Definition conn_builder.h:69
Definition connection_manager.h:62
void get_connections_from_sources_(const size_t tid, std::deque< ConnectionID > &connectome, NodeCollectionPTR source, NodeCollectionPTR target, synindex syn_id, long synapse_label) const
Definition connection_manager.cpp:1250
void get_targets(const std::vector< size_t > &sources, const size_t syn_id, const std::string &post_synaptic_element, std::vector< std::vector< size_t > > &targets)
Definition connection_manager.cpp:1401
std::vector< std::vector< size_t > > num_connections_
A structure to count the number of synapses of a specific type.
Definition connection_manager.h:664
bool get_user_set_delay_extrema() const
Definition connection_manager.cpp:368
long get_min_delay() const
Return minimal connection delay, which is precomputed by update_delay_extrema_().
Definition connection_manager.h:728
std::vector< DelayChecker > delay_checkers_
Definition connection_manager.h:658
const std::vector< SpikeData > & get_compressed_spike_data(const synindex syn_id, const size_t idx)
Definition connection_manager.h:937
void register_conn_builder(const std::string &name)
Add a connectivity rule, i.e.
Definition connection_manager_impl.h:43
void sort_connections(const size_t tid)
Sorts connections in the presynaptic infrastructure by increasing source node ID.
Definition connection_manager.cpp:1426
void collect_compressed_spike_data(const size_t tid)
Definition connection_manager.cpp:1761
void initialize_iteration_state()
Set iteration_state_ entries for all threads to beginning of compressed_spike_data_map_.
Definition connection_manager.cpp:1898
void get_sources(const std::vector< size_t > &targets, const size_t syn_id, std::vector< std::vector< size_t > > &sources)
Definition connection_manager.cpp:1381
void send_from_device(const size_t tid, const size_t ldid, Event &e)
Send event e to all targets of source device ldid (local device id)
Definition connection_manager_impl.h:79
double get_stdp_eps() const
Definition connection_manager.h:892
void send_to_devices(const size_t tid, const size_t source_node_id, Event &e)
Send event e to all device targets of source source_node_id.
Definition connection_manager_impl.h:67
ConnectionType connection_required(Node *&source, Node *&target, size_t tid)
Check whether a connection between the given source and target nodes can be established on the given ...
Definition connection_manager.cpp:1512
PerThreadBoolIndicator check_primary_connections_
Check for primary connections (spikes) on each thread.
Definition connection_manager.h:704
bool use_compressed_spikes_
Whether to use spike compression; if a neuron has targets on multiple threads of a process,...
Definition connection_manager.h:698
bool fill_target_buffer(const size_t tid, const size_t rank_start, const size_t rank_end, std::vector< TargetData > &send_buffer_target_data, TargetSendBufferPosition &send_buffer_position)
Definition connection_manager.cpp:1783
void set_connections_have_changed()
Sets flag indicating whether connection information needs to be communicated to true.
Definition connection_manager.cpp:1737
void calibrate(const TimeConverter &)
Resize the structures for the Connector objects if necessary.
Definition connection_manager.cpp:422
void set_source_has_more_targets(const size_t tid, const synindex syn_id, const size_t lcid, const bool more_targets)
Definition connection_manager.h:928
void connect_(Node &source, Node &target, const size_t s_node_id, const size_t tid, const synindex syn_id, const Dictionary ¶ms, const double delay=numerics::nan, const double weight=numerics::nan)
connect_ is used to establish a connection between a sender and receiving node which both have proxie...
Definition connection_manager.cpp:868
long max_delay_
Value of the largest delay in the network in steps.
Definition connection_manager.h:678
size_t get_source_node_id(const size_t tid, const synindex syn_id, const size_t lcid)
Definition connection_manager.h:868
std::vector< GenericThirdConnBuilderFactory * > thirdconnbuilder_factories_
Third-factor ConnBuilder factories, indexed by thirdconnruledict_ elements.
Definition connection_manager.h:674
void initialize(const bool) override
Prepare manager for operation.
Definition connection_manager.cpp:96
Stopwatch< StopwatchGranularity::Normal, StopwatchParallelism::MasterOnly > sw_construction_connect
Definition connection_manager.h:458
void compute_target_data_buffer_size()
Definition connection_manager.cpp:1443
void compute_compressed_secondary_recv_buffer_positions(const size_t tid)
Definition connection_manager.cpp:1469
void connect_sonata(const Dictionary &graph_specs, const long hyberslab_size)
Connect nodes from SONATA specification.
Definition connection_manager.cpp:779
void delete_connections_()
Deletes all connections.
Definition connection_manager.cpp:328
void connect(NodeCollectionPTR sources, NodeCollectionPTR targets, const Dictionary &conn_spec, const std::vector< Dictionary > &syn_specs)
Create connections.
Definition connection_manager.cpp:431
void get_connections_to_targets_(const size_t tid, std::deque< ConnectionID > &connectome, NodeCollectionPTR source, NodeCollectionPTR target, synindex syn_id, long synapse_label) const
Definition connection_manager.cpp:1211
void prepare_target_table(const size_t tid)
Definition connection_manager.h:812
void send(const size_t tid, const synindex syn_id, const size_t lcid, const std::vector< ConnectorModel * > &cm, Event &e)
Definition connection_manager.h:910
bool connections_have_changed() const
Returns true if connection information needs to be communicated.
Definition connection_manager.h:824
Dictionary get_synapse_status(const size_t source_node_id, const size_t target_node_id, const size_t tid, const synindex syn_id, const size_t lcid) const
Definition connection_manager.cpp:235
bool secondary_connections_exist() const
Definition connection_manager.h:880
bool get_next_target_data(const size_t tid, const size_t rank_start, const size_t rank_end, size_t &target_rank, TargetData &next_target_data)
Definition connection_manager.h:836
bool is_source_table_cleared() const
Returns true if source table was cleared.
Definition connection_manager.h:764
void send_local(size_t t, Node &source, Event &e)
Send event e to all targets of node source on thread t.
void remove_disabled_connections_(const size_t tid)
Removes disabled connections (of structural plasticity)
Definition connection_manager.cpp:1688
bool connections_have_changed_
True if new connections have been created since startup or last call to simulate.
Definition connection_manager.h:685
void set_stdp_eps(const double stdp_eps)
Definition connection_manager.cpp:1604
ThirdOutBuilder * get_third_conn_builder(const std::string &name, NodeCollectionPTR sources, NodeCollectionPTR targets, ThirdInBuilder *third_in, const Dictionary &conn_spec, const std::vector< Dictionary > &syn_specs)
Obtain builder for bipartite connections.
Definition connection_manager.cpp:402
size_t get_num_connections() const
Returns the number of connections in the network.
Definition connection_manager.cpp:1051
void clean_source_table(const size_t tid)
Removes processed entries from source table.
Definition connection_manager.h:740
Dictionary thirdconnruledict_
Dictionary for third-factor connection rules.
Definition connection_manager.h:671
void restructure_connection_tables(const size_t tid)
Deletes TargetTable and resets processed flags of SourceTable.
Definition connection_manager.h:920
bool valid_connection_rule(std::string)
Definition connection_manager.h:722
long get_max_delay() const
Return maximal connection delay, which is precomputed by update_delay_extrema_().
Definition connection_manager.h:734
const std::vector< Target > & get_remote_targets_of_local_node(const size_t tid, const size_t lid) const
Definition connection_manager.h:818
BipartiteConnBuilder * get_conn_builder(const std::string &name, NodeCollectionPTR sources, NodeCollectionPTR targets, ThirdOutBuilder *third_out, const Dictionary &conn_spec, const std::vector< Dictionary > &syn_specs)
Obtain builder for bipartite connections.
Definition connection_manager.cpp:382
const Time get_max_delay_time_() const
This method queries and finds the maximum delay of all local connections.
Definition connection_manager.cpp:354
void resize_target_table_devices_to_number_of_synapse_types()
Definition connection_manager.h:776
std::deque< ConnectionID > get_connections(const Dictionary ¶ms)
Return connections between pairs of neurons.
Definition connection_manager.cpp:1081
std::vector< std::pair< size_t, std::map< size_t, CSDMapEntry >::const_iterator > > iteration_state_
For each thread, store (syn_id, compressed_spike_data_map_::iterator) pair for next iteration while f...
Definition connection_manager.h:718
ConnectionType
Definition connection_manager.h:66
@ CONNECT_TO_DEVICE
Definition connection_manager.h:69
@ NO_CONNECTION
Definition connection_manager.h:70
@ CONNECT
Definition connection_manager.h:67
@ CONNECT_FROM_DEVICE
Definition connection_manager.h:68
void trigger_update_weight(const long vt_node_id, const std::vector< spikecounter > &dopa_spikes, const double t_trig)
Triggered by volume transmitter in update.
Definition connection_manager.cpp:1019
void finalize(const bool) override
Take down manager after operation.
Definition connection_manager.cpp:153
void no_targets_to_process(const size_t tid)
Definition connection_manager.h:794
void save_source_table_entry_point(const size_t tid)
Definition connection_manager.h:788
void check_secondary_connections_exist()
Definition connection_manager.cpp:1731
std::vector< std::vector< ConnectorBase * > > connections_
A structure to hold the Connector objects which in turn hold the connection information.
Definition connection_manager.h:624
void reject_last_target_data(const size_t tid)
Definition connection_manager.h:782
bool use_compressed_spikes() const
Returns whether spikes should be compressed.
Definition connection_manager.h:886
void resize_target_table_devices_to_number_of_neurons()
Definition connection_manager.h:770
void clear_source_table(const size_t tid)
Clears all entries in source table.
Definition connection_manager.h:749
void compress_secondary_send_buffer_pos(const size_t tid)
Definition connection_manager.cpp:1682
std::vector< std::vector< std::vector< SpikeData > > > compressed_spike_data_
A structure to hold "unpacked" spikes on the postsynaptic side if spike compression is enabled.
Definition connection_manager.h:639
void get_connections_(const size_t tid, std::deque< ConnectionID > &connectome, NodeCollectionPTR source, NodeCollectionPTR target, synindex syn_id, long synapse_label) const
See get_connections()
Definition connection_manager.cpp:1188
void get_status(Dictionary &) override
Retrieve the status of the manager.
Definition connection_manager.cpp:213
size_t get_num_target_data(const size_t tid) const
Definition connection_manager.cpp:1037
void connect_arrays(const long *sources, const long *targets, const double *weights, const double *delays, const std::vector< std::string > &p_keys, const double *p_values, size_t n, const std::string &syn_model)
Definition connection_manager.cpp:605
TargetTableDevices target_table_devices_
Definition connection_manager.h:656
TargetTable target_table_
A structure to hold the information about targets for each neuron on the presynaptic side.
Definition connection_manager.h:654
bool get_keep_source_table() const
Returns true if source table is kept after building network.
Definition connection_manager.h:758
bool has_primary_connections() const
Definition connection_manager.h:874
Dictionary connruledict_
Dictionary for connection rules.
Definition connection_manager.h:666
bool has_primary_connections_
Whether primary connections (spikes) exist.
Definition connection_manager.h:701
~ConnectionManager() override
Definition connection_manager.cpp:85
const Time get_min_delay_time_() const
This method queries and finds the minimum delay of all local connections.
Definition connection_manager.cpp:340
bool get_connections_has_been_called_
true if GetConnections has been called.
Definition connection_manager.h:688
size_t get_target_node_id(const size_t tid, const synindex syn_id, const size_t lcid) const
Definition connection_manager.h:898
void reset_source_table_entry_point(const size_t tid)
Definition connection_manager.h:800
void restore_source_table_entry_point(const size_t tid)
Definition connection_manager.h:806
double stdp_eps_
Maximum distance between (double) spike times in STDP that is still considered 0.
Definition connection_manager.h:714
void add_target(const size_t tid, const size_t target_rank, const TargetData &target_data)
Definition connection_manager.h:830
void disconnect(const size_t tid, const synindex syn_id, const size_t snode_id, const size_t tnode_id)
Definition connection_manager.cpp:1000
bool secondary_connections_exist_
Whether secondary connections (e.g., gap junctions) exist.
Definition connection_manager.h:707
void set_synapse_status(const size_t source_node_id, const size_t target_node_id, const size_t tid, const synindex syn_id, const size_t lcid, const Dictionary &dict)
Definition connection_manager.cpp:278
void connect_to_device_(Node &source, Node &target, const size_t s_node_id, const size_t tid, const synindex syn_id, const Dictionary ¶ms, const double delay=NAN, const double weight=NAN)
connect_to_device_ is used to establish a connection between a sender and receiving node if the sende...
Definition connection_manager.cpp:924
void split_to_neuron_device_vectors_(const size_t tid, NodeCollectionPTR nodecollection, std::vector< size_t > &neuron_node_ids, std::vector< size_t > &device_node_ids) const
Splits a TokenArray of node IDs to two vectors containing node IDs of neurons and node IDs of devices...
Definition connection_manager.cpp:1163
void connect_tripartite(NodeCollectionPTR sources, NodeCollectionPTR targets, NodeCollectionPTR third, const Dictionary &connectivity, const Dictionary &third_connectivity, const std::map< std::string, std::vector< Dictionary > > &synapse_specs)
Create tripartite connections.
Definition connection_manager.cpp:801
void connect_from_device_(Node &source, Node &target, const size_t tid, const synindex syn_id, const Dictionary ¶ms, const double delay=NAN, const double weight=NAN)
connect_from_device_ is used to establish a connection between a sender and receiving node if the sen...
Definition connection_manager.cpp:940
void resize_connections()
Definition connection_manager.cpp:1714
PerThreadBoolIndicator check_secondary_connections_
Check for secondary connections (e.g., gap junctions) on each thread.
Definition connection_manager.h:710
long min_delay_
Value of the smallest delay in the network.
Definition connection_manager.h:676
void sync_has_primary_connections()
Definition connection_manager.cpp:1725
void update_delay_extrema_()
Update delay extrema to current values.
Definition connection_manager.cpp:485
ConnectionManager()
Definition connection_manager.cpp:66
size_t get_num_connections_(const size_t tid, const synindex syn_id) const
Definition connection_manager.h:862
const std::vector< size_t > & get_secondary_send_buffer_positions(const size_t tid, const size_t lid, const synindex syn_id) const
Definition connection_manager.h:846
std::vector< GenericBipartiteConnBuilderFactory * > connbuilder_factories_
ConnBuilder factories, indexed by connruledict_ elements.
Definition connection_manager.h:669
bool deliver_secondary_events(const size_t tid, const bool called_from_wfr_update, std::vector< unsigned int > &recv_buffer)
Definition connection_manager.cpp:1633
size_t find_connection(const size_t tid, const synindex syn_id, const size_t snode_id, const size_t tnode_id)
Find first non-disabled thread-local connection of given synapse type with given source and target no...
Definition connection_manager.cpp:973
bool get_device_connected(size_t tid, size_t lcid) const
Definition connection_manager.h:904
void register_third_conn_builder(const std::string &name)
Add a connectivity rule, i.e.
Definition connection_manager_impl.h:56
size_t get_secondary_recv_buffer_position(const size_t tid, const synindex syn_id, const size_t lcid) const
Returns read position in MPI receive buffer for secondary connections.
Definition connection_manager.h:854
void clear_compressed_spike_data_map()
Definition connection_manager.h:943
void set_status(const Dictionary &) override
Set the status of the manager.
Definition connection_manager.cpp:182
DelayChecker & get_delay_checker()
Returns the delay checker for the current thread.
Definition connection_manager.cpp:207
std::map< size_t, size_t > buffer_pos_of_source_node_id_syn_id_
Definition connection_manager.h:647
std::vector< std::vector< std::vector< size_t > > > secondary_recv_buffer_pos_
Stores absolute position in receive buffer of secondary events.
Definition connection_manager.h:645
void increase_connection_count(const size_t tid, const synindex syn_id)
Increases the connection count.
Definition connection_manager.cpp:955
void unset_connections_have_changed()
Sets flag indicating whether connection information needs to be communicated to false.
Definition connection_manager.cpp:1754
bool keep_source_table_
Whether to keep source table after connection setup is complete.
Definition connection_manager.h:681
void get_source_node_ids_(const size_t tid, const synindex syn_id, const size_t tnode_id, std::vector< size_t > &sources)
Definition connection_manager.cpp:1367
SourceTable source_table_
A structure to hold the node IDs of presynaptic neurons during postsynaptic connection creation,...
Definition connection_manager.h:632
Definition delay_checker.h:37
Encapsulate information sent between nodes.
Definition event.h:103
Interface for kernel manager classes.
Definition manager_interface.h:46
Base class for all NEST network objects.
Definition node.h:99
A thread-safe vector to keep track of the status across threads, for example during gather operations...
Definition per_thread_bool_indicator.h:104
Base class of secondary events.
Definition secondary_event.h:50
Definition simulation_manager.h:47
This data structure stores the node IDs of presynaptic neurons during postsynaptic connection creatio...
Definition source_table.h:104
void clean(const size_t tid)
Removes all entries marked as processed.
Definition source_table.cpp:113
void save_entry_point(const size_t tid)
Stores current_positions_ in saved_positions_.
Definition source_table.h:396
size_t get_node_id(const size_t tid, const synindex syn_id, const size_t lcid) const
Returns the node ID of the source at tid|syn_id|lcid.
Definition source_table.cpp:159
void clear_compressed_spike_data_map()
Definition source_table.h:526
void restore_entry_point(const size_t tid)
Restores current_positions_ from saved_positions_.
Definition source_table.h:423
void reset_processed_flags(const size_t tid)
Resets all processed flags.
Definition source_table.h:457
void reset_entry_point(const size_t tid)
Resets saved_positions_ to end of sources_.
Definition source_table.h:430
void clear(const size_t tid)
Clears sources_.
Definition source_table.h:371
bool is_cleared() const
Returns true if sources_ has been cleared.
Definition source_table.cpp:87
void reject_last_target_data(const size_t tid)
Rejects the last target data, and resets the current_positions_ accordingly.
Definition source_table.h:382
bool get_next_target_data(const size_t tid, const size_t rank_start, const size_t rank_end, size_t &source_rank, TargetData &next_target_data)
Returns the next target data, according to the current_positions_.
Definition source_table.cpp:397
void no_targets_to_process(const size_t tid)
Sets current_positions_ for this thread to minimal values so that these are not considered in find_ma...
Definition source_table.h:469
Used to communicate part of the connection infrastructure from post- to presynaptic side.
Definition target_data.h:175
This class simplifies keeping track of write position in MPI buffer while collocating targets.
Definition send_buffer_position.h:112
This data structure stores the connections between local neurons and devices.
Definition target_table_devices.h:51
void resize_to_number_of_neurons()
Resizes vectors according to number of local nodes.
Definition target_table_devices.cpp:80
bool is_device_connected(size_t tid, size_t lcid) const
Checks if the device has any connections in this thread.
Definition target_table_devices.h:247
void resize_to_number_of_synapse_types()
Resizes vectors according to number of available synapse types.
Definition target_table_devices.cpp:92
This data structure stores all targets of the local neurons.
Definition target_table.h:47
void clear(const size_t tid)
Clears all entries of targets_.
Definition target_table.h:132
void prepare(const size_t tid)
Adjusts targets_ to number of local nodes.
Definition target_table.cpp:56
void add_target(const size_t tid, const size_t target_rank, const TargetData &target_data)
Adds entry to targets_.
Definition target_table.cpp:90
const std::vector< Target > & get_targets(const size_t tid, const size_t lid) const
Returns all targets of a neuron.
Definition target_table.h:119
const std::vector< size_t > & get_secondary_send_buffer_positions(const size_t tid, const size_t lid, const synindex syn_id) const
Returns all MPI send buffer positions of a neuron.
Definition target_table.h:125
Builder creating "thÃrd in" connections based on data from "third out" builder.
Definition conn_builder.h:333
Builder for connections from third-factor nodes to primary target populations.
Definition conn_builder.h:408
Class to convert times from one representation to another.
Definition nest_timeconverter.h:42
Definition nest_time.h:135
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
std::shared_ptr< NodeCollection > NodeCollectionPTR
Definition node_collection.h:50
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
const double nan
Definition numerics.cpp:36