Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt cache thrashing fix for low synapse count vector access #3113

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion nestkernel/connection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ nest::ConnectionManager::initialize( const bool reset_kernel )
std::vector< DelayChecker > tmp( kernel().vp_manager.get_num_threads() );
delay_checkers_.swap( tmp );

std::vector< std::vector< size_t > > tmp2( kernel().vp_manager.get_num_threads(), std::vector< size_t >() );
std::vector< aligned_vector< size_t > > tmp2( kernel().vp_manager.get_num_threads(), aligned_vector< size_t >() );
num_connections_.swap( tmp2 );
}

Expand Down
23 changes: 22 additions & 1 deletion nestkernel/connection_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
#include "manager_interface.h"
#include "stopwatch.h"

#ifdef HAVE_BOOST
#ifdef __cpp_lib_hardware_interference_size
using std::hardware_destructive_interference_size;
#else
constexpr std::size_t hardware_destructive_interference_size = 64;
#endif
#include <boost/align/aligned_allocator.hpp>
#include <new>
#endif

// Includes from nestkernel:
#include "conn_builder.h"
#include "connection_id.h"
Expand All @@ -52,6 +62,16 @@

namespace nest
{

#ifdef HAVE_BOOST
template < typename T >
using aligned_vector =
std::vector< T, boost::alignment::aligned_allocator< T, hardware_destructive_interference_size > >;
#else
template < typename T >
using aligned_vector = std::vector< T >;
#endif

class GenericConnBuilderFactory;
class spikecounter;
class Node;
Expand Down Expand Up @@ -633,7 +653,8 @@ class ConnectionManager : public ManagerInterface
* A structure to count the number of synapses of a specific
* type. Arranged in a 2d structure: threads|synapsetypes.
*/
std::vector< std::vector< size_t > > num_connections_;

std::vector< aligned_vector< size_t > > num_connections_;

DictionaryDatum connruledict_; //!< Dictionary for connection rules.

Expand Down
Loading