/*
 *  test_thread_local_ids.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::test_thread_local_ids - test that thread-local ids are set correctly 

Synopsis: (test_thread_local_ids.sli) run -> dies if assertion fails

Description:
Ensures that thread-local IDs are set correctly on multithreaded simulations.

Author: Plesser, Ippen
FirstVersion: 2014-11-21
*/

(unittest) run
/unittest using

skip_if_not_threaded

M_ERROR setverbosity

{
  ResetKernel
  0 << /local_num_threads 4 >> SetStatus
  
  /iaf_neuron 4 Create ; 
  [ 1 ] [ 2 ] /all_to_all << /model /static_synapse_hpc >> Connect
   
  [ 4 ] { [[ /thread_local_id ]] get } Table dup ==
  [ [0] [0] [0] [0] ]
  eq
} assert_or_die

{
  ResetKernel
  0 << /local_num_threads 4 >> SetStatus

  /iaf_neuron 4 Create ; 
  10 Simulate

  [ 4 ] { [[ /thread_local_id ]] get } Table dup ==
  [ [0] [0] [0] [0] ]
  eq
} assert_or_die

endusing
