This data structure stores the node IDs of presynaptic neurons during postsynaptic connection creation, before the connection information has been transferred to the presynaptic side. More...
#include <source_table.h>
Public Member Functions | |
| SourceTable () | |
| ~SourceTable () | |
| void | initialize () |
| Initialize data structure. | |
| void | finalize () |
| Delete data structures. | |
| void | add_source (const size_t tid, const synindex syn_id, const size_t node_id, const bool is_primary) |
| Adds a source to sources_. | |
| void | clear (const size_t tid) |
| Clears sources_. | |
| bool | is_cleared () const |
| Returns true if sources_ has been cleared. | |
| 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_. | |
| void | reject_last_target_data (const size_t tid) |
| Rejects the last target data, and resets the current_positions_ accordingly. | |
| void | save_entry_point (const size_t tid) |
| Stores current_positions_ in saved_positions_. | |
| void | restore_entry_point (const size_t tid) |
| Restores current_positions_ from saved_positions_. | |
| void | reset_entry_point (const size_t tid) |
| Resets saved_positions_ to end of sources_. | |
| 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. | |
| std::vector< BlockVector< Source > > & | get_thread_local_sources (const size_t tid) |
| Returns a reference to all sources local on thread; necessary for sorting. | |
| SourceTablePosition | find_maximal_position () const |
| Determines maximal saved_positions_ after which it is safe to delete sources during clean(). | |
| void | reset_processed_flags (const size_t tid) |
| Resets all processed flags. | |
| void | clean (const size_t tid) |
| Removes all entries marked as processed. | |
| 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_maximal_position(). | |
| void | compute_buffer_pos_for_unique_secondary_sources (const size_t tid, std::map< size_t, size_t > &buffer_pos_of_source_node_id_syn_id_) |
| Computes MPI buffer positions for unique combination of source node ID and synapse type across all threads for all secondary connections. | |
| size_t | find_first_source (const size_t tid, const synindex syn_id, const size_t snode_id) const |
| Finds the first non-disabled entry in sources_ at the given thread id and synapse type that has sender equal to snode_id. | |
| void | disable_connection (const size_t tid, const synindex syn_id, const size_t lcid) |
| Marks entry in sources_ at given position as disabled. | |
| size_t | remove_disabled_sources (const size_t tid, const synindex syn_id) |
| Removes all entries from sources_ that are marked as disabled. | |
| void | get_source_node_ids (const size_t tid, const synindex syn_id, const std::vector< size_t > &source_lcids, std::vector< size_t > &sources) |
| Returns node IDs for entries in sources_ for the given thread id, synapse type and local connections ids. | |
| size_t | num_unique_sources (const size_t tid, const synindex syn_id) const |
| Returns the number of unique node IDs for given thread id and synapse type in sources_.i. | |
| void | resize_sources () |
| Resizes sources_ according to total number of threads and synapse types. | |
| size_t | pack_source_node_id_and_syn_id (const size_t source_node_id, const synindex syn_id) const |
| Encodes combination of node ID and synapse types as single long number. | |
| void | resize_compressible_sources () |
| void | collect_compressible_sources (const size_t tid) |
| void | fill_compressed_spike_data (std::vector< std::vector< std::vector< SpikeData > > > &compressed_spike_data) |
| void | clear_compressed_spike_data_map () |
| void | dump_sources () const |
| void | dump_compressible_sources () const |
| void | dump_compressed_spike_data (const std::vector< std::vector< std::vector< SpikeData > > > &compressed_spike_data) const |
Private Member Functions | |
| bool | source_should_be_processed_ (const size_t rank_start, const size_t rank_end, const Source &source) const |
| Returns whether this Source object should be considered when constructing MPI buffers for communicating connections. | |
| bool | next_entry_has_same_source_ (const SourceTablePosition ¤t_position, const Source ¤t_source) const |
| Returns true if the following entry in the SourceTable has the same source gid. | |
| bool | previous_entry_has_same_source_ (const SourceTablePosition ¤t_position, const Source ¤t_source) const |
| Returns true if the previous entry in the SourceTable has the same source gid. | |
| bool | populate_target_data_fields_ (const SourceTablePosition ¤t_position, const Source ¤t_source, const size_t source_rank, TargetData &next_target_data) const |
| Fills the fields of a TargetData during construction of * presynaptic connection infrastructure. | |
Private Attributes | |
| std::vector< std::vector< BlockVector< Source > > > | sources_ |
| 3D structure storing node IDs of presynaptic neurons. | |
| PerThreadBoolIndicator | is_cleared_ |
| Whether the 3D structure has been deleted. | |
| std::vector< SourceTablePosition > | current_positions_ |
| Needed during readout of sources_. | |
| std::vector< SourceTablePosition > | saved_positions_ |
| Needed during readout of sources_. | |
| PerThreadBoolIndicator | saved_entry_point_ |
| If we detect an overflow in one of the MPI buffer parts, we save our current position in sources_ to continue at that point in the next communication round, while filling up (possible) remaining parts of the MPI buffer. | |
| std::vector< std::vector< std::map< size_t, SpikeData > > > | compressible_sources_ |
| A structure to temporarily hold information about all process local targets will be addressed by incoming spikes. | |
| std::vector< std::map< size_t, CSDMapEntry > > | compressed_spike_data_map_ |
| A structure to temporarily store locations of "unpacked spikes" in the compressed_spike_data_ structure of ConnectionManager. | |
Static Private Attributes | |
| static const size_t | min_deleted_elements_ = 1000000 |
| Minimal number of sources that need to be deleted per synapse type and thread before a reallocation of the respective vector is performed. | |
Friends | |
| class | ConnectionManager |
This data structure stores the node IDs of presynaptic neurons during postsynaptic connection creation, before the connection information has been transferred to the presynaptic side.
The core structure is the three dimensional sources vector, which is arranged as follows:
1st dimension: threads 2nd dimension: synapse types 3rd dimension: node IDs After all connections have been created, the information stored in this structure is transferred to the presynaptic side and the sources vector can be cleared.
| nest::SourceTable::SourceTable | ( | ) |
| nest::SourceTable::~SourceTable | ( | ) |
|
inline |
Adds a source to sources_.
References sources_.
Referenced by nest::ConnectionManager::connect_().
| void nest::SourceTable::clean | ( | const size_t | tid | ) |
Removes all entries marked as processed.
References BlockVector< value_type_ >::begin(), BlockVector< value_type_ >::clear(), BlockVector< value_type_ >::end(), BlockVector< value_type_ >::erase(), find_maximal_position(), nest::SourceTablePosition::lcid, BlockVector< value_type_ >::size(), sources_, nest::SourceTablePosition::syn_id, and nest::SourceTablePosition::tid.
Referenced by nest::ConnectionManager::clean_source_table().
|
inline |
Clears sources_.
References BlockVector< value_type_ >::end(), is_cleared_, nest::PerThreadBoolIndicator::set_true(), and sources_.
Referenced by nest::ConnectionManager::clear_source_table(), and finalize().
|
inline |
References compressed_spike_data_map_.
Referenced by nest::ConnectionManager::clear_compressed_spike_data_map().
| void nest::SourceTable::collect_compressible_sources | ( | const size_t | tid | ) |
References compressible_sources_, nest::KernelManager::connection_manager, get_node_id(), nest::kernel(), nest::ConnectionManager::set_source_has_more_targets(), and sources_.
Referenced by nest::ConnectionManager::collect_compressed_spike_data().
| void nest::SourceTable::compute_buffer_pos_for_unique_secondary_sources | ( | const size_t | tid, |
| std::map< size_t, size_t > & | buffer_pos_of_source_node_id_syn_id_ | ||
| ) |
Computes MPI buffer positions for unique combination of source node ID and synapse type across all threads for all secondary connections.
References nest::ModelManager::get_connection_model(), nest::KernelManager::get_omp_synchronization_construction_stopwatch(), nest::MPIManager::get_process_id_of_node_id(), nest::ModelManager::get_secondary_event_prototype(), nest::ConnectorModel::has_property(), nest::IS_PRIMARY, nest::kernel(), nest::KernelManager::model_manager, nest::KernelManager::mpi_manager, pack_source_node_id_and_syn_id(), nest::MPIManager::set_recv_counts_secondary_events_in_int_per_rank(), sources_, nest::Stopwatch< detailed_timer, threaded_timer >::start(), and nest::Stopwatch< detailed_timer, threaded_timer >::stop().
Referenced by nest::ConnectionManager::compute_compressed_secondary_recv_buffer_positions().
|
inline |
Marks entry in sources_ at given position as disabled.
References sources_.
Referenced by nest::ConnectionManager::disconnect().
| void nest::SourceTable::dump_compressed_spike_data | ( | const std::vector< std::vector< std::vector< SpikeData > > > & | compressed_spike_data | ) | const |
References compressed_spike_data_map_, FULL_LOGGING_ONLY, nest::kernel(), and nest::KernelManager::write_to_dump().
| void nest::SourceTable::dump_compressible_sources | ( | ) | const |
References compressible_sources_, FULL_LOGGING_ONLY, nest::kernel(), and nest::KernelManager::write_to_dump().
| void nest::SourceTable::dump_sources | ( | ) | const |
References FULL_LOGGING_ONLY, nest::kernel(), sources_, and nest::KernelManager::write_to_dump().
| void nest::SourceTable::fill_compressed_spike_data | ( | std::vector< std::vector< std::vector< SpikeData > > > & | compressed_spike_data | ) |
References compressed_spike_data_map_, compressible_sources_, nest::find(), nest::ModelManager::get_num_connection_models(), nest::VPManager::get_num_threads(), nest::invalid_lcid, nest::invalid_synindex, nest::invalid_targetindex, nest::kernel(), nest::KernelManager::model_manager, and nest::KernelManager::vp_manager.
Referenced by nest::ConnectionManager::collect_compressed_spike_data().
| void nest::SourceTable::finalize | ( | ) |
Delete data structures.
References clear(), compressed_spike_data_map_, compressible_sources_, current_positions_, is_cleared_, saved_positions_, and sources_.
Referenced by nest::ConnectionManager::finalize().
| size_t nest::SourceTable::find_first_source | ( | const size_t | tid, |
| const synindex | syn_id, | ||
| const size_t | snode_id | ||
| ) | const |
Finds the first non-disabled entry in sources_ at the given thread id and synapse type that has sender equal to snode_id.
invalid_indexReferences nest::Source::get_node_id(), nest::Source::is_disabled(), nest::kernel(), and sources_.
Referenced by nest::ConnectionManager::find_connection(), and nest::ConnectionManager::get_targets().
| SourceTablePosition nest::SourceTable::find_maximal_position | ( | ) | const |
Determines maximal saved_positions_ after which it is safe to delete sources during clean().
References nest::VPManager::get_num_threads(), nest::kernel(), saved_positions_, and nest::KernelManager::vp_manager.
Referenced by clean().
| bool nest::SourceTable::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_.
References nest::KernelManager::connection_manager, current_positions_, nest::SourceTablePosition::decrease(), nest::Source::get_node_id(), nest::MPIManager::get_process_id_of_node_id(), nest::SourceTablePosition::is_invalid(), nest::kernel(), nest::SourceTablePosition::lcid, nest::KernelManager::mpi_manager, next_entry_has_same_source_(), populate_target_data_fields_(), previous_entry_has_same_source_(), nest::SourceTablePosition::seek_to_next_valid_index(), nest::Source::set_processed(), nest::ConnectionManager::set_source_has_more_targets(), source_should_be_processed_(), sources_, nest::SourceTablePosition::syn_id, and nest::SourceTablePosition::tid.
Referenced by nest::ConnectionManager::get_next_target_data().
| size_t nest::SourceTable::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.
References nest::kernel(), and sources_.
Referenced by collect_compressible_sources(), nest::ConnectionManager::compute_compressed_secondary_recv_buffer_positions(), nest::Connector< ConnectionT >::find_enabled_connection(), nest::ConnectionManager::get_connections_(), nest::ConnectionManager::get_connections_from_sources_(), nest::ConnectionManager::get_connections_to_targets_(), nest::ConnectionManager::get_source_node_id(), get_source_node_ids(), and previous_entry_has_same_source_().
|
inline |
Returns node IDs for entries in sources_ for the given thread id, synapse type and local connections ids.
References get_node_id(), and sources_.
Referenced by nest::ConnectionManager::get_source_node_ids_().
| std::vector< BlockVector< Source > > & nest::SourceTable::get_thread_local_sources | ( | const size_t | tid | ) |
Returns a reference to all sources local on thread; necessary for sorting.
References sources_.
Referenced by nest::ConnectionManager::sort_connections().
| void nest::SourceTable::initialize | ( | ) |
Initialize data structure.
References compressible_sources_, current_positions_, nest::VPManager::get_num_threads(), nest::VPManager::get_thread_id(), nest::PerThreadBoolIndicator::initialize(), is_cleared_, nest::kernel(), resize_sources(), saved_entry_point_, saved_positions_, sources_, and nest::KernelManager::vp_manager.
Referenced by nest::ConnectionManager::initialize().
| bool nest::SourceTable::is_cleared | ( | ) | const |
Returns true if sources_ has been cleared.
References nest::PerThreadBoolIndicator::all_true(), and is_cleared_.
Referenced by nest::ConnectionManager::is_source_table_cleared(), nest::ConnectionManager::restructure_connection_tables(), and nest::ConnectionManager::sort_connections().
|
private |
Returns true if the following entry in the SourceTable has the same source gid.
References nest::Source::get_node_id(), nest::SourceTablePosition::is_invalid(), nest::SourceTablePosition::lcid, sources_, nest::SourceTablePosition::syn_id, and nest::SourceTablePosition::tid.
Referenced by get_next_target_data().
|
inline |
Sets current_positions_ for this thread to minimal values so that these are not considered in find_maximal_position().
References current_positions_.
Referenced by nest::ConnectionManager::no_targets_to_process().
|
inline |
Returns the number of unique node IDs for given thread id and synapse type in sources_.i.
This number corresponds to the number of targets that need to be communicated during construction of the presynaptic connection infrastructure.
References sources_.
Referenced by nest::ConnectionManager::get_num_target_data().
|
inline |
Encodes combination of node ID and synapse types as single long number.
References nest::invalid_synindex.
Referenced by compute_buffer_pos_for_unique_secondary_sources(), and nest::ConnectionManager::compute_compressed_secondary_recv_buffer_positions().
|
private |
Fills the fields of a TargetData during construction of * presynaptic connection infrastructure.
References nest::KernelManager::connection_manager, nest::Source::get_node_id(), nest::MPIManager::get_recv_displacement_secondary_events_in_int(), nest::ConnectionManager::get_secondary_recv_buffer_position(), nest::Source::is_primary(), nest::kernel(), nest::SourceTablePosition::lcid, nest::KernelManager::mpi_manager, nest::TargetData::reset_marker(), nest::TargetData::secondary_data, nest::TargetData::set_is_primary(), nest::TargetDataFields::set_lcid(), nest::SecondaryTargetDataFields::set_recv_buffer_pos(), nest::TargetData::set_source_lid(), nest::TargetData::set_source_tid(), nest::TargetDataFields::set_syn_id(), nest::SecondaryTargetDataFields::set_syn_id(), nest::TargetDataFields::set_tid(), nest::SourceTablePosition::syn_id, nest::TargetData::target_data, and nest::SourceTablePosition::tid.
Referenced by get_next_target_data().
|
private |
Returns true if the previous entry in the SourceTable has the same source gid.
References nest::Source::get_node_id(), get_node_id(), nest::SourceTablePosition::is_invalid(), nest::SourceTablePosition::lcid, sources_, nest::SourceTablePosition::syn_id, and nest::SourceTablePosition::tid.
Referenced by get_next_target_data().
|
inline |
Rejects the last target data, and resets the current_positions_ accordingly.
References current_positions_, and sources_.
Referenced by nest::ConnectionManager::reject_last_target_data().
| size_t nest::SourceTable::remove_disabled_sources | ( | const size_t | tid, |
| const synindex | syn_id | ||
| ) |
Removes all entries from sources_ that are marked as disabled.
References BlockVector< value_type_ >::begin(), BlockVector< value_type_ >::end(), BlockVector< value_type_ >::erase(), nest::kernel(), BlockVector< value_type_ >::size(), and sources_.
Referenced by nest::ConnectionManager::remove_disabled_connections_().
|
inline |
Resets saved_positions_ to end of sources_.
References saved_positions_, and sources_.
Referenced by nest::ConnectionManager::reset_source_table_entry_point().
|
inline |
Resets all processed flags.
Needed for restructuring connection tables, e.g., during structural plasticity update.
References BlockVector< value_type_ >::end(), and sources_.
Referenced by nest::ConnectionManager::restructure_connection_tables().
| void nest::SourceTable::resize_compressible_sources | ( | ) |
References compressible_sources_, nest::ModelManager::get_num_connection_models(), nest::kernel(), and nest::KernelManager::model_manager.
Referenced by nest::ConnectionManager::collect_compressed_spike_data().
| void nest::SourceTable::resize_sources | ( | ) |
Resizes sources_ according to total number of threads and synapse types.
References nest::VPManager::assert_thread_parallel(), nest::kernel(), sources_, and nest::KernelManager::vp_manager.
Referenced by initialize(), and nest::ConnectionManager::resize_connections().
|
inline |
Restores current_positions_ from saved_positions_.
References current_positions_, saved_entry_point_, saved_positions_, and nest::PerThreadBoolIndicator::set_false().
Referenced by nest::ConnectionManager::restore_source_table_entry_point().
|
inline |
Stores current_positions_ in saved_positions_.
References current_positions_, saved_entry_point_, saved_positions_, nest::PerThreadBoolIndicator::set_true(), and sources_.
Referenced by nest::ConnectionManager::save_source_table_entry_point().
|
private |
Returns whether this Source object should be considered when constructing MPI buffers for communicating connections.
Returns false if i) this entry was already processed, or ii) this entry is disabled (e.g., by structural plastcity) or iii) the reading thread is not responsible for the particular part of the MPI buffer where this entry would be written.
References nest::MPIManager::get_process_id_of_node_id(), nest::kernel(), and nest::KernelManager::mpi_manager.
Referenced by get_next_target_data().
|
friend |
|
private |
A structure to temporarily store locations of "unpacked spikes" in the compressed_spike_data_ structure of ConnectionManager.
Data from this structure is transferred to the presynaptic side during construction of the presynaptic connection infrastructure. Arranged as a one-dimensional vector over synapse ids with an inner map (source node id -> (source_index+target_thread).
Referenced by clear_compressed_spike_data_map(), dump_compressed_spike_data(), fill_compressed_spike_data(), nest::ConnectionManager::fill_target_buffer(), finalize(), and nest::ConnectionManager::initialize_iteration_state().
|
private |
A structure to temporarily hold information about all process local targets will be addressed by incoming spikes.
Data from this structure is transferred to the compressed_spike_data_ structure of ConnectionManager during construction of the postsynaptic connection infrastructure. Arranged as a two dimensional vector (thread|synapse) with an inner map (source node id -> spike data).
Referenced by collect_compressible_sources(), dump_compressible_sources(), fill_compressed_spike_data(), finalize(), initialize(), and resize_compressible_sources().
|
private |
Needed during readout of sources_.
Referenced by finalize(), get_next_target_data(), initialize(), no_targets_to_process(), reject_last_target_data(), restore_entry_point(), and save_entry_point().
|
private |
Whether the 3D structure has been deleted.
Referenced by clear(), finalize(), initialize(), and is_cleared().
|
staticprivate |
Minimal number of sources that need to be deleted per synapse type and thread before a reallocation of the respective vector is performed.
Balances number of reallocations and memory usage.
|
private |
If we detect an overflow in one of the MPI buffer parts, we save our current position in sources_ to continue at that point in the next communication round, while filling up (possible) remaining parts of the MPI buffer.
Referenced by initialize(), restore_entry_point(), and save_entry_point().
|
private |
Needed during readout of sources_.
Referenced by finalize(), find_maximal_position(), initialize(), reset_entry_point(), restore_entry_point(), and save_entry_point().
|
private |
3D structure storing node IDs of presynaptic neurons.
Referenced by add_source(), clean(), clear(), collect_compressible_sources(), compute_buffer_pos_for_unique_secondary_sources(), disable_connection(), dump_sources(), finalize(), find_first_source(), get_next_target_data(), get_node_id(), get_source_node_ids(), get_thread_local_sources(), initialize(), next_entry_has_same_source_(), num_unique_sources(), previous_entry_has_same_source_(), reject_last_target_data(), remove_disabled_sources(), reset_entry_point(), reset_processed_flags(), resize_sources(), and save_entry_point().