Skip to content

Commit

Permalink
Merge pull request #2658 from heplesser/make-bad-threads-error
Browse files Browse the repository at this point in the history
Make it an error to set multiple threads if NEST was built without thread support
  • Loading branch information
heplesser committed Apr 13, 2023
2 parents 444bfba + 957c0e8 commit d5420fd
Show file tree
Hide file tree
Showing 26 changed files with 77 additions and 3 deletions.
4 changes: 1 addition & 3 deletions nestkernel/vp_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ nest::VPManager::set_status( const DictionaryDatum& d )

if ( force_singlethreading_ and n_threads > 1 )
{
std::string msg = "Multithreading requested, but unavailable. Using a single thread.";
LOG( M_WARNING, "VPManager::set_status", msg );
n_threads = 1;
throw BadProperty( "This installation of NEST was built without support for multiple threads." );
}

// We only want to act if new values differ from the old
Expand Down
2 changes: 2 additions & 0 deletions testsuite/mpitests/test_get_nodes.sli
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Description:
Author: August 2019, Stine B. Vennemo
*/

skip_if_not_threaded

(unittest) run
/unittest using

Expand Down
2 changes: 2 additions & 0 deletions testsuite/mpitests/test_sinusoidal_poisson_generator_5.sli
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Author: December 2012, May 2013, Plesser, based on test_poisson_generator.sli
See also: test_sinusoidal_poisson_generator_{1,2,3,4,6}, test_sinusoidal_poisson_generator_nostat
*/

skip_if_not_threaded

(unittest) run
/unittest using

Expand Down
2 changes: 2 additions & 0 deletions testsuite/mpitests/test_sinusoidal_poisson_generator_6.sli
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Author: December 2012, May 2013, Plesser, based on test_poisson_generator.sli
See also: test_sinusoidal_poisson_generator_{1,2,3,4,5}, test_sinusoidal_poisson_generator_nostat
*/

skip_if_not_threaded

(unittest) run
/unittest using

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*
*/

skip_if_not_threaded

(unittest) run
/unittest using

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*
*/

skip_if_not_threaded

(unittest) run
/unittest using

Expand Down
2 changes: 2 additions & 0 deletions testsuite/pytests/mpi/2/test_connect_arrays_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
HAVE_MPI4PY = False

HAVE_MPI = nest.ll_api.sli_func("statusdict/have_mpi ::")
HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@unittest.skipIf(not HAVE_MPI4PY, 'mpi4py is not available')
class TestConnectArraysMPICase(unittest.TestCase):
"""
Expand Down
5 changes: 5 additions & 0 deletions testsuite/pytests/mpi/4/test_consistent_local_vps.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

import unittest
import nest


HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
def test_consistent_local_vps():
"""
Test local_vps field of kernel status.
Expand Down
4 changes: 4 additions & 0 deletions testsuite/pytests/test_connect_all_to_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import nest


HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@nest.ll_api.check_stack
class TestAllToAll(connect_test_base.ConnectTestBase):

Expand Down
4 changes: 4 additions & 0 deletions testsuite/pytests/test_connect_array_fixed_outdegree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
import numpy


HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@nest.ll_api.check_stack
class ConnectArrayFixedOutdegreeTestCase(unittest.TestCase):
"""Tests of connections with fixed outdegree and parameter arrays"""
Expand Down
1 change: 1 addition & 0 deletions testsuite/pytests/test_connect_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def test_connect_arrays_different_weights_delays(self):
np.testing.assert_array_almost_equal(conns.weight, weights)
np.testing.assert_array_almost_equal(conns.delay, delays)

@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
def test_connect_arrays_threaded(self):
"""Connecting NumPy arrays, threaded"""
nest.local_num_threads = 2
Expand Down
5 changes: 5 additions & 0 deletions testsuite/pytests/test_connect_fixed_indegree.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
import nest


HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@nest.ll_api.check_stack
class TestFixedInDegree(connect_test_base.ConnectTestBase):

# specify connection pattern and specific params
Expand Down
5 changes: 5 additions & 0 deletions testsuite/pytests/test_connect_fixed_outdegree.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
import nest


HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@nest.ll_api.check_stack
class TestFixedOutDegree(connect_test_base.ConnectTestBase):

# specify connection pattern and specific params
Expand Down
5 changes: 5 additions & 0 deletions testsuite/pytests/test_connect_fixed_total_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
import nest


HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@nest.ll_api.check_stack
class TestFixedTotalNumber(connect_test_base.ConnectTestBase):

# specify connection pattern and specific params
Expand Down
5 changes: 5 additions & 0 deletions testsuite/pytests/test_connect_one_to_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
import nest


HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@nest.ll_api.check_stack
class TestOneToOne(connect_test_base.ConnectTestBase):

# specify connection pattern
Expand Down
5 changes: 5 additions & 0 deletions testsuite/pytests/test_connect_pairwise_bernoulli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
import nest


HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@nest.ll_api.check_stack
class TestPairwiseBernoulli(connect_test_base.ConnectTestBase):

# specify connection pattern and specific params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
import nest


HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@nest.ll_api.check_stack
class TestSymmetricPairwiseBernoulli(connect_test_base.ConnectTestBase):

# sizes of source-, target-population and connection probability for
Expand Down
3 changes: 3 additions & 0 deletions testsuite/pytests/test_recording_backend_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import unittest
import nest

HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
class TestRecordingBackendASCII(unittest.TestCase):

def testAAAOverwriteFiles(self):
Expand Down
3 changes: 3 additions & 0 deletions testsuite/pytests/test_recording_backend_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import unittest
import nest

HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
class TestRecordingBackendMemory(unittest.TestCase):

def testEventsDict(self):
Expand Down
2 changes: 2 additions & 0 deletions testsuite/pytests/test_weight_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import numpy as np

HAVE_GSL = nest.ll_api.sli_func("statusdict/have_gsl ::")
HAVE_OPENMP = nest.ll_api.sli_func("is_threaded")


@unittest.skipIf(not HAVE_OPENMP, 'NEST was compiled without multi-threading')
@nest.ll_api.check_stack
class WeightRecorderTestCase(unittest.TestCase):
"""Tests for the Weight Recorder"""
Expand Down
2 changes: 2 additions & 0 deletions testsuite/regressiontests/issue-1640.sli
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Author: Håkon Mørk
FirstVersion: August 2020
*/

skip_if_not_threaded

(unittest) run
/unittest using

Expand Down
2 changes: 2 additions & 0 deletions testsuite/regressiontests/ticket-643.sli
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

*/

skip_if_not_threaded

(unittest) run
/unittest using

Expand Down
2 changes: 2 additions & 0 deletions testsuite/regressiontests/ticket-881.sli
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Author: Hans Ekkehard Plesser
*/


skip_if_not_threaded

(unittest) run
/unittest using

Expand Down
2 changes: 2 additions & 0 deletions testsuite/unittests/test_GetConnections.sli
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@


% eighth test: check static synapses on four threads
skip_if_not_threaded

{
<< >> begin
ResetKernel
Expand Down
2 changes: 2 additions & 0 deletions testsuite/unittests/test_sinusoidal_gamma_generator.sli
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ M_ERROR setverbosity
} assert_or_die
(passed 4b) ==

skip_if_not_threaded

% test 4c: two threads, one spike train for all targets
{
false 2 4 test4_function
Expand Down
2 changes: 2 additions & 0 deletions testsuite/unittests/test_sinusoidal_poisson_generator.sli
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ M_ERROR setverbosity
} assert_or_die
(passed 4b) ==

skip_if_not_threaded

% test 4c: two threads, one spike train for all targets
{
false 2 4 test4_function
Expand Down

0 comments on commit d5420fd

Please sign in to comment.