/*
 *  issue-521.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-521 - *_hpc connections return local id instead of global id of target neuron

   Ensure that *_hpc connections also return correct global target GID on GetConnections.

   FirstVersion: 04/2017
   Author: Till Schumann
 */

(unittest) run
/unittest using

skip_if_not_threaded

/test_targets
{
dup /threads Set
ResetKernel
0 << /local_num_threads threads >> SetStatus


% create set of neurons
/iaf_psc_alpha 20 Create

% connect two neurons (prime number to increase variations of thread placement)
5 13 /static_synapse Connect
5 13 /static_synapse_hpc Connect

% store info from target neuron for comparison 
13 GetStatus /target_dict Set

<< >> GetConnections 0 get GetStatus /conn_dict Set
<< >> GetConnections 1 get GetStatus /conn_hpc_dict Set


/* normal connection should contain global_id as target */
conn_dict /target get target_dict /global_id get eq assert_or_die

/* same for hpc connection */
conn_hpc_dict /target get target_dict /global_id get eq assert_or_die


} def


/* test runs with different number of threads */
1 test_targets
2 test_targets
4 test_targets 
8 test_targets
16 test_targets

endusing
