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

Modernize random number generator setup #1549

Merged
merged 172 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 163 commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
f95b235
First draft of a new librandom based on C++11 RNG facilities.
jougs Jun 22, 2018
0511b4f
Add TODO
jougs Oct 9, 2019
7f6ca30
Add todos after meeting with @heplesser
jougs Nov 29, 2019
aa9e64d
Merge branch 'nest-3' into feature/cpp11-librandom
jougs Dec 6, 2019
e39e16c
Merge branch 'master' of github.com:nest/nest-simulator into feature/…
jougs Feb 7, 2020
4231c1a
Undo line break
jougs Feb 11, 2020
dbe8f4c
RNG template class
hakonsbm Feb 11, 2020
607b5d3
Removed RDist class
hakonsbm Feb 11, 2020
149ee79
Merge pull request #45 from hakonsbm/feature/cpp11-librandom
jougs Feb 11, 2020
1bc8078
Added ulrand to RNG class
hakonsbm Feb 14, 2020
2c417f7
Merge pull request #46 from hakonsbm/feature/cpp11-librandom
jougs Feb 14, 2020
31670e8
Replacing librandom by C++11 random code
jougs Feb 18, 2020
962d339
Fixing include order and labeling
jougs Feb 18, 2020
14f29f7
Removed random ConnParameter
hakonsbm Feb 26, 2020
fa6ffca
Using unsigned long as RNG result type
hakonsbm Feb 26, 2020
5fc5e2b
Adjusted ulrand to be in range [0, N-1]
hakonsbm Feb 26, 2020
b4d7f90
Updated tests for the new generator
hakonsbm Feb 26, 2020
ded02aa
Added distribution wrapper and refactored
hakonsbm Mar 4, 2020
0bb9f8d
Fixed RNG seeding and minor update to RNGs
hakonsbm Mar 5, 2020
ac8ea4f
Updated more tests
hakonsbm Mar 5, 2020
6135c1d
Added uniform_int Parameter
hakonsbm Mar 6, 2020
92f6183
Using thread-local distributions for normal and lognormal parameters
hakonsbm Mar 9, 2020
7cbafa5
Add missing lognormal distribution and UniformIntParameter bits
hakonsbm Mar 9, 2020
1da185b
Minor test adjustment
hakonsbm Mar 10, 2020
72be827
Added statistical connection checking
hakonsbm Mar 10, 2020
ab9ef8f
Broadcasting test data to MPI nodes to keep tests in sync over nodes
hakonsbm Mar 11, 2020
e18185e
Increase number of runs in two level test for more accurate results
hakonsbm Mar 11, 2020
d7c5606
Removed unused names
hakonsbm Mar 11, 2020
984ebc3
Implemented SeedSequence-based seeding scheme.
heplesser Apr 21, 2020
1fb82b4
Merge branch 'master' into hakonsbm_cpp11-librandom
heplesser Apr 21, 2020
61c7a96
Removed some tests that are no longer relevant and updated others.
heplesser Apr 21, 2020
c239c9d
Introduced thread-synced RNGs; renamed global_rng and thread_rng.
heplesser Apr 22, 2020
e2dbcc9
Revised check of rng synchrony.
heplesser Apr 22, 2020
df49bd5
Merge branch 'boost_blockvector_fix' of https://github.com/hakonsbm/n…
heplesser Apr 22, 2020
8dec976
Changed seeds in some tests since seed value 0 is no longer accepted.
heplesser Apr 22, 2020
d224bb2
Updated reference data for one GIF test.
heplesser Apr 23, 2020
b3fd6bc
Merge pull request #30 from heplesser/hakonsbm_cpp11-librandom
hakonsbm Apr 23, 2020
64255ec
Updated reference data for the rest of the GIF tests
hakonsbm Apr 23, 2020
58e27f5
Renamed files and classes related to random number generation.
heplesser Apr 23, 2020
de1dc61
Added 32-bit mt19937 generator, removed ranlux48.
heplesser Apr 24, 2020
431627a
Fixed include path.
heplesser Apr 24, 2020
f23c109
Merge pull request #31 from heplesser/hakonsbm_cpp11-librandom
hakonsbm Apr 24, 2020
2fbbee2
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Apr 24, 2020
247dede
Fix random-related includes.
heplesser Apr 24, 2020
abfe2a1
Renamed thread_[synced,specific] to vp_[synced,specific].
heplesser Apr 24, 2020
6ac443a
Formatting
hakonsbm Apr 24, 2020
604a806
Removed mother_rng and mother_seed from nest names
hakonsbm Apr 24, 2020
89806f3
Removed obsolete rng_manager.cpp.
heplesser Apr 24, 2020
129aa03
Updated documentation for new RNG interface, step 1.
heplesser Apr 24, 2020
6ab8c90
Merge pull request #33 from heplesser/hakonsbm_cpp11-librandom
hakonsbm Apr 24, 2020
6acd520
Adjusted PyNEST tests for the new random generator setup
hakonsbm Apr 28, 2020
01bc37b
Adjusted SLI tests for the new random generator setup
hakonsbm Apr 28, 2020
91a7b6b
Fixed PEP8 issues
hakonsbm Apr 28, 2020
0abeac4
Added section on random number generators
hakonsbm May 4, 2020
bbaa30d
Switched to membrane potential randomisation using Parameters
hakonsbm May 5, 2020
d2f5812
Removed outdated hpc_benchmark example
hakonsbm May 5, 2020
e2ffafe
Updated more SLI examples for the new random number generators
hakonsbm May 6, 2020
bcad66e
Replace std::seed_seq with randutils::seed_seq_fe128 by Melissa O'Neill.
heplesser May 7, 2020
961664e
Moved from smart pointers to dumb pointers for random generators
hakonsbm May 15, 2020
5f103cd
Merge remote-tracking branch 'refs/remotes/nest/master'
hakonsbm May 15, 2020
18be152
Merge branch 'feature/cpp11-librandom' of https://github.com/hakonsbm…
heplesser May 18, 2020
7f06406
Merge pull request #34 from heplesser/hakonsbm_cpp11-librandom
hakonsbm May 18, 2020
1156341
Formatting
hakonsbm Jun 2, 2020
2157fcc
Updated reference values for new random generators one more time
hakonsbm Jun 2, 2020
4761b48
Adjusted tests for new random generators
hakonsbm Jun 2, 2020
b7f37ce
Added randutils to static check exclusion list
hakonsbm Jun 2, 2020
e0e9b8f
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Jun 2, 2020
0110f79
Pass parameter to Poisson distribution in gif_pop_psc_exp
hakonsbm Jun 2, 2020
23afe2a
Update pp_cond_exp_mc_urbanczik model for new random generators
hakonsbm Jun 2, 2020
ecf5426
Updated test to account for ordering of connections
hakonsbm Jun 2, 2020
11eb37d
Adjusted tests further for new random generators
hakonsbm Jun 2, 2020
0ec069b
Adjusted model parameters to avoid numerical instability
hakonsbm Jun 3, 2020
a56b1bd
Added support for Random123 generators
hakonsbm Jun 16, 2020
dc41942
Added PyNEST tests of Random123 generators
hakonsbm Jun 16, 2020
c479505
Merge remote-tracking branch 'refs/remotes/nest/master'
hakonsbm Oct 8, 2020
633cbfe
Adjusted mask to avoid neuron positions at mask boundaries
hakonsbm Oct 8, 2020
7b78af7
Switched to numpy.sum because scipy.sum is deprecated
hakonsbm Oct 8, 2020
f633b78
Merge branch 'feature/cpp11-librandom'
hakonsbm Oct 8, 2020
c60bff8
Using mean of KS tests to make it more reliable
hakonsbm Oct 8, 2020
65d24ab
Merge remote-tracking branch 'origin/feature/cpp11-librandom-random12…
hakonsbm Oct 13, 2020
9905a23
Fixed filename in header
hakonsbm Oct 13, 2020
7a2a270
Added Random123 files to CMakeLists
hakonsbm Oct 13, 2020
7210f2f
Added static code check exceptions for Random123 files
hakonsbm Oct 13, 2020
206b838
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Oct 14, 2020
cc34ea3
Added test of Random123 library to CMake configuration
hakonsbm Oct 20, 2020
a7cc6dc
Updated tests for unsupported Random123 case
hakonsbm Oct 20, 2020
63bd714
Added readme for Random123 tests
hakonsbm Oct 20, 2020
93be5a3
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Oct 20, 2020
32ce16a
Added Random123 tests to be ignored by static checking
hakonsbm Oct 20, 2020
c3eafa6
Added initialization of pointer
hakonsbm Oct 22, 2020
013aaa2
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Oct 22, 2020
c27b588
Move third-party code from libnestutil to thirdparty (compose, randut…
heplesser Nov 10, 2020
35c40e9
Merge pull request #35 from heplesser/feature/cpp11-librandom
hakonsbm Nov 10, 2020
2ab9e0e
Added some documentation on counter-based RNGs
hakonsbm Oct 27, 2020
9443a89
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Nov 10, 2020
e17cead
Started work on RNG guide for NEST 3.
heplesser Nov 10, 2020
9c8673e
Update random_numbers.rst
heplesser Nov 30, 2020
279b49c
Merge branch 'master' into hakonsbm_cpp11-librandom
heplesser Feb 1, 2021
75c93d6
Added mistakenly dropped file
heplesser Feb 1, 2021
25d8d38
Partial adaptation of test_connect_distributions
heplesser Feb 1, 2021
a4c9117
Merge pull request #36 from heplesser/hakonsbm_cpp11-librandom
hakonsbm Feb 1, 2021
c3e87a2
Commented out redundant line from randutils.hpp to avoid endless comp…
heplesser Feb 1, 2021
bb4763a
Fixed warnings
hakonsbm Feb 2, 2021
1bb06cb
Re-removed irrelevant test
hakonsbm Feb 2, 2021
ed19b82
Added function checking parameter for integer output
hakonsbm Feb 2, 2021
48b8f4f
Use long value type only if parameter always returns an integer
hakonsbm Feb 2, 2021
a5f72a0
Updated test to use integer parameter as receptor type
hakonsbm Feb 2, 2021
d77377b
First part of random_numbers doc revision for NEST3.
heplesser Feb 2, 2021
00cc5b3
Do not perform format checking in thirdparty directory
heplesser Feb 3, 2021
469ceef
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Feb 3, 2021
622ec32
Updated siegert neuron test for modernized random number setup
hakonsbm Feb 3, 2021
23ed05c
Merge branch 'feature/cpp11-librandom' of https://github.com/hakonsbm…
heplesser Feb 3, 2021
15f952b
First complete draft of randomness guide for NEST3.
heplesser Feb 3, 2021
7563c59
Merge pull request #37 from heplesser/hakonsbm_cpp11-librandom
hakonsbm Feb 4, 2021
1d8379a
Added examples
hakonsbm Feb 4, 2021
98deaf2
Whitespace cleanup
hakonsbm Feb 4, 2021
f6df0b9
Updated paths ignored for static code analysis
hakonsbm Feb 4, 2021
a1345e7
Corrected path ignored for static code analysis
hakonsbm Feb 4, 2021
05f0a0b
Fixed ignoring of nested directories
hakonsbm Feb 4, 2021
5b95c47
Fixed typo
hakonsbm Feb 4, 2021
69036fe
Removed generated files
hakonsbm Feb 5, 2021
9033960
Added `using` directive to NormalParameter
hakonsbm Feb 5, 2021
9c9578c
Removed topology user manual again
hakonsbm Feb 5, 2021
19d1e75
Explicitly ignore the thirdparty directory when autoformatting C++ files
hakonsbm Feb 5, 2021
b784544
Removed unused import
hakonsbm Feb 5, 2021
cf29b84
Updated libneurosim connection builder for new RNGs
hakonsbm Feb 5, 2021
ca389ca
Improved documentation of SetKernelStatus
heplesser Feb 5, 2021
f70e561
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Feb 5, 2021
54e3768
Apply suggestions from documentation code review
hakonsbm Feb 5, 2021
72e2d01
Whitespace fixes.
heplesser Feb 5, 2021
6fd5abe
Merge pull request #38 from heplesser/hakonsbm_cpp11-librandom
hakonsbm Feb 5, 2021
d53d9de
Apply more documentation suggestions from code review
hakonsbm Feb 5, 2021
4c5d147
Apply suggestions from code review of documentation on RNGs
hakonsbm Feb 12, 2021
63e0869
Added link to random number generators guide
hakonsbm Feb 12, 2021
1471c65
Fixed typo
hakonsbm Feb 12, 2021
cf97db9
Removed unused and unneeded lines from tests
hakonsbm Feb 12, 2021
176db5c
Added and updated comments and documentation
hakonsbm Feb 12, 2021
32fdfdb
Updated SLI examples
hakonsbm Feb 12, 2021
5ba9544
Alphabetization
hakonsbm Feb 12, 2021
a86ebc4
Removed duplicate entry
hakonsbm Feb 12, 2021
8bafeaa
Added test_random123 to test_all script
hakonsbm Feb 12, 2021
e7598d1
Minor C++ changes
hakonsbm Feb 12, 2021
5eb7e06
Removed TODOs that will be converted to issues
hakonsbm Feb 12, 2021
3889f73
Removed unneeded comment
hakonsbm Feb 12, 2021
adac700
Removed whitespace
hakonsbm Feb 12, 2021
5d93f3e
Apply suggestions from code review
hakonsbm Feb 12, 2021
701ec5d
Removed commented out code
hakonsbm Feb 12, 2021
250940c
Clarified sentence
hakonsbm Feb 15, 2021
2a46989
Reverted erroneous variable name change
hakonsbm Feb 16, 2021
fe35acc
Removed unneeded workaround
hakonsbm Feb 16, 2021
9f767e5
Added comments
hakonsbm Feb 16, 2021
6530f6c
Clarified "don't do this in python" message and fixed heading.
heplesser Feb 17, 2021
d38b2de
Fixed typo
hakonsbm Feb 18, 2021
5dd3805
Merge pull request #39 from heplesser/hakonsbm_cpp11-librandom
hakonsbm Feb 18, 2021
23749d3
Added more documentation and comment
hakonsbm Feb 18, 2021
e96a417
Fixed typo
hakonsbm Feb 18, 2021
e8279f1
Corrected test typo
hakonsbm Feb 18, 2021
abb8dcc
Clarified variable comment
hakonsbm Feb 18, 2021
2567442
Removed unneeded comment
hakonsbm Feb 18, 2021
95b28cb
Changed from unneeded updateValue to just checking if name is known
hakonsbm Feb 18, 2021
5af6664
Update dictionary entry description
hakonsbm Feb 18, 2021
79f16b9
Updated comments
hakonsbm Feb 23, 2021
9080e3f
Alphabetized includes
hakonsbm Feb 23, 2021
f763fab
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Mar 12, 2021
62861ac
Using consistent version number
hakonsbm Mar 12, 2021
14211b8
Fixing more inconsistent version numbers
hakonsbm Mar 12, 2021
2453c83
Fixed references
hakonsbm Mar 19, 2021
904a445
Fixed indentation
hakonsbm Mar 19, 2021
97659d1
Removed excess documentation whitespace
hakonsbm Mar 19, 2021
414a1c7
Apply suggestions from code review
hakonsbm Mar 23, 2021
761c766
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Apr 6, 2021
f029b1d
Merge remote-tracking branch 'nest/master' into feature/cpp11-librandom
hakonsbm Apr 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ nest_check_have_stl_vector_capacity_doubling()
nest_check_have_xlc_ice_on_using()
nest_check_have_std_nan()
nest_check_have_std_isnan()
nest_check_random123()

################################################################################
################## Create version string ##################
Expand Down Expand Up @@ -224,11 +225,11 @@ add_subdirectory( examples )
add_subdirectory( extras )
add_subdirectory( lib )
add_subdirectory( libnestutil )
add_subdirectory( librandom )
add_subdirectory( models )
add_subdirectory( sli )
add_subdirectory( nest )
add_subdirectory( nestkernel )
add_subdirectory( thirdparty )
add_subdirectory( testsuite )
if ( HAVE_PYTHON )
add_subdirectory( pynest )
Expand Down Expand Up @@ -275,7 +276,6 @@ endforeach ()
set( ALL_LIBS
"-lnestutil"
"-lnest"
"-lrandom"
"-lsli"
"-lnestkernel"
"${OpenMP_CXX_FLAGS}"
Expand Down
21 changes: 21 additions & 0 deletions cmake/CheckExtraCompilerFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,24 @@ function( NEST_CHECK_HAVE_STD_ISNAN )
set( HAVE_STD_ISNAN ${HAVE_STD_ISNAN} PARENT_SCOPE )
message( STATUS "Check if ::isnan is available from cmath. ${HAVE_STD_ISNAN}" )
endfunction()

####### Test if Random123 generators work #######
function( NEST_CHECK_RANDOM123 )
message( STATUS "Check if Random123 generators work." )
try_run( RUN_RESULT COMPILE_RESULT
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Random123/tests/kat_cpp.cpp
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${CMAKE_CURRENT_SOURCE_DIR}/thirdparty
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
RUN_OUTPUT_VARIABLE RUN_OUTPUT
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Random123/tests/kat_vectors
)
if ( ${COMPILE_RESULT} AND ${RUN_RESULT} EQUAL 0 )
set( HAVE_RANDOM123 ON )
else ()
message( ${RUN_OUTPUT} )
set( HAVE_RANDOM123 OFF )
endif ()
set( HAVE_RANDOM123 ${HAVE_RANDOM123} PARENT_SCOPE )
message( STATUS "Check if Random123 generators work. ${HAVE_RANDOM123}" )
endfunction()
1 change: 0 additions & 1 deletion doc/fulldoc.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,6 @@ INPUT = @PROJECT_SOURCE_DIR@/README.md \
@PROJECT_SOURCE_DIR@/extras \
@PROJECT_SOURCE_DIR@/lib \
@PROJECT_SOURCE_DIR@/libnestutil \
@PROJECT_SOURCE_DIR@/librandom \
@PROJECT_SOURCE_DIR@/models \
@PROJECT_SOURCE_DIR@/nest \
@PROJECT_SOURCE_DIR@/nestkernel \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,30 @@ Functions related to models
No Change


Functions related to random number generators
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In NEST 2.x, you would have to set a global seed and individual seeds for each virtual process manually.
In NEST 3.0, you set only a single `rng_seed`, which is used as a base for all other seeds.

+-------------------------------------------------+----------------------------------------------------------------+
| NEST 2.x | NEST 3.0 |
+=================================================+================================================================+
| nest.SetKernelStatus({’grng_seed’ : msd+N_vp}) | nest.SetKernelStatus({'rng_seed': msd}) |
+-------------------------------------------------+ |
| nest.SetKernelStatus({’rng_seeds’ : range( | |
| msd+N_vp+1, msd+2*N_vp+1)}) | |
| | |
+-------------------------------------------------+----------------------------------------------------------------+
| nest.ll_api.sli_func('rngdict keys') | nest.GetKernelStatus('rng_types') |
| | |
+-------------------------------------------------+----------------------------------------------------------------+
| nest.ll_api.sli_run('0 << /grng | nest.SetKernelStatus({'rng_type': 'mt19937', 'rng_seed': 101}) |
| rngdict/MT19937 :: 101 CreateRNG >> SetStatus') | |
| | |
+-------------------------------------------------+----------------------------------------------------------------+


Functions related to parallel computing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
63 changes: 62 additions & 1 deletion doc/guides/nest2_to_nest3/nest2_to_nest3_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ Dictionary with lists when setting parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It is now possible to use a dictionary with lists when setting node parameters
with ``Create()``, ``set()`` or ``SetStatus()``. The values of the lists will
with ``Create()``, ``set()`` or ``SetStatus()``. The values of the lists will
be distributed across the nodes. The way to do this previously was to apply a
list of dictionaries. This is still possible.

Expand Down Expand Up @@ -1505,6 +1505,67 @@ All details about the new infrastructure can be found in the guide on
:doc:`recording from simulations <recording_from_simulations>`.


Simpler handling of random number generators
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All random number generators managed by the NEST kernel are now seeded by
providing a single seed :math:`s` with :math:`1\leq s \leq 2^{31}-1`. The
kernel automatically seeds the random number streams on the various parallel
processes:

+---------------------------------------------+---------------------------------------+
| NEST 2.x | NEST 3.0 |
+=============================================+=======================================+
| | |
| :: | :: |
| | |
| msd = n_threads * seed + 1 | nest.SetKernelStatus({ |
| nest.SetKernelStatus({ | 'rng_seed': seed}) |
| 'grng_seed': msd, | |
| 'rng_seeds': range(msd+1, | |
| msd+1+n_threads) | |
| }) | |
| | |
+---------------------------------------------+---------------------------------------+

Changing the type of random number generator to use is easy now:

+---------------------------------------------+---------------------------------------+
| NEST 2.x | NEST 3.0 |
+=============================================+=======================================+
| | |
| :: | :: |
| | |
| # too difficult to show here | nest.SetKernelStatus({ |
| | 'rng_type': 'mt19937'}) |
| | |
+---------------------------------------------+---------------------------------------+

Which random number generator types are available can be checked by:

::

nest.GetKernelStatus('rng_types')

Details about the new random number generators can be found in the guide on :doc:`random number generators<../random_numbers>`.

Counter-based random number generators
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In addition to the conventional random number generator types, there is added support for
"counter-based" random number generators (CBRNGs) with the Random123 library. Where
conventional RNGs use N iterations of a stateful transformation to find the Nth random
number, the Nth random number of a CBRNG can be obtained by applying a stateless mixing
function to N.

The Random123 library is included in NEST, and random number generator types like Philox and
Threefry are automatically made available.

.. note::

On some systems or with some compilers, the CBRNGs may not give reliable results. In these
cases, they are automatically disabled during compilation and will not be available.


What's removed?
---------------

Expand Down
Loading