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

Prohibit DataConnect in multithreaded mode. #776

Merged
merged 2 commits into from Jul 3, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions nestkernel/nestmodule.cpp
Expand Up @@ -864,6 +864,12 @@ NestModule::DataConnect_i_D_sFunction::execute( SLIInterpreter* i ) const
{
i->assert_stack_load( 3 );

if ( kernel().vp_manager.get_num_threads() > 1 )
{
throw KernelException(
"DataConnect can not be used with multiple threads" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot

}

const index source = getValue< long >( i->OStack.pick( 2 ) );
DictionaryDatum params = getValue< DictionaryDatum >( i->OStack.pick( 1 ) );
const Name synmodel_name = getValue< std::string >( i->OStack.pick( 0 ) );
Expand Down Expand Up @@ -922,6 +928,13 @@ void
NestModule::DataConnect_aFunction::execute( SLIInterpreter* i ) const
{
i->assert_stack_load( 1 );

if ( kernel().vp_manager.get_num_threads() > 1 )
{
throw KernelException(
"DataConnect can not be used with multiple threads" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot

}

const ArrayDatum connectome = getValue< ArrayDatum >( i->OStack.top() );

kernel().connection_manager.data_connect_connectome( connectome );
Expand Down
74 changes: 74 additions & 0 deletions testsuite/regressiontests/issue-527.sli
@@ -0,0 +1,74 @@
/*
* issue-527.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-527

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

Description:
This test ensures that NEST raises an error if the user tries to use
DataConnect in multithreaded mode.

Author: Stine B. Vennemo
FirstVersion: July 2017
SeeAlso:
*/

(unittest) run
/unittest using

skip_if_not_threaded

/test_threaded_DataConnect
{
dup /threads Set
ResetKernel
0 << /local_num_threads threads /total_num_virtual_procs threads >> SetStatus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to set total_num_virtual_procs, that is set automatically based on local_num_threads.


% Create set of neurons
/A /iaf_psc_alpha 1 Create def
/B /iaf_psc_alpha 1000 Create def

% Make target array
/t [A 1 add 1.0 mul B 1.0 mul] Range def

% Make weight array
/w [1000] 1.0 LayoutArray def

% Make delay array
/d [1000] 1.0 LayoutArray def

% Connect using DataConnect
A << /target t /weight w /delay d >> /static_synapse DataConnect

} def

/* test runs with different number of threads */
[2 16 2] Range
{
{ test_threaded_DataConnect } fail_or_die
}
forall

endusing