Skip to content

Commit

Permalink
Merge pull request #666 from heplesser/fix-665-topoconnect
Browse files Browse the repository at this point in the history
Connecting to layers of recording devices now works properly
  • Loading branch information
terhorstd authored Mar 1, 2017
2 parents 8069e3b + d87ee7c commit 5003e2b
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ if [ "$xSTATIC_ANALYSIS" = "1" ] ; then
CLANG_FORMAT=clang-format
PEP8=pep8
PERFORM_VERA=true
PERFORM_CPPCHECK=true
PERFORM_CPPCHECK=false
PERFORM_CLANG_FORMAT=true
PERFORM_PEP8=true

Expand Down
2 changes: 1 addition & 1 deletion extras/static_code_analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ for f in $FILE_NAMES; do
IGNORES=$PEP8_IGNORES
;;
esac
if ! pep8_result=`$PEP8 --ignore=$PEP8_IGNORES $f` ; then
if ! pep8_result=`$PEP8 --ignore=$IGNORES $f` ; then
printf '%s\n' "$pep8_result" | while IFS= read -r line
do
print_msg "MSGBLD0195: " "[PEP8] $line"
Expand Down
10 changes: 8 additions & 2 deletions nestkernel/nestmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ NestModule::Create_l_iFunction::execute( SLIInterpreter* i ) const
// extract arguments
const long n_nodes = getValue< long >( i->OStack.pick( 0 ) );
if ( n_nodes <= 0 )
{
throw RangeCheck();
}

const std::string modname = getValue< std::string >( i->OStack.pick( 1 ) );

Expand Down Expand Up @@ -792,7 +794,9 @@ NestModule::DataConnect_i_D_sFunction::execute( SLIInterpreter* i ) const
const Token synmodel =
kernel().model_manager.get_synapsedict()->lookup( synmodel_name );
if ( synmodel.empty() )
{
throw UnknownSynapseType( synmodel_name.toString() );
}
const index synmodel_id = static_cast< index >( synmodel );

kernel().connection_manager.data_connect_single(
Expand Down Expand Up @@ -1091,8 +1095,6 @@ NestModule::NumProcessesFunction::execute( SLIInterpreter* i ) const
Execute this script with
mpirun -np 1 nest example.sli
Availability: NEST 2.2
Author: Susanne Kunkel
FirstVersion: July 2011
Expand Down Expand Up @@ -1179,9 +1181,13 @@ NestModule::TimeCommunication_i_i_bFunction::execute( SLIInterpreter* i ) const

double time = 0.0;
if ( offgrid )
{
time = kernel().mpi_manager.time_communicate_offgrid( num_bytes, samples );
}
else
{
time = kernel().mpi_manager.time_communicate( num_bytes, samples );
}

i->OStack.pop( 3 );
i->OStack.push( time );
Expand Down
160 changes: 160 additions & 0 deletions testsuite/regressiontests/issue-665.sli
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* issue-665.sli
*
* This file is part of NEST.
*
* Copyright (C) 2004 The NEST Initiative
*
* NEST is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* NEST is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
*/


/* BeginDocumentation
Name: testsuite::issue-665

Synopsis: (issue-665) run -> NEST exits if test fails

Description:
This test ensures that ConnectLayers correctly handles devices with thread
siblings as sources and targets.

Author: Hans Ekkehard Plesser
FirstVersion: February 2017
SeeAlso:
*/

(unittest) run
/unittest using

is_threaded not { exit_test_gracefully } if

% First set of tests: Single generator to neuron layer
/gen_to_layer_test
{
/connspec Set

ResetKernel
0 << /local_num_threads 4 >> SetStatus

/pgl
<< /elements /poisson_generator
/rows 1 /columns 1 >>
CreateLayer def

/nnl
<< /elements /iaf_psc_alpha
/rows 2 /columns 2 >>
CreateLayer def

pgl nnl connspec ConnectLayers

/src pgl GetGlobalLeaves 1 Take def
/tgts nnl GetGlobalLeaves Sort def

/conns << /source src >> GetConnections def
/ctgts conns { cva 1 get } Map Sort def

tgts ctgts eq
}
def

{
<< /connection_type /convergent >> gen_to_layer_test
}
assert_or_die

{
<< /connection_type /divergent >> gen_to_layer_test
}
assert_or_die

{
% one incoming connection to each neuron in layer
<< /connection_type /convergent
/number_of_connections 1 >> gen_to_layer_test
}
assert_or_die

{
% four outgoing connections, one to each neuron in layer
% prohibit multapses to ensure consistent result
<< /connection_type /divergent
/number_of_connections 4
/allow_multapses false >> gen_to_layer_test
}
assert_or_die

% -----------------------------------------------

% Second set of tests: Neuron layer to single detector
/layer_to_det_test
{
/connspec Set

ResetKernel
0 << /local_num_threads 4 >> SetStatus

/nnl
<< /elements /iaf_psc_alpha
/rows 2 /columns 2 >>
CreateLayer def

/sdl
<< /elements /spike_detector
/rows 1 /columns 1 >>
CreateLayer def

nnl sdl connspec ConnectLayers

/tgt sdl GetGlobalLeaves 1 Take def
/srcs nnl GetGlobalLeaves Sort def

/conns << /target tgt >> GetConnections def
/csrcs conns { cva 0 get } Map Sort def

srcs csrcs eq
}
def

{
<< /connection_type /convergent >> layer_to_det_test
}
assert_or_die

{
<< /connection_type /divergent >> layer_to_det_test
}
fail_or_die
clear

{
% four incoming connections, one to each neuron in layer
% prohibit multapses to ensure consistent result
<< /connection_type /convergent
/number_of_connections 4
/allow_multapses false >> layer_to_det_test
}
fail_or_die
clear

{
% one outgoing connection from each neuron in layer
<< /connection_type /divergent
/number_of_connections 1 >> layer_to_det_test
}
fail_or_die
clear

endusing
Loading

0 comments on commit 5003e2b

Please sign in to comment.