Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a3f5369
Fix issue: #3532
med-ayssar Jul 20, 2025
4271659
Make clang-format happy
med-ayssar Jul 20, 2025
25b7240
Make clang-format happy
med-ayssar Jul 20, 2025
7617de0
Avoid copies of Source
med-ayssar Jul 20, 2025
02c2055
Make clang-format happy #3
med-ayssar Jul 20, 2025
93a0798
Disable my Nvim clangformat-plugin
med-ayssar Jul 20, 2025
94cdccb
Use std::find_if instead of custom function
med-ayssar Sep 20, 2025
0015a85
Apply clang format
med-ayssar Sep 20, 2025
ae566f0
Merge branch 'master' into 3532
med-ayssar Sep 20, 2025
3454d36
Make clang happy again
med-ayssar Sep 20, 2025
bbf3baf
Use custom compare method for std::lower_bound
med-ayssar Sep 20, 2025
9c67d5a
Fix clang-format again
med-ayssar Sep 20, 2025
28e50b4
Fix format again
med-ayssar Sep 20, 2025
eead8c3
Fix space
med-ayssar Sep 20, 2025
d138558
Fix std::lower_bound comp predicate
med-ayssar Sep 20, 2025
e30af4f
Fix the logic behind std::lower_bound with deleted connection
med-ayssar Sep 21, 2025
8564c57
Fix indentation
med-ayssar Sep 21, 2025
ed28503
Adjust the function to be more compact and simpler
ayssar100 Sep 22, 2025
06e36f5
Fix compiler errors
med-ayssar Sep 22, 2025
7610668
Compare Iter with origin
med-ayssar Sep 22, 2025
e99e03c
Fix find_connection implementation for use_compressed_spike=OFF
med-ayssar Sep 24, 2025
f8170d5
Add pytest
med-ayssar Sep 24, 2025
007501f
Format files
med-ayssar Sep 24, 2025
a344c57
Fix copyright header
med-ayssar Sep 24, 2025
097babd
Sort imports
med-ayssar Sep 24, 2025
0c4048b
Add bit flag for disabled sources
med-ayssar Sep 25, 2025
52460b8
Activate Source again on changing node_id
med-ayssar Sep 25, 2025
b3941fe
Avoid double-delete of ptr
med-ayssar Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nestkernel/connection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ nest::ConnectionManager::find_connection( const size_t tid,
{
// lcid will hold the position of the /first/ connection from node
// snode_id to any local node, or be invalid
size_t lcid = source_table_.find_first_source( tid, syn_id, snode_id );
size_t lcid = source_table_.find_first_source( tid, syn_id, snode_id, use_compressed_spikes() );
if ( lcid == invalid_index )
{
return invalid_index;
Expand Down Expand Up @@ -1428,7 +1428,7 @@ nest::ConnectionManager::get_targets( const std::vector< size_t >& sources,
{
for ( size_t i = 0; i < sources.size(); ++i )
{
const size_t start_lcid = source_table_.find_first_source( tid, syn_id, sources[ i ] );
const size_t start_lcid = source_table_.find_first_source( tid, syn_id, sources[ i ], use_compressed_spikes() );
if ( start_lcid != invalid_index )
{
connections_[ tid ][ syn_id ]->get_target_node_ids( tid, start_lcid, post_synaptic_element, targets[ i ] );
Expand Down
48 changes: 33 additions & 15 deletions nestkernel/source_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

// Includes from nestkernel:
Expand Down Expand Up @@ -300,7 +301,10 @@
* Finds the first entry in sources_ at the given thread id and
* synapse type that is equal to snode_id.
*/
size_t find_first_source( const size_t tid, const synindex syn_id, const size_t snode_id ) const;
size_t find_first_source( const size_t tid,
const synindex syn_id,
const size_t snode_id,
bool using_compressed_spikes = false ) const;

/**
* Marks entry in sources_ at given position as disabled.
Expand Down Expand Up @@ -471,27 +475,41 @@
}

inline size_t
SourceTable::find_first_source( const size_t tid, const synindex syn_id, const size_t snode_id ) const
SourceTable::find_first_source( const size_t tid,
const synindex syn_id,
const size_t snode_id,
bool using_compressed_spikes /* default = false */ ) const
{
// binary search in sorted sources
const BlockVector< Source >::const_iterator begin = sources_[ tid ][ syn_id ].begin();
const BlockVector< Source >::const_iterator end = sources_[ tid ][ syn_id ].end();
BlockVector< Source >::const_iterator it = std::lower_bound( begin, end, Source( snode_id, true ) );

// source found by binary search could be disabled, iterate through
// sources until a valid one is found
while ( it != end )

const auto source_begin = sources_[ tid ][ syn_id ].cbegin();

Check failure on line 484 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_macos (macos-latest, clang, openmp, mpi, python, gsl, ltdl, boost, hdf5, optimize, warning)

no member named 'cbegin' in 'BlockVector<nest::Source>'

Check failure on line 484 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, openmp, python, gsl, ltdl, boost, optimize, warning)

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cbegin’; did you mean ‘begin’?

Check failure on line 484 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, boost, optimize, warning)

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cbegin’; did you mean ‘begin’?

Check failure on line 484 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, optimize, warning)

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cbegin’; did you mean ‘begin’?

Check failure on line 484 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, mpi, python, gsl, ltdl, boost, optimize, warning)

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cbegin’; did you mean ‘begin’?

Check failure on line 484 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, openmp, mpi, python, gsl, ltdl, boost, hdf5, sionlib, libneurosim...

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cbegin’; did you mean ‘begin’?
const auto source_end = sources_[ tid ][ syn_id ].cend();

Check failure on line 485 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_macos (macos-latest, clang, openmp, mpi, python, gsl, ltdl, boost, hdf5, optimize, warning)

no member named 'cend' in 'BlockVector<nest::Source>'

Check failure on line 485 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, openmp, python, gsl, ltdl, boost, optimize, warning)

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cend’; did you mean ‘end’?

Check failure on line 485 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, boost, optimize, warning)

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cend’; did you mean ‘end’?

Check failure on line 485 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, optimize, warning)

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cend’; did you mean ‘end’?

Check failure on line 485 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, mpi, python, gsl, ltdl, boost, optimize, warning)

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cend’; did you mean ‘end’?

Check failure on line 485 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, openmp, mpi, python, gsl, ltdl, boost, hdf5, sionlib, libneurosim...

‘const value_type’ {aka ‘const class BlockVector<nest::Source>’} has no member named ‘cend’; did you mean ‘end’?

const Source selected_source { snode_id, /* is_primary */ true };

auto find_source = []( auto begin, auto end, const Source& value ) -> size_t
{
if ( it->get_node_id() == snode_id and not it->is_disabled() )
iter = std::find_if( begin,

Check failure on line 491 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_macos (macos-latest, clang, openmp, mpi, python, gsl, ltdl, boost, hdf5, optimize, warning)

use of undeclared identifier 'iter'

Check failure on line 491 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, openmp, python, gsl, ltdl, boost, optimize, warning)

‘iter’ was not declared in this scope

Check failure on line 491 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, boost, optimize, warning)

‘iter’ was not declared in this scope

Check failure on line 491 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, optimize, warning)

‘iter’ was not declared in this scope

Check failure on line 491 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, mpi, python, gsl, ltdl, boost, optimize, warning)

‘iter’ was not declared in this scope

Check failure on line 491 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, openmp, mpi, python, gsl, ltdl, boost, hdf5, sionlib, libneurosim...

‘iter’ was not declared in this scope
end,
[ &value ]( const Source& src ) { return src.get_node_id() == value.get_node_id() && not src.is_disabled(); } );
if ( iter != end )

Check failure on line 494 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_macos (macos-latest, clang, openmp, mpi, python, gsl, ltdl, boost, hdf5, optimize, warning)

use of undeclared identifier 'iter'
{
const size_t lcid = it - begin;
const size_t lcid = iter - begin;

Check failure on line 496 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_macos (macos-latest, clang, openmp, mpi, python, gsl, ltdl, boost, hdf5, optimize, warning)

use of undeclared identifier 'iter'
return lcid;
}
++it;
// no enabled entry with this snode ID found
return invalid_index;
};

auto iter = source_begin;

if ( using_compressed_spikes )
{
auto iter = std::lower_bound( iter, source_end, selected_source );

Check failure on line 507 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_macos (macos-latest, clang, openmp, mpi, python, gsl, ltdl, boost, hdf5, optimize, warning)

variable 'iter' declared with deduced type 'auto' cannot appear in its own initializer

Check failure on line 507 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, openmp, python, gsl, ltdl, boost, optimize, warning)

use of ‘iter’ before deduction of ‘auto’

Check failure on line 507 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, boost, optimize, warning)

use of ‘iter’ before deduction of ‘auto’

Check failure on line 507 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, optimize, warning)

use of ‘iter’ before deduction of ‘auto’

Check failure on line 507 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, mpi, python, gsl, ltdl, boost, optimize, warning)

use of ‘iter’ before deduction of ‘auto’

Check failure on line 507 in nestkernel/source_table.h

View workflow job for this annotation

GitHub Actions / build_linux (ubuntu-22.04, gcc, openmp, mpi, python, gsl, ltdl, boost, hdf5, sionlib, libneurosim...

use of ‘iter’ before deduction of ‘auto’
}

// no enabled entry with this snode ID found
return invalid_index;
auto ret = find_source( iter, source_end, selected_source );

return ret;
}

inline void
Expand Down
Loading