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

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>

Collaboration diagram for nest::SourceTable:
[legend]

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 &current_position, const Source &current_source) const
 Returns true if the following entry in the SourceTable has the same source gid.
 
bool previous_entry_has_same_source_ (const SourceTablePosition &current_position, const Source &current_source) const
 Returns true if the previous entry in the SourceTable has the same source gid.
 
bool populate_target_data_fields_ (const SourceTablePosition &current_position, const Source &current_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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SourceTable()

nest::SourceTable::SourceTable ( )

◆ ~SourceTable()

nest::SourceTable::~SourceTable ( )

Member Function Documentation

◆ add_source()

void nest::SourceTable::add_source ( const size_t  tid,
const synindex  syn_id,
const size_t  node_id,
const bool  is_primary 
)
inline

Adds a source to sources_.

References sources_.

Referenced by nest::ConnectionManager::connect_().

Here is the caller graph for this function:

◆ clean()

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

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

◆ clear()

void nest::SourceTable::clear ( const size_t  tid)
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().

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

◆ clear_compressed_spike_data_map()

void nest::SourceTable::clear_compressed_spike_data_map ( )
inline

References compressed_spike_data_map_.

Referenced by nest::ConnectionManager::clear_compressed_spike_data_map().

Here is the caller graph for this function:

◆ collect_compressible_sources()

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

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

◆ compute_buffer_pos_for_unique_secondary_sources()

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

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

◆ disable_connection()

void nest::SourceTable::disable_connection ( const size_t  tid,
const synindex  syn_id,
const size_t  lcid 
)
inline

Marks entry in sources_ at given position as disabled.

References sources_.

Referenced by nest::ConnectionManager::disconnect().

Here is the caller graph for this function:

◆ dump_compressed_spike_data()

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

Here is the call graph for this function:

◆ dump_compressible_sources()

void nest::SourceTable::dump_compressible_sources ( ) const

References compressible_sources_, FULL_LOGGING_ONLY, nest::kernel(), and nest::KernelManager::write_to_dump().

Here is the call graph for this function:

◆ dump_sources()

void nest::SourceTable::dump_sources ( ) const

References FULL_LOGGING_ONLY, nest::kernel(), sources_, and nest::KernelManager::write_to_dump().

Here is the call graph for this function:

◆ fill_compressed_spike_data()

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

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

◆ finalize()

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

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

◆ find_first_source()

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.

Returns
local connection id (lcid) or invalid_index
Note
For compressed spikes, it uses binary search, otherwise linear search.

References nest::Source::get_node_id(), nest::Source::is_disabled(), nest::kernel(), and sources_.

Referenced by nest::ConnectionManager::find_connection(), and nest::ConnectionManager::get_targets().

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

◆ find_maximal_position()

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

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

◆ get_next_target_data()

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 
)

◆ get_node_id()

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

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

◆ get_source_node_ids()

void nest::SourceTable::get_source_node_ids ( const size_t  tid,
const synindex  syn_id,
const std::vector< size_t > &  source_lcids,
std::vector< size_t > &  sources 
)
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_().

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

◆ get_thread_local_sources()

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

Here is the caller graph for this function:

◆ initialize()

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

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

◆ is_cleared()

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

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

◆ next_entry_has_same_source_()

bool nest::SourceTable::next_entry_has_same_source_ ( const SourceTablePosition &  current_position,
const Source &  current_source 
) const
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().

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

◆ no_targets_to_process()

void nest::SourceTable::no_targets_to_process ( const size_t  tid)
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().

Here is the caller graph for this function:

◆ num_unique_sources()

size_t nest::SourceTable::num_unique_sources ( const size_t  tid,
const synindex  syn_id 
) const
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().

Here is the caller graph for this function:

◆ pack_source_node_id_and_syn_id()

size_t nest::SourceTable::pack_source_node_id_and_syn_id ( const size_t  source_node_id,
const synindex  syn_id 
) const
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().

Here is the caller graph for this function:

◆ populate_target_data_fields_()

bool nest::SourceTable::populate_target_data_fields_ ( const SourceTablePosition &  current_position,
const Source &  current_source,
const size_t  source_rank,
TargetData &  next_target_data 
) const
private

◆ previous_entry_has_same_source_()

bool nest::SourceTable::previous_entry_has_same_source_ ( const SourceTablePosition &  current_position,
const Source &  current_source 
) const
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().

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

◆ reject_last_target_data()

void nest::SourceTable::reject_last_target_data ( const size_t  tid)
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().

Here is the caller graph for this function:

◆ remove_disabled_sources()

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

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

◆ reset_entry_point()

void nest::SourceTable::reset_entry_point ( const size_t  tid)
inline

Resets saved_positions_ to end of sources_.

References saved_positions_, and sources_.

Referenced by nest::ConnectionManager::reset_source_table_entry_point().

Here is the caller graph for this function:

◆ reset_processed_flags()

void nest::SourceTable::reset_processed_flags ( const size_t  tid)
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().

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

◆ resize_compressible_sources()

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

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

◆ resize_sources()

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

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

◆ restore_entry_point()

void nest::SourceTable::restore_entry_point ( const size_t  tid)
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().

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

◆ save_entry_point()

void nest::SourceTable::save_entry_point ( const size_t  tid)
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().

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

◆ source_should_be_processed_()

bool nest::SourceTable::source_should_be_processed_ ( const size_t  rank_start,
const size_t  rank_end,
const Source &  source 
) const
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().

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

Friends And Related Symbol Documentation

◆ ConnectionManager

friend class ConnectionManager
friend

Member Data Documentation

◆ compressed_spike_data_map_

std::vector< std::map< size_t, CSDMapEntry > > nest::SourceTable::compressed_spike_data_map_
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().

◆ compressible_sources_

std::vector< std::vector< std::map< size_t, SpikeData > > > nest::SourceTable::compressible_sources_
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().

◆ current_positions_

std::vector< SourceTablePosition > nest::SourceTable::current_positions_
private

◆ is_cleared_

PerThreadBoolIndicator nest::SourceTable::is_cleared_
private

Whether the 3D structure has been deleted.

Referenced by clear(), finalize(), initialize(), and is_cleared().

◆ min_deleted_elements_

const size_t nest::SourceTable::min_deleted_elements_ = 1000000
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.

See also
SourceTable::clean()

◆ saved_entry_point_

PerThreadBoolIndicator nest::SourceTable::saved_entry_point_
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().

◆ saved_positions_

std::vector< SourceTablePosition > nest::SourceTable::saved_positions_
private

◆ sources_


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