├── .clang-format
├── .clang-tidy
├── .github
└── workflows
│ └── static_tests.yml
├── .gitignore
├── .pre-commit-config.yaml
├── .readthedocs.yml
├── CMakeLists.txt
├── COPYING
├── INSTALL
├── LICENSE
├── Makefile.am
├── README.md
├── VERSION
├── bin
├── CMakeLists.txt
└── nestgpu_vars.sh.in
├── c++
├── examples
│ ├── bin
│ │ ├── brunel_mpi.sh
│ │ ├── clean.sh
│ │ ├── log_setvar.txt
│ │ ├── log_test_connect.txt
│ │ ├── plot_all.m
│ │ ├── plot_brunel_mpi.m
│ │ ├── plot_brunel_net.m
│ │ ├── plot_brunel_outdegree.m
│ │ ├── plot_brunel_outdegree_mpi.m
│ │ ├── run_all.sh
│ │ ├── test_aeif_cond_beta.m
│ │ ├── test_brunel_vect.sh
│ │ ├── test_constcurr.m
│ │ └── test_setvar.m
│ ├── brunel_mpi.cpp
│ ├── brunel_mpi_nx.cpp.old
│ ├── brunel_net.cpp
│ ├── brunel_outdegree.cpp
│ ├── brunel_outdegree_mpi.cpp
│ ├── brunel_vect.cpp
│ ├── make_all.sh
│ ├── make_brunel_mpi.sh
│ ├── make_brunel_net.sh
│ ├── make_brunel_outdegree.sh
│ ├── make_brunel_outdegree_mpi.sh
│ ├── make_brunel_vect.sh
│ ├── make_constcurr.sh
│ ├── make_setvar.sh
│ ├── make_test_aeif_cond_beta.sh
│ ├── make_test_connect.sh
│ ├── make_test_error.sh
│ ├── test_aeif_cond_beta.cpp
│ ├── test_connect.cpp
│ ├── test_constcurr.cpp
│ ├── test_error.cpp
│ └── test_setvar.cpp
└── tests
│ ├── bin
│ ├── clean.sh
│ ├── plot_test_connections.m
│ ├── plot_test_neuron_groups.m
│ └── plot_test_record.m
│ ├── make_test_connections.sh
│ ├── make_test_neuron_groups.sh
│ ├── test_connections.cpp
│ └── test_neuron_groups.cpp
├── cmake
├── CheckIncludesSymbols.cmake
├── ColorMessages.cmake
├── ConfigureSummary.cmake
├── FindCython.cmake
├── FindLTDL.cmake
├── FindPythonModule.cmake
├── GetTriple.cmake
├── ProcessOptions.cmake
├── UseCython.cmake
└── VersionInfo.cmake
├── config.h.in
├── configure.ac
├── deb
├── add_to_repo.sh
├── build_package.sh
├── control.templ
├── depends.sh
├── info.txt
├── remove_package.sh
└── sign.sh
├── doc
├── _static
│ └── css
│ │ ├── custom.css
│ │ └── pygments.css
├── community.rst
├── conf.py
├── contents.rst
├── download
│ └── download.rst
├── examples
│ └── index.rst
├── extractor_userdocs.py
├── guides
│ ├── differences_nest-gpu_nest.rst
│ ├── how_to_record_spikes.rst
│ ├── implement_new_neuron_models.rst
│ └── index.rst
├── index.rst
├── installation
│ ├── cmake_options.rst
│ └── index.rst
├── logo
│ ├── nestgpu-logo.pdf
│ ├── nestgpu-logo.png
│ └── nestgpu-logo.svg
├── publications.rst
└── requirements.txt
├── lib
└── info.txt
├── libnestutil
├── CMakeLists.txt
└── config.h.in
├── m4
├── acx_mpi.m4
├── compile
├── config.guess
├── config.sub
├── ct_check_cuda.m4
├── depcomp
├── install-sh
├── ltmain.sh
├── missing
├── py-compile
└── pypath.m4
├── macOS
├── README
├── info.txt
├── install.sh
├── lib
│ └── info.txt
├── nestgpu.rb
├── pythonlib
│ └── nestgpu.py
└── uninstall.sh
├── patch.sh
├── postinstall.sh
├── pyproject.toml
├── python
├── Potjans_2014
│ ├── README.rst
│ ├── eval_microcircuit_time.py
│ ├── helpers.py
│ ├── log_time_10s_gtx1050mob.txt
│ ├── log_time_10s_gtx1050mob_b.txt
│ ├── log_time_10s_gtx1050mob_cde.txt
│ ├── log_time_10s_gtx1050mob_g_cde.txt
│ ├── network.py
│ ├── network_params.py
│ ├── run_microcircuit.py
│ ├── script.sh
│ ├── script_eval_time.sh
│ ├── sim_params.py
│ ├── sim_params.templ
│ ├── sim_params_norec.py
│ ├── sim_params_norec.templ
│ └── stimulus_params.py
├── Potjans_2014_hc
│ ├── README.rst
│ ├── eval_microcircuit_time.py
│ ├── helpers.py
│ ├── log_time_10s_gtx1050mob.txt
│ ├── log_time_10s_gtx1050mob_b.txt
│ ├── log_time_10s_gtx1050mob_cde.txt
│ ├── network.py
│ ├── network_params.py
│ ├── run_microcircuit.py
│ ├── script.sh
│ ├── sim_params.py
│ ├── sim_params.templ
│ ├── sim_params_norec.py
│ └── stimulus_params.py
├── Potjans_2014_s
│ ├── README.rst
│ ├── eval_microcircuit_time.py
│ ├── helpers.py
│ ├── log_time_10s_gtx1050mob.txt
│ ├── log_time_10s_gtx1050mob_b.txt
│ ├── log_time_10s_gtx1050mob_c.txt
│ ├── log_time_10s_gtx1050mob_ring_spike_buffer.txt
│ ├── network.py
│ ├── network_params.py
│ ├── run_microcircuit.py
│ ├── script.sh
│ ├── sim_params.py
│ ├── sim_params.templ
│ ├── sim_params_norec.py
│ └── stimulus_params.py
├── examples
│ ├── balanced_izh.py
│ ├── balanced_izh_cond_beta.py
│ ├── balanced_izh_psc_exp_2s.py
│ ├── balanced_izh_psc_exp_2s_eval_time.py
│ ├── balanced_izh_psc_exp_5s.py
│ ├── brunel_array.py
│ ├── brunel_list.py
│ ├── brunel_mpi.py
│ ├── brunel_net.py
│ ├── brunel_outdegree.py
│ ├── example1.py
│ ├── example2.py
│ ├── plot_aeif_cond_alpha.py
│ ├── plot_aeif_cond_alpha_multisynapse.py
│ ├── plot_aeif_cond_beta.py
│ ├── plot_aeif_cond_beta_multisynapse.py
│ ├── plot_aeif_psc_alpha.py
│ ├── plot_aeif_psc_alpha_multisynapse.py
│ ├── plot_aeif_psc_delta.py
│ ├── plot_aeif_psc_exp.py
│ ├── plot_aeif_psc_exp_multisynapse.py
│ ├── plot_fast_iaf_psc_exp.py
│ ├── plot_iaf_psc_alpha.py
│ ├── plot_iaf_psc_exp.py
│ ├── plot_iaf_psc_exp_g.py
│ ├── plot_izh.py
│ ├── plot_izh_cond_beta.py
│ ├── stdp.py
│ └── temp_mpi.py
├── hpc_benchmark
│ └── hpc_benchmark.py
└── test
│ ├── err.py
│ ├── err_mpi.py
│ ├── log_setvar.txt
│ ├── log_setvar3.txt
│ ├── logp3_connect.txt
│ ├── logp3_getarr.txt
│ ├── logp3_group_param.txt
│ ├── logp3_setvar2.txt
│ ├── logp3_setvar3.txt
│ ├── logp3_syn_group.txt
│ ├── nest_iaf_psc_alpha.py
│ ├── parrot_neuron.py
│ ├── plot_aeif_psc_delta_multisynapse.py
│ ├── test_aeif_cond_alpha.py
│ ├── test_aeif_cond_alpha_multisynapse.py
│ ├── test_aeif_cond_alpha_multisynapse_nest.txt
│ ├── test_aeif_cond_alpha_nest.txt
│ ├── test_aeif_cond_beta.py
│ ├── test_aeif_cond_beta_multisynapse.py
│ ├── test_aeif_cond_beta_multisynapse_nest.txt
│ ├── test_aeif_cond_beta_nest.txt
│ ├── test_aeif_psc_alpha.py
│ ├── test_aeif_psc_alpha_multisynapse.py
│ ├── test_aeif_psc_alpha_multisynapse_nest.txt
│ ├── test_aeif_psc_alpha_nest.txt
│ ├── test_aeif_psc_delta.py
│ ├── test_aeif_psc_delta_nest.txt
│ ├── test_aeif_psc_exp.py
│ ├── test_aeif_psc_exp_multisynapse.py
│ ├── test_aeif_psc_exp_multisynapse_nest.txt
│ ├── test_aeif_psc_exp_nest.txt
│ ├── test_all.sh
│ ├── test_brunel_array.py
│ ├── test_brunel_list.py
│ ├── test_brunel_mpi.py
│ ├── test_brunel_outdegree.py
│ ├── test_brunel_outdegree_mpi.py
│ ├── test_brunel_user_m1.py
│ ├── test_connect.py
│ ├── test_distribution.py
│ ├── test_ext_neuron.py
│ ├── test_fast_iaf_psc_exp_nest.txt
│ ├── test_fixed_total_number.py
│ ├── test_getarr.py
│ ├── test_group_param.py
│ ├── test_iaf_psc_alpha.py
│ ├── test_iaf_psc_alpha_nest.txt
│ ├── test_iaf_psc_exp.py
│ ├── test_iaf_psc_exp_g.py
│ ├── test_iaf_psc_exp_hc.py
│ ├── test_iaf_psc_exp_nest.txt
│ ├── test_izh.py
│ ├── test_izh_nest.txt
│ ├── test_mpi.sh
│ ├── test_setvar.py
│ ├── test_setvar2.py
│ ├── test_setvar3.py
│ ├── test_spike_detector.py
│ ├── test_spike_times.py
│ ├── test_stdp.py
│ ├── test_stdp
│ ├── cases
│ │ ├── case1.py
│ │ ├── case10.py
│ │ ├── case2.py
│ │ ├── case3.py
│ │ ├── case4.py
│ │ ├── case5.py
│ │ ├── case6.py
│ │ ├── case7.py
│ │ ├── case8.py
│ │ ├── case9.py
│ │ ├── swap.sh
│ │ └── test_all.sh
│ └── long_test
│ │ └── test_stdp.py
│ ├── test_stdp_list.py
│ ├── test_syn_group.py
│ ├── test_syn_model.py
│ ├── test_t_ref.py
│ └── test_user_m1.py
├── pythonlib
├── CMakeLists.txt
├── Makefile.am
├── Makefile.in
└── nestgpu.py
├── src
├── CMakeLists.txt
├── aeif_cond_alpha.cu
├── aeif_cond_alpha.h
├── aeif_cond_alpha_kernel.h
├── aeif_cond_alpha_multisynapse.cu
├── aeif_cond_alpha_multisynapse.h
├── aeif_cond_alpha_multisynapse_kernel.h
├── aeif_cond_alpha_multisynapse_rk5.h
├── aeif_cond_beta.cu
├── aeif_cond_beta.h
├── aeif_cond_beta_kernel.h
├── aeif_cond_beta_multisynapse.cu
├── aeif_cond_beta_multisynapse.h
├── aeif_cond_beta_multisynapse_kernel.h
├── aeif_cond_beta_multisynapse_rk5.h
├── aeif_psc_alpha.cu
├── aeif_psc_alpha.h
├── aeif_psc_alpha_kernel.h
├── aeif_psc_alpha_multisynapse.cu
├── aeif_psc_alpha_multisynapse.h
├── aeif_psc_alpha_multisynapse_kernel.h
├── aeif_psc_alpha_multisynapse_rk5.h
├── aeif_psc_delta.cu
├── aeif_psc_delta.h
├── aeif_psc_delta_kernel.h
├── aeif_psc_delta_rk5.h
├── aeif_psc_exp.cu
├── aeif_psc_exp.h
├── aeif_psc_exp_kernel.h
├── aeif_psc_exp_multisynapse.cu
├── aeif_psc_exp_multisynapse.h
├── aeif_psc_exp_multisynapse_kernel.h
├── aeif_psc_exp_multisynapse_rk5.h
├── base_neuron.cu
├── base_neuron.h
├── connect.cu
├── connect.h
├── connect_mpi.cu
├── connect_mpi.h
├── connect_rules.cpp
├── connect_rules.h
├── connect_spec.h
├── cuda_error.h
├── dir_connect.h
├── dummyfile.cpp
├── ext_neuron.cu
├── ext_neuron.h
├── fix_headers.sh
├── getRealTime.cu
├── getRealTime.h
├── get_spike.cu
├── get_spike.h
├── iaf_psc_alpha.cu
├── iaf_psc_alpha.h
├── iaf_psc_exp.cu
├── iaf_psc_exp.h
├── iaf_psc_exp_g.cu
├── iaf_psc_exp_g.h
├── iaf_psc_exp_hc.cu
├── iaf_psc_exp_hc.h
├── iaf_psc_exp_hc_params.h
├── izhikevich.cu
├── izhikevich.h
├── izhikevich_cond_beta.cu
├── izhikevich_cond_beta.h
├── izhikevich_cond_beta_kernel.h
├── izhikevich_cond_beta_rk5.h
├── izhikevich_psc_exp.cu
├── izhikevich_psc_exp.h
├── izhikevich_psc_exp_2s.cu
├── izhikevich_psc_exp_2s.h
├── izhikevich_psc_exp_5s.cu
├── izhikevich_psc_exp_5s.h
├── locate.cu
├── locate.h
├── multimeter.cu
├── multimeter.h
├── nestgpu.cu
├── nestgpu.h
├── nestgpu_C.cpp
├── nestgpu_C.h
├── neuron_models.cu
├── neuron_models.h
├── ngpu_exception.h
├── node_group.cu
├── node_group.h
├── nota.txt
├── nota2.txt
├── nota3.txt
├── parrot_neuron.cu
├── parrot_neuron.h
├── poiss_gen.cu
├── poiss_gen.h
├── poiss_gen_variables.h
├── poisson.cu
├── poisson.h
├── prefix_scan.cu
├── prefix_scan.h
├── propagate_error.h
├── propagator_stability.cu
├── propagator_stability.h
├── pypath.m4
├── random.cu
├── random.h
├── rev_spike.cu
├── rev_spike.h
├── rk5.cu
├── rk5.h
├── rk5_const.h
├── rk5_interface.h
├── scan.cu
├── scan.h
├── script.sh
├── send_spike.cu
├── send_spike.h
├── spike_buffer.cu
├── spike_buffer.cu.commented
├── spike_buffer.h
├── spike_detector.cu
├── spike_detector.h
├── spike_generator.cu
├── spike_generator.h
├── spike_mpi.cu
├── spike_mpi.h
├── stdp.cu
├── stdp.h
├── syn_model.cu
├── syn_model.h
├── test_syn_model.cu
├── test_syn_model.h
├── user_m1.cu
├── user_m1.cu.bk
├── user_m1.h
├── user_m1.h.bk
├── user_m1_cond_alpha.cu
├── user_m1_cond_alpha.h
├── user_m1_cond_alpha_kernel.h
├── user_m1_cond_alpha_rk5.h
├── user_m1_cond_beta.cu
├── user_m1_cond_beta.h
├── user_m1_cond_beta_kernel.h
├── user_m1_cond_beta_rk5.h
├── user_m1_iaf_psc_exp.cu
├── user_m1_iaf_psc_exp.h
├── user_m1_iaf_psc_exp_g.cu
├── user_m1_iaf_psc_exp_g.h
├── user_m1_iaf_psc_exp_hc.cu
├── user_m1_iaf_psc_exp_hc.h
├── user_m1_iaf_psc_exp_hc_params.h
├── user_m1_kernel.h
├── user_m1_kernel.h.bk
├── user_m1_psc_alpha.cu
├── user_m1_psc_alpha.h
├── user_m1_psc_alpha_kernel.h
├── user_m1_psc_alpha_rk5.h
├── user_m1_psc_delta.cu
├── user_m1_psc_delta.h
├── user_m1_psc_delta_kernel.h
├── user_m1_psc_delta_rk5.h
├── user_m1_psc_exp.cu
├── user_m1_psc_exp.h
├── user_m1_psc_exp_g.cu
├── user_m1_psc_exp_g.h
├── user_m1_psc_exp_hc.cu
├── user_m1_psc_exp_hc.h
├── user_m1_psc_exp_hc_params.h
├── user_m1_psc_exp_kernel.h
├── user_m1_psc_exp_rk5.h
├── user_m1_rk5.h
├── user_m1_rk5.h.bk
├── user_m2.cu
├── user_m2.h
├── user_m2_cond_alpha.cu
├── user_m2_cond_alpha.h
├── user_m2_cond_alpha_kernel.h
├── user_m2_cond_alpha_rk5.h
├── user_m2_cond_beta.cu
├── user_m2_cond_beta.h
├── user_m2_cond_beta_kernel.h
├── user_m2_cond_beta_rk5.h
├── user_m2_iaf_psc_exp.cu
├── user_m2_iaf_psc_exp.h
├── user_m2_iaf_psc_exp_g.cu
├── user_m2_iaf_psc_exp_g.h
├── user_m2_iaf_psc_exp_hc.cu
├── user_m2_iaf_psc_exp_hc.h
├── user_m2_iaf_psc_exp_hc_params.h
├── user_m2_kernel.h
├── user_m2_psc_alpha.cu
├── user_m2_psc_alpha.h
├── user_m2_psc_alpha_kernel.h
├── user_m2_psc_alpha_rk5.h
├── user_m2_psc_delta.cu
├── user_m2_psc_delta.h
├── user_m2_psc_delta_kernel.h
├── user_m2_psc_delta_rk5.h
├── user_m2_psc_exp.cu
├── user_m2_psc_exp.h
├── user_m2_psc_exp_g.cu
├── user_m2_psc_exp_g.h
├── user_m2_psc_exp_hc.cu
├── user_m2_psc_exp_hc.h
├── user_m2_psc_exp_hc_params.h
├── user_m2_psc_exp_kernel.h
├── user_m2_psc_exp_rk5.h
├── user_m2_rk5.h
└── write_iaf_psc_exp_hc_params.py
├── todo.txt
└── tox.ini
/.clang-tidy:
--------------------------------------------------------------------------------
1 | Checks: '-*,modernize-use-nullptr,modernize-use-override,bugprone,modernize-redundant-void-arg'
2 |
--------------------------------------------------------------------------------
/.github/workflows/static_tests.yml:
--------------------------------------------------------------------------------
1 | #
2 | # detailed syntax defined in
3 | # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
4 | #
5 | name: "Static Tests"
6 |
7 | on: [push, pull_request]
8 |
9 | jobs:
10 | clang-format:
11 | runs-on: "ubuntu-20.04"
12 | env:
13 | CLANG_REQUIRE_VERSION: 17.0.4
14 | CLANG_FORMAT_FILE: ".clang-format"
15 | steps:
16 | - name: "Checkout repository content"
17 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
18 | with:
19 | fetch-depth: 0
20 |
21 | - name: "Install dependencies"
22 | run: |
23 | python -m pip install --force-reinstall clang-format==${{ env.CLANG_REQUIRE_VERSION }}
24 |
25 | - name: "Run clang-format..."
26 | run: |
27 | files=$(find . -iname "*.h" -o -iname "*.cu" -o -iname "*.cpp")
28 | diff -u <(cat ${files}) <(clang-format ${files})
29 |
30 | black:
31 | runs-on: "ubuntu-20.04"
32 | steps:
33 | - name: "Checkout repository content"
34 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
35 | with:
36 | fetch-depth: 0
37 |
38 | - name: "Run black..."
39 | uses: psf/black@2a1c67e0b2f81df602ec1f6e7aeb030b9709dc7c # 23.11.0
40 |
41 | flake8:
42 | runs-on: "ubuntu-20.04"
43 | steps:
44 | - name: "Checkout repository content"
45 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
46 | with:
47 | fetch-depth: 0
48 |
49 | - name: "Set up Python 3.x"
50 | uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
51 | with:
52 | python-version: 3.9
53 |
54 | - name: "Install dependencies"
55 | run: |
56 | pip install flake8
57 |
58 | - name: "Run flake8..."
59 | run: |
60 | flake8 .
61 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.lo
2 | *.mod
3 | *.o
4 | *.a
5 | *.so
6 | *.dylib
7 | *.pyc
8 | *.pyo
9 | Makefile
10 | Makefile.in
11 | build
12 | build_mac
13 | aclocal.m4
14 | autom4te.cache
15 | build-aux
16 | *.swp
17 | defbuild
18 | *~
19 | m4/libtool.m4
20 | m4/ltoptions.m4
21 | m4/ltsugar.m4
22 | m4/ltversion.m4
23 | m4/lt~obsolete.m4
24 | config.h
25 | config.log
26 | config.status
27 | configure
28 | configure.doc
29 | stamp-h1
30 | libtool
31 | .deps
32 | *.gz
33 | *.tgz
34 | /.autotools
35 | /.cproject
36 | /.project
37 | /.settings/
38 | doxygen
39 | python/test/log.txt
40 | .vscode/
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/pycqa/isort
3 | rev: 5.12.0
4 | hooks:
5 | - id: isort
6 | args: ["--profile", "black"]
7 |
8 | - repo: https://github.com/psf/black
9 | rev: 23.7.0
10 | hooks:
11 | - id: black
12 | language_version: python3
13 |
14 | # - repo: https://github.com/pre-commit/mirrors-clang-format
15 | # rev: v17.0.4
16 | # hooks:
17 | # - id: clang-format
18 |
19 | - repo: https://github.com/pre-commit/pre-commit-hooks
20 | rev: v4.4.0
21 | hooks:
22 | - id: end-of-file-fixer
23 | - id: trailing-whitespace
24 |
--------------------------------------------------------------------------------
/.readthedocs.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 |
3 | sphinx:
4 | builder: html
5 | configuration: doc/conf.py
6 |
7 | python:
8 | version: 3.8
9 | install:
10 | - requirements: doc/requirements.txt
11 |
12 | build:
13 | image: latest
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NEST GPU
2 |
3 | **NEST GPU was developed under the name [NeuronGPU](https://github.com/golosio/NeuronGPU) before it has been integrated in the NEST Initiative, see [Golosio et al. (2021)](https://www.frontiersin.org/articles/10.3389/fncom.2021.627620/full). Currently this repository is being adapted to the NEST development workflow.**
4 |
5 | NEST GPU is a GPU-MPI library for simulation of large-scale networks of spiking neurons.
6 | Can be used in Python, in C++ and in C.
7 |
8 | With this library it is possible to run relatively fast simulations of large-scale networks of spiking neurons. For instance, on a single Nvidia GeForce RTX 2080 Ti GPU board it is possible to simulate the activity of 1 million multisynapse AdEx neurons with 1000 synapse per neurons, for a total of 1 billion synapse, using the fifth-order Runge-Kutta method with adaptive stepsize as differential equations solver, in little more than 70 seconds per second of neural activity. The MPI communication is also very efficient.
9 | The Python interface is very similar to that of the NEST simulator: the most used commands are practically identical, dictionaries are used to define neurons, connections and synapses properties in the same way.
10 |
11 | ## Documentation
12 | To get started with NEST GPU, please see the [NEST GPU Documentation](https://nest-gpu.readthedocs.io/en/latest/).
13 |
14 | ## License
15 | NEST GPU is an open source software licensed under the [GNU General Public Lincese version 2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html).
16 |
17 | ## Installing NEST GPU
18 | To install NEST GPU see the [NEST GPU Installation Intructions](https://nest-gpu.readthedocs.io/en/latest/installation/index.html) on our Documentation.
19 |
20 | ## Citing NEST GPU
21 | If you use NEST GPU in your work, please cite the publications in our [publication list](https://nest-gpu.readthedocs.io/en/latest/publications.html).
22 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | 1.08
2 |
--------------------------------------------------------------------------------
/bin/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # CMakeLists.txt
2 | #
3 | # This file is part of NEST GPU.
4 | #
5 | # Copyright (C) 2004 The NEST Initiative
6 | #
7 | # NEST GPU is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 2 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # NEST GPU is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with NEST GPU. If not, see .
19 |
20 | install( PROGRAMS ${PROJECT_BINARY_DIR}/bin/nestgpu_vars.sh
21 | DESTINATION ${CMAKE_INSTALL_BINDIR} )
22 |
--------------------------------------------------------------------------------
/bin/nestgpu_vars.sh.in:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Make PyNEST available by prepending its path to PYTHONPATH in a safe way.
4 | export PYTHONPATH="@CMAKE_INSTALL_PREFIX@/@PYEXECDIR@${PYTHONPATH:+:$PYTHONPATH}"
5 |
6 | # Make NEST executables available by prepending their path to PATH.
7 | export NESTGPU_LIB="@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/nestgpu/libnestgpukernel.so"
8 |
--------------------------------------------------------------------------------
/c++/examples/bin/brunel_mpi.sh:
--------------------------------------------------------------------------------
1 | mpirun -np 2 brunel_mpi 5000
2 |
--------------------------------------------------------------------------------
/c++/examples/bin/clean.sh:
--------------------------------------------------------------------------------
1 | rm -f test_aeif_cond_beta.dat
2 | rm -f test_brunel_mpi_0.dat
3 | rm -f test_brunel_mpi_1.dat
4 | rm -f test_brunel_net.dat
5 | rm -f test_brunel_outdegree.dat
6 | rm -f test_brunel_outdegree_mpi_0.dat
7 | rm -f test_brunel_outdegree_mpi_1.dat
8 | rm -f test_brunel_vect.dat
9 | rm -f test_constcurr.dat
10 | rm -f brunel_mpi
11 | rm -f brunel_net
12 | rm -f brunel_outdegree
13 | rm -f brunel_outdegree_mpi
14 | rm -f brunel_vect
15 | rm -f test_aeif_cond_beta
16 | rm -f test_connect
17 | rm -f test_constcurr
18 | rm -f test_error
19 | rm -f test_setvar
20 | rm -f *~
21 |
--------------------------------------------------------------------------------
/c++/examples/bin/plot_all.m:
--------------------------------------------------------------------------------
1 | plot_brunel_mpi
2 | waitforbuttonpress ()
3 | close all
4 | plot_brunel_net
5 | waitforbuttonpress ()
6 | close all
7 | plot_brunel_outdegree
8 | waitforbuttonpress ()
9 | close all
10 | plot_brunel_outdegree_mpi
11 | waitforbuttonpress ()
12 | close all
13 | test_aeif_cond_beta
14 | waitforbuttonpress ()
15 | close all
16 | test_constcurr
17 | waitforbuttonpress ()
18 | close all
19 | test_setvar
20 | waitforbuttonpress ()
21 | close all
22 |
--------------------------------------------------------------------------------
/c++/examples/bin/plot_brunel_mpi.m:
--------------------------------------------------------------------------------
1 | data=load('test_brunel_mpi_0.dat');
2 | t=data(:,1);
3 | V1=data(:,2);
4 | V2=data(:,3);
5 | V3=data(:,4);
6 | figure(1);
7 | plot(t,V1);
8 | figure(2);
9 | plot(t,V2);
10 | figure(3);
11 | plot(t,V3);
12 |
13 | data1=load('test_brunel_mpi_1.dat');
14 | t1=data1(:,1);
15 | V11=data1(:,2);
16 | V12=data1(:,3);
17 | V13=data1(:,4);
18 | figure(4);
19 | plot(t1,V11);
20 | figure(5);
21 | plot(t1,V12);
22 | figure(6);
23 | plot(t1,V13);
24 |
--------------------------------------------------------------------------------
/c++/examples/bin/plot_brunel_net.m:
--------------------------------------------------------------------------------
1 | data=load('test_brunel_net.dat');
2 | t=data(:,1);
3 | V1=data(:,2);
4 | V2=data(:,3);
5 | V3=data(:,4);
6 | figure(1);
7 | plot(t,V1);
8 | figure(2);
9 | plot(t,V2);
10 | figure(3);
11 | plot(t,V3);
12 |
--------------------------------------------------------------------------------
/c++/examples/bin/plot_brunel_outdegree.m:
--------------------------------------------------------------------------------
1 | data=load('test_brunel_outdegree.dat');
2 | t=data(:,1);
3 | V1=data(:,2);
4 | V2=data(:,3);
5 | V3=data(:,4);
6 | V4=data(:,5);
7 | V5=data(:,6);
8 | V6=data(:,7);
9 | V7=data(:,8);
10 | V8=data(:,9);
11 | V9=data(:,10);
12 | V10=data(:,11);
13 | figure(1);
14 | plot(t,V1);
15 | figure(2);
16 | plot(t,V2);
17 | figure(3);
18 | plot(t,V3);
19 | figure(4);
20 | plot(t,V4);
21 | figure(5);
22 | plot(t,V5);
23 | figure(6);
24 | plot(t,V6);
25 | figure(7);
26 | plot(t,V7);
27 | figure(8);
28 | plot(t,V8);
29 | figure(9);
30 | plot(t,V9);
31 | figure(10);
32 | plot(t,V10);
33 |
--------------------------------------------------------------------------------
/c++/examples/bin/plot_brunel_outdegree_mpi.m:
--------------------------------------------------------------------------------
1 | data=load('test_brunel_outdegree_mpi_0.dat');
2 | t=data(:,1);
3 | V1=data(:,2);
4 | V2=data(:,3);
5 | V3=data(:,4);
6 | V4=data(:,5);
7 | V5=data(:,6);
8 | figure(1);
9 | plot(t,V1);
10 | figure(2);
11 | plot(t,V2);
12 | figure(3);
13 | plot(t,V3);
14 | figure(4);
15 | plot(t,V4);
16 | figure(5);
17 | plot(t,V5);
18 |
19 | data1=load('test_brunel_outdegree_mpi_1.dat');
20 | t1=data1(:,1);
21 | V11=data1(:,2);
22 | V12=data1(:,3);
23 | V13=data1(:,4);
24 | V14=data1(:,5);
25 | V15=data1(:,6);
26 | figure(6);
27 | plot(t1,V11);
28 | figure(7);
29 | plot(t1,V12);
30 | figure(8);
31 | plot(t1,V13);
32 | figure(9);
33 | plot(t1,V14);
34 | figure(10);
35 | plot(t1,V15);
36 |
--------------------------------------------------------------------------------
/c++/examples/bin/run_all.sh:
--------------------------------------------------------------------------------
1 | mpirun -np 2 brunel_mpi 2000
2 | ./brunel_net 2000
3 | ./brunel_vect 2000
4 | ./brunel_outdegree 2000
5 | mpirun -np 2 ./brunel_outdegree_mpi 2000
6 | ./test_aeif_cond_beta
7 | ./test_constcurr
8 |
--------------------------------------------------------------------------------
/c++/examples/bin/test_aeif_cond_beta.m:
--------------------------------------------------------------------------------
1 | data=load('test_aeif_cond_beta.dat');
2 | t=data(:,1);
3 | V=data(:,2);
4 | plot(t,V)
5 |
--------------------------------------------------------------------------------
/c++/examples/bin/test_brunel_vect.sh:
--------------------------------------------------------------------------------
1 | export OMP_NUM_THREADS=1
2 | ./brunel_net 1000
3 | ./brunel_vect 1000
4 | diff test_brunel_vect.dat test_brunel_net.dat
5 | unset OMP_NUM_THREADS
6 |
--------------------------------------------------------------------------------
/c++/examples/bin/test_constcurr.m:
--------------------------------------------------------------------------------
1 | data=load('test_constcurr.dat');
2 | t=data(:,1);
3 | V=data(:,2);
4 | plot(t,V)
5 |
--------------------------------------------------------------------------------
/c++/examples/bin/test_setvar.m:
--------------------------------------------------------------------------------
1 | data=load('test_setvar.dat');
2 | t=data(:,1);
3 | V0=data(:,2);
4 | V1=data(:,3);
5 | V2=data(:,4);
6 | figure(1);
7 | plot(t,V0);
8 | figure(2);
9 | plot(t,V1);
10 | figure(3);
11 | plot(t,V2);
12 |
--------------------------------------------------------------------------------
/c++/examples/make_all.sh:
--------------------------------------------------------------------------------
1 | ./make_brunel_mpi.sh
2 | ./make_brunel_net.sh
3 | ./make_brunel_outdegree_mpi.sh
4 | ./make_brunel_outdegree.sh
5 | ./make_brunel_vect.sh
6 | ./make_constcurr.sh
7 | ./make_setvar.sh
8 | ./make_test_aeif_cond_beta.sh
9 | ./make_test_connect.sh
10 | ./make_test_error.sh
11 |
--------------------------------------------------------------------------------
/c++/examples/make_brunel_mpi.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/brunel_mpi brunel_mpi.cpp -lm -lnestgpu
2 |
--------------------------------------------------------------------------------
/c++/examples/make_brunel_net.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/brunel_net brunel_net.cpp -lm -lnestgpu
2 |
3 |
--------------------------------------------------------------------------------
/c++/examples/make_brunel_outdegree.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/brunel_outdegree brunel_outdegree.cpp -lm -lnestgpu
2 |
3 |
--------------------------------------------------------------------------------
/c++/examples/make_brunel_outdegree_mpi.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/brunel_outdegree_mpi brunel_outdegree_mpi.cpp -lm -lnestgpu
2 |
--------------------------------------------------------------------------------
/c++/examples/make_brunel_vect.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/brunel_vect brunel_vect.cpp -lm -lnestgpu
2 |
3 |
--------------------------------------------------------------------------------
/c++/examples/make_constcurr.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/test_constcurr test_constcurr.cpp -lm -lnestgpu
2 |
3 |
--------------------------------------------------------------------------------
/c++/examples/make_setvar.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/test_setvar test_setvar.cpp -lm -lnestgpu
2 |
3 |
--------------------------------------------------------------------------------
/c++/examples/make_test_aeif_cond_beta.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/test_aeif_cond_beta test_aeif_cond_beta.cpp -lm -lnestgpu
2 |
--------------------------------------------------------------------------------
/c++/examples/make_test_connect.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/test_connect test_connect.cpp -lm -lnestgpu
2 |
3 |
--------------------------------------------------------------------------------
/c++/examples/make_test_error.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/test_error test_error.cpp -lm -lnestgpu
2 |
--------------------------------------------------------------------------------
/c++/examples/test_constcurr.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * test_constcurr.cpp
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include "nestgpu.h"
32 |
33 | using namespace std;
34 |
35 | int main(int argc, char *argv[])
36 | {
37 | NESTGPU ngpu;
38 | cout << "Building ...\n";
39 |
40 | srand(12345);
41 | int n_neurons = 10000;
42 |
43 | // create n_neurons neurons with 1 receptor ports
44 | NodeSeq neuron = ngpu.Create("aeif_cond_beta", n_neurons, 1);
45 |
46 | // neuron parameters
47 | ngpu.SetNeuronParam(neuron, "a", 4.0);
48 | ngpu.SetNeuronParam(neuron, "b", 80.5);
49 | ngpu.SetNeuronParam(neuron, "E_L", -70.6);
50 | ngpu.SetNeuronParam(neuron, "I_e", 800.0);
51 |
52 | string filename = "test_constcurr.dat";
53 | int i_neurons[] = {neuron[rand()%n_neurons]}; // any set of neuron indexes
54 | string var_name[] = {"V_m"};
55 |
56 | // create multimeter record of V_m
57 | ngpu.CreateRecord(filename, var_name, i_neurons, 1);
58 |
59 | ngpu.Simulate();
60 |
61 | return 0;
62 | }
63 |
--------------------------------------------------------------------------------
/c++/tests/bin/clean.sh:
--------------------------------------------------------------------------------
1 | rm -f test_connections_g1.dat
2 | rm -f test_connections_spikes.dat
3 | rm -f test_connections_voltage.dat
4 | rm -f test_neuron_group_record.dat
5 | rm -f test_neuron_groups_g1.dat
6 | rm -f test_neuron_groups_spikes.dat
7 | rm -f test_neuron_groups_voltage.dat
8 | rm -f test_connections
9 | rm -f test_neuron_groups
10 |
--------------------------------------------------------------------------------
/c++/tests/bin/plot_test_connections.m:
--------------------------------------------------------------------------------
1 | clear all; close all;
2 | data=load('test_connections_voltage.dat');
3 | t=data(:,1);
4 | n1=data(:,2);
5 | n2=data(:,3);
6 | n3=data(:,4);
7 | n4=data(:,5);
8 | n5=data(:,6);
9 | n6=data(:,7);
10 | n7=data(:,8);
11 | %
12 | y1=data(:,9);
13 | y2=data(:,10);
14 | y3=data(:,11);
15 | %
16 | data=load('test_connections_g1.dat');
17 | z1=data(:,2);
18 | z2=data(:,3);
19 | z3=data(:,4);
20 | z4=data(:,5);
21 | z5=data(:,6);
22 | z6=data(:,7);
23 | %
24 | %
25 | data=load('test_connections_spikes.dat');
26 | sp1=data(:,2);
27 | sp2=data(:,3);
28 | sp3=data(:,4);
29 | sp4=data(:,5);
30 | sp5=data(:,6);
31 | sp6=data(:,7);
32 | sp7=data(:,8);
33 |
34 | figure(1);
35 | plot(t,n1);
36 | figure(2);
37 | plot(t,n7)
38 | %
39 | figure(3);
40 | plot(t,y1)
41 | %
42 | figure(4);
43 | plot(t,y2)
44 | %
45 | figure(5);
46 | plot(t,y3)
47 | %
48 | figure(6)
49 | plot(t,sp1+sp2+sp3+sp4)
50 | hold on
51 | plot(t,(y1+70.6)*70,'r')
52 | %
53 | figure(7)
54 | plot(t,sp5)
55 | hold on
56 | plot(t,(y2+70.6)*70,'r')
57 | %
58 | figure(8)
59 | plot(t,sp6 + sp7)
60 | hold on
61 | plot(t,(y3+70.6)*70,'r')
62 | %
63 | figure(9)
64 | plot(t,sp1)
65 | hold on
66 | plot(t,z1*50,'r')
67 | %
68 | figure(10)
69 | plot(t,sp2+sp3)
70 | hold on
71 | plot(t,z2*50,'r')
72 | %
73 | figure(11)
74 | plot(t,sp4)
75 | hold on
76 | plot(t,z3*50,'r')
77 | %
78 | figure(12)
79 | plot(t,sp5)
80 | hold on
81 | plot(t,z4*50,'r')
82 | %
83 | figure(13)
84 | plot(t,sp6)
85 | hold on
86 | plot(t,z5*50,'r')
87 | %
88 | figure(14)
89 | plot(t,sp7)
90 | hold on
91 | plot(t,z6*50,'r');
92 | %
93 |
--------------------------------------------------------------------------------
/c++/tests/bin/plot_test_neuron_groups.m:
--------------------------------------------------------------------------------
1 | clear all; close all;
2 | data=load('test_neuron_groups_voltage.dat');
3 | t=data(:,1);
4 | n1=data(:,2);
5 | n2=data(:,3);
6 | n3=data(:,4);
7 | n4=data(:,5);
8 | n5=data(:,6);
9 | n6=data(:,7);
10 | n7=data(:,8);
11 | %
12 | y1=data(:,9);
13 | y2=data(:,10);
14 | y3=data(:,11);
15 | %
16 | data=load('test_neuron_groups_g1.dat');
17 | z1=data(:,2);
18 | z2=data(:,3);
19 | z3=data(:,4);
20 | z4=data(:,5);
21 | z5=data(:,6);
22 | z6=data(:,7);
23 | %
24 | %
25 | data=load('test_neuron_groups_spikes.dat');
26 | sp1=data(:,2);
27 | sp2=data(:,3);
28 | sp3=data(:,4);
29 | sp4=data(:,5);
30 | sp5=data(:,6);
31 | sp6=data(:,7);
32 | sp7=data(:,8);
33 |
34 | figure(1);
35 | plot(t,n1);
36 | figure(2);
37 | plot(t,n7)
38 | %
39 | figure(3);
40 | plot(t,y1)
41 | %
42 | figure(4);
43 | plot(t,y2)
44 | %
45 | figure(5);
46 | plot(t,y3)
47 | %
48 | figure(6)
49 | plot(t,sp1+sp2+sp3+sp4)
50 | hold on
51 | plot(t,(y1+70.6)*70,'r')
52 | %
53 | figure(7)
54 | plot(t,sp5)
55 | hold on
56 | plot(t,(y2+70.6)*70,'r')
57 | %
58 | figure(8)
59 | plot(t,sp6 + sp7)
60 | hold on
61 | plot(t,(y3+70.6)*70,'r')
62 | %
63 | figure(9)
64 | plot(t,sp1)
65 | hold on
66 | plot(t,z1*50,'r')
67 | %
68 | figure(10)
69 | plot(t,sp2+sp3)
70 | hold on
71 | plot(t,z2*50,'r')
72 | %
73 | figure(11)
74 | plot(t,sp4)
75 | hold on
76 | plot(t,z3*50,'r')
77 | %
78 | figure(12)
79 | plot(t,sp5)
80 | hold on
81 | plot(t,z4*50,'r')
82 | %
83 | figure(13)
84 | plot(t,sp6)
85 | hold on
86 | plot(t,z5*50,'r')
87 | %
88 | figure(14)
89 | plot(t,sp7)
90 | hold on
91 | plot(t,z6*50,'r');
92 | %
93 |
--------------------------------------------------------------------------------
/c++/tests/bin/plot_test_record.m:
--------------------------------------------------------------------------------
1 | clear all; close all;
2 | data=load('test_neuron_groups_voltage.dat');
3 | t=data(:,1);
4 | n1=data(:,2);
5 | n2=data(:,3);
6 | n3=data(:,4);
7 | n4=data(:,5);
8 | n5=data(:,6);
9 | n6=data(:,7);
10 | n7=data(:,8);
11 | %
12 | data1=load('test_neuron_group_record.dat');
13 | t1=data1(:,1);
14 | v1=data1(:,2);
15 | v2=data1(:,3);
16 | v3=data1(:,4);
17 | v4=data1(:,5);
18 | v5=data1(:,6);
19 | v6=data1(:,7);
20 | v7=data1(:,8);
21 | %
22 |
23 | figure(1);
24 | plot(t,n1);
25 | hold on;
26 | plot(t1,v1);
27 |
28 | figure(2);
29 | plot(t,n2);
30 | hold on;
31 | plot(t1,v2);
32 |
33 | figure(3);
34 | plot(t,n3);
35 | hold on;
36 | plot(t1,v3);
37 |
38 | figure(4);
39 | plot(t,n4);
40 | hold on;
41 | plot(t1,v4);
42 |
43 | figure(5);
44 | plot(t,n5);
45 | hold on;
46 | plot(t1,v5);
47 |
48 | figure(6);
49 | plot(t,n6);
50 | hold on;
51 | plot(t1,v6);
52 |
53 | figure(7);
54 | plot(t,n7);
55 | hold on;
56 | plot(t1,v7);
57 |
58 |
--------------------------------------------------------------------------------
/c++/tests/make_test_connections.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/test_connections test_connections.cpp -lm -lnestgpu
2 |
3 |
--------------------------------------------------------------------------------
/c++/tests/make_test_neuron_groups.sh:
--------------------------------------------------------------------------------
1 | g++ -Wall -I ../../src -o bin/test_neuron_groups test_neuron_groups.cpp -lm -lnestgpu
2 |
3 |
--------------------------------------------------------------------------------
/cmake/FindPythonModule.cmake:
--------------------------------------------------------------------------------
1 | # FindPythonModule.cmake
2 | #
3 | # This file is part of NEST GPU.
4 | #
5 | # Copyright (C) 2004 The NEST Initiative
6 | #
7 | # NEST GPU is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 2 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # NEST GPU is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with NEST GPU. If not, see .
19 |
20 | # https://cmake.org/pipermail/cmake/2011-January/041666.html
21 | function(find_python_module module)
22 | string(TOUPPER ${module} module_upper)
23 |
24 | if(NOT PY_${module_upper})
25 | if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED")
26 | set(${module}_FIND_REQUIRED TRUE)
27 | endif()
28 |
29 | # A module's location is usually a directory, but for binary modules
30 | # it's a .so file.
31 | execute_process(COMMAND "${Python_EXECUTABLE}" "-c"
32 | "import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
33 | RESULT_VARIABLE _${module}_status
34 | OUTPUT_VARIABLE _${module}_location
35 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
36 |
37 | if(NOT _${module}_status)
38 | set(HAVE_${module_upper} ON CACHE INTERNAL "")
39 | set(PY_${module_upper} ${_${module}_location} CACHE STRING
40 | "Location of Python module ${module}")
41 | else()
42 | set(HAVE_${module_upper} OFF CACHE INTERNAL "")
43 | endif()
44 |
45 | endif(NOT PY_${module_upper})
46 |
47 | find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper})
48 | endfunction(find_python_module)
49 |
--------------------------------------------------------------------------------
/deb/add_to_repo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ $# -ne 3 ]; then
3 | echo "Usage: $0 folder distro package-name"
4 | echo "where folder is /srv/dev/ubuntu or /srv/deb/debian and distro is bionic, eoan, ..."
5 | exit
6 | fi
7 | reprepro -b $1 includedeb $2 $3
8 |
--------------------------------------------------------------------------------
/deb/build_package.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ $# -ne 1 ]; then
3 | echo "Usage: $0 distro"
4 | echo "where distro is ubuntu1 for bionic(18.04), ubuntu2 for eoan(19.10), debian1, ..."
5 | exit
6 | fi
7 |
8 | version=1.4.6~$1
9 |
10 | #define source and target directories
11 | srcdir=..
12 | tgdir=nestgpu_$version
13 |
14 | # create installation directory if it doesn't exist and clean it
15 | mkdir -p $tgdir/usr/local/nestgpu
16 | rm -fr $tgdir/usr/local/nestgpu/*
17 | mkdir -p $tgdir/usr/local/lib
18 |
19 | # copy subdirectories
20 | cp -r $srcdir/src $tgdir/usr/local/nestgpu
21 | cp -r $srcdir/python $tgdir/usr/local/nestgpu
22 | cp -r $srcdir/c++ $tgdir/usr/local/nestgpu
23 | cp -r $srcdir/deb/lib $tgdir/usr/local/nestgpu
24 |
25 | #create include directory and copy header file
26 | mkdir $tgdir/usr/local/nestgpu/include
27 | cp $srcdir/src/nestgpu.h $tgdir/usr/local/nestgpu/include/
28 |
29 | # create python package directory
30 | mkdir -p $tgdir/usr/lib/python2.7/dist-packages/
31 | mkdir -p $tgdir/usr/lib/python3/dist-packages/
32 |
33 | # copy the nestgpu python module
34 | cp $srcdir/pythonlib/nestgpu.py $tgdir/usr/lib/python2.7/dist-packages/
35 | cp $srcdir/pythonlib/nestgpu.py $tgdir/usr/lib/python3/dist-packages/
36 |
37 | # create a symbolic link in /usr/local/lib to the dynamic-link library
38 | ln -s /usr/local/nestgpu/lib/libnestgpu.so $tgdir/usr/local/lib/libnestgpu.so
39 |
40 | # create dependency list
41 | depends=$(./depends.sh)
42 |
43 | # create metadata file and control file
44 | mkdir $tgdir/DEBIAN
45 | cat control.templ | sed "s/__version__/$version/;s/__depends__/$depends/" > $tgdir/DEBIAN/control
46 | dpkg-deb --build $tgdir
47 |
--------------------------------------------------------------------------------
/deb/control.templ:
--------------------------------------------------------------------------------
1 | Package: nestgpu
2 | Version: __version__
3 | Section: base
4 | Priority: optional
5 | Architecture: amd64
6 | Depends: libomp-dev (>= 5.0.1-1), libopenmpi-dev (>= 2.1.1-8), nvidia-cuda-toolkit (>= 9.1.85-3ubuntu1), openmpi-bin (>= 2.1.1-8), python (>= 2.7.15~rc1-1), python-matplotlib (>= 2.1.1-2ubuntu3), python-mpi4py (>= 2.0.0-3)
7 | Maintainer: Bruno Golosio
8 | Homepage: https://github.com/golosio/NESTGPU
9 | Description: NESTGPU
10 | A GPU-MPI library for simulation of large-scale networks of spiking neurons.
11 | Can be used in Python, in C++ and in C.
12 | https://github.com/golosio/NESTGPU
13 |
--------------------------------------------------------------------------------
/deb/depends.sh:
--------------------------------------------------------------------------------
1 | pkg_list="nvidia-cuda-toolkit openmpi-bin libopenmpi-dev libomp-dev python python-matplotlib python-mpi4py"
2 | apt list $pkg_list 2>/dev/null | tr '/' ' ' | grep -v Listing | while read a b c d; do echo -n "$a (>= $c), "; done | sed 's/, $//'; echo
3 |
--------------------------------------------------------------------------------
/deb/info.txt:
--------------------------------------------------------------------------------
1 | debian/ubuntu distribution folder
2 |
--------------------------------------------------------------------------------
/deb/remove_package.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ $# -ne 1 ]; then
3 | echo "Usage: $0 distro"
4 | exit
5 | fi
6 | sudo reprepro -Vb /srv/deb/ubuntu remove $1 nestgpu
7 |
--------------------------------------------------------------------------------
/deb/sign.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ $# -ne 1 ]; then
3 | echo "Usage: $0 package-name"
4 | exit
5 | fi
6 |
7 | dpkg-sig --sign builder $1
8 |
--------------------------------------------------------------------------------
/doc/community.rst:
--------------------------------------------------------------------------------
1 | Community
2 | =========
3 |
4 | NEST GPU adopts the unified, community-centered workflow of NEST and encourages both users and developers to get in touch in the following ways:
5 |
6 | Issues and pull requests on GitHub
7 | ##################################
8 |
9 | On ``_, you can submit
10 |
11 | * issues for reporting bugs and requesting features
12 | * pull requests for contributing to the source code and the documentation.
13 |
14 | Mailing list
15 | ############
16 |
17 | The NEST User Mailing List is intended to be a forum for questions on the usage of NEST, the exchange of code, and general discussions about NEST. NEST GPU-specific topics are equally welcome. The philosophy is that all users profit by sharing their experience. All NEST core developers are subscribed to this list and will participate in the discussions as far as time allows.
18 |
19 | By subscribing to the mailing list you will also get notified of all NEST-related events!
20 |
21 | Please find `here `_ the guidelines for contributing to the mailing list and information on how to access it.
22 |
23 | Open video conference
24 | #####################
25 |
26 | Every two weeks, we have an open video conference to discuss current issues and developments in NEST. We welcome users with questions regarding their implementations or issues they want help solving to join. This is an opportunity to have discussions in real time with developers.
27 |
28 | Information for dates and how to join can be found on the `GitHub wiki `_.
29 |
30 |
--------------------------------------------------------------------------------
/doc/contents.rst:
--------------------------------------------------------------------------------
1 | Table of Contents
2 | =================
3 |
4 | .. toctree::
5 |
6 | index
7 |
8 | .. toctree::
9 | :maxdepth: 1
10 | :caption: User Documentation
11 |
12 | Download
13 | Install
14 | Guides
15 | Examples
16 | Model Directory
17 |
18 |
19 | .. toctree::
20 | :maxdepth: 2
21 | :caption: Getting Involved
22 |
23 | Community
24 | Publications
25 |
26 |
--------------------------------------------------------------------------------
/doc/download/download.rst:
--------------------------------------------------------------------------------
1 | Download NEST GPU
2 | =================
3 |
4 | You can download NEST GPU from `our GitHub page `_.
5 | Then, please follow the :doc:`installation instructions <../installation/index>`.
6 |
--------------------------------------------------------------------------------
/doc/examples/index.rst:
--------------------------------------------------------------------------------
1 | Examples
2 | ========
3 |
4 | You can find some Python examples and some C++ examples in the directories `python/examples `_ and `c++/examples `_ respectively.
--------------------------------------------------------------------------------
/doc/guides/how_to_record_spikes.rst:
--------------------------------------------------------------------------------
1 | How to record spikes in NEST GPU
2 | ================================
3 |
4 | There are different ways to record spikes in NEST GPU.
5 | The first way is to continuously record the spikes
6 | using the device :doc:`spike_detector <../models/spike_detector>`.
7 |
8 | An alternative way, which is computationally faster than
9 | the ``spike_detector`` device, can be achieved using
10 | the ``RecSpikeTimes`` method.
11 | This method has to be activated before the ``Simulate``
12 | function through the command ``ActivateRecSpikeTimes`` in this way:
13 |
14 | ::
15 |
16 | nestgpu.ActivateRecSpikeTimes(neurons, N_max_spike_times)
17 |
18 | where ``neurons`` is a population of N neurons created using the
19 | ``Create`` function, and ``N_max_spike_times`` is an integer
20 | which sets the maximum amount of spikes that can be recorded
21 | from each neuron of the population (needed to optimize GPU
22 | memory). This method does not enable the recording of
23 | a subset of neurons belonging to a population created in a
24 | single ``Create`` function.
25 |
26 | After the simulation, the spike times of the recorded population
27 | can be obtained using the command ``GetRecSpikeTimes``, which
28 | returns a list of N lists with the spike times for every neuron
29 | of the population:
30 |
31 | ::
32 |
33 | spike_times = nestgpu.GetRecSpikeTimes(neurons)
34 |
35 |
--------------------------------------------------------------------------------
/doc/guides/index.rst:
--------------------------------------------------------------------------------
1 | Guides
2 | ======
3 |
4 | Here you can find details on some topics about NEST GPU.
5 |
6 | .. toctree::
7 | :maxdepth: 1
8 | :caption: In-depth guides to NEST GPU
9 |
10 | differences_nest-gpu_nest
11 | implement_new_neuron_models
12 | how_to_record_spikes
13 |
--------------------------------------------------------------------------------
/doc/logo/nestgpu-logo.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nest/nest-gpu/d3be46f99a542606571449966aae1985c7efac58/doc/logo/nestgpu-logo.pdf
--------------------------------------------------------------------------------
/doc/logo/nestgpu-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nest/nest-gpu/d3be46f99a542606571449966aae1985c7efac58/doc/logo/nestgpu-logo.png
--------------------------------------------------------------------------------
/doc/publications.rst:
--------------------------------------------------------------------------------
1 | NEST GPU Publications
2 | =====================
3 |
4 | * Golosio B, Villamar J, Tiddia G, Pastorelli E, Stapmanns J, Fanti V, Paolucci PS, Morrison A and Senk J. (2023) Runtime Construction of Large-Scale Spiking Neuronal Network Models on GPU Devices. Applied Sciences; 13(17):9598. doi: https://doi.org/10.3390/app13179598
5 |
6 | * Tiddia G, Golosio B, Albers J, Senk J, Simula F, Pronold J, Fanti V, Pastorelli E, Paolucci PS and van Albada SJ (2022) Fast Simulation of a Multi-Area Spiking Network Model of Macaque Cortex on an MPI-GPU Cluster. Front. Neuroinform. 16:883333. doi: https://doi.org/10.3389/fninf.2022.883333
7 |
8 | * Golosio B, Tiddia G, De Luca C, Pastorelli E, Simula F and Paolucci PS (2021) Fast Simulations of Highly-Connected Spiking Cortical Models Using GPUs. Front. Comput. Neurosci. 15:627620. doi: https://doi.org/10.3389/fncom.2021.627620
9 |
--------------------------------------------------------------------------------
/doc/requirements.txt:
--------------------------------------------------------------------------------
1 | nbsphinx
2 | numpy
3 | sphinx_rtd_theme
4 | sphinx-tabs
5 | tqdm
--------------------------------------------------------------------------------
/lib/info.txt:
--------------------------------------------------------------------------------
1 | Dinamic library libnestgpu should be produced in this directory.
2 |
--------------------------------------------------------------------------------
/libnestutil/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # libnestutil/CMakeLists.txt
2 | #
3 | # This file is part of NEST GPU.
4 | #
5 | # Copyright (C) 2004 The NEST Initiative
6 | #
7 | # NEST GPU is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 2 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # NEST GPU is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with NEST GPU. If not, see .
19 |
20 | install( FILES ${PROJECT_BINARY_DIR}/libnestutil/config.h
21 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nestgpu )
22 |
--------------------------------------------------------------------------------
/libnestutil/config.h.in:
--------------------------------------------------------------------------------
1 | #ifndef CONFIG_H
2 | #define CONFIG_H
3 |
4 | /*
5 | config.h is automatically generated from config.h.in during the
6 | configuration process. Please make all changes in config.h.in.
7 | */
8 |
9 | /* Define to 1 if you have the header file. */
10 | #cmakedefine HAVE_DLFCN_H 1
11 |
12 | /* Define to 1 if you have the header file. */
13 | #cmakedefine HAVE_INTTYPES_H 1
14 |
15 | /* Define to 1 if you have the `m' library (-lm). */
16 | #cmakedefine HAVE_LIBM 1
17 |
18 | /* Define to 1 if you have the header file. */
19 | #cmakedefine HAVE_LIMITS_H 1
20 |
21 | /* Define to 1 if you have the header file. */
22 | #cmakedefine HAVE_MEMORY_H 1
23 |
24 | /* Define if you have the MPI library. */
25 | #cmakedefine HAVE_MPI 1
26 |
27 | /* Define to 1 if you have the `pow' function. */
28 | #cmakedefine HAVE_POW 1
29 |
30 | /* Define to 1 if you have the header file. */
31 | #cmakedefine HAVE_STDINT_H 1
32 |
33 | /* Define to 1 if you have the header file. */
34 | #cmakedefine HAVE_STDLIB_H 1
35 |
36 | /* Define to 1 if you have the header file. */
37 | #cmakedefine HAVE_STRINGS_H 1
38 |
39 | /* Define to 1 if you have the header file. */
40 | #cmakedefine HAVE_STRING_H 1
41 |
42 | /* Define to 1 if you have the header file. */
43 | #cmakedefine HAVE_SYS_STAT_H 1
44 |
45 | /* Define to 1 if you have the header file. */
46 | #cmakedefine HAVE_SYS_TYPES_H 1
47 |
48 | /* Define to 1 if you have the header file. */
49 | #cmakedefine HAVE_UNISTD_H 1
50 |
51 | /* Version number of package */
52 | #define VERSION @NEST_GPU_VERSION_STRING@
53 |
54 | #ifndef HAVE_SYS_TYPES_H
55 | /* Define to `unsigned int' if is not defined. */
56 | #define size_t unsigned int
57 | #endif
58 |
59 | #endif // #ifndef CONFIG_H
60 |
--------------------------------------------------------------------------------
/m4/pypath.m4:
--------------------------------------------------------------------------------
1 | AC_DEFUN([adl_CHECK_PYTHON],
2 | [AM_PATH_PYTHON([2.0])
3 | AC_CACHE_CHECK([for $am_display_PYTHON includes directory],
4 | [adl_cv_python_inc],
5 | [adl_cv_python_inc=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()" 2>/dev/null`])
6 | AC_SUBST([PYTHONINC], [$adl_cv_python_inc])])
7 |
--------------------------------------------------------------------------------
/macOS/README:
--------------------------------------------------------------------------------
1 | HOW TO PREPARE A NEW VERSION FOR MACOS HOMEBREW REPOSITORY
2 | Go to the nestgpu git repository folder:
3 | cd ~/NESTGPU
4 | Update the version number in configure.ac and in macOS/nestgpu.rb if necessary. Type:
5 | autoreconf -i
6 | mkdir build
7 | cd build
8 | ../configure
9 | make
10 | sudo make install
11 | To test the installation from source:
12 | Go to the folder python/test and test the software running the scripts:
13 | (if necessary set the PYTHONPATH environment variable to the location of the nestgpu.py module)
14 | ./test_all.sh
15 | ./testp3_all.sh
16 | ./test_mpi.sh
17 | ./testp3_mpi.sh
18 | (unset the PYTHONPATH environment variable if you have defined it before)
19 | Go to the folder MacOS.
20 | cp /usr/local/lib/libnestgpu.so lib/
21 | cp ../pythonlib/nestgpu.py pythonlib/
22 | cd ../build
23 | sudo make uninstall
24 | cd ..
25 | rm -fr build
26 | To test the installation before uploading it to the web:
27 | cd macOS
28 | run the script
29 | sudo ./install.sh ../..
30 | cd ../python/test
31 | ./test_all.sh
32 | ./testp3_all.sh
33 | ./test_mpi.sh
34 | ./testp3_mpi.sh
35 | cd ../../MacOS
36 | sudo ./uninstall.sh
37 | cd ../../..
38 | tar -cvzf NESTGPU_v1.2.2-macOS.tgz NESTGPU/
39 | (change the version appropriately)
40 | Get the file checksum and take note of it:
41 | shasum -a 256 NESTGPU_v1.2.2-macOS.tgz
42 | Open the github page with a browser. Click on "Releases"
43 | Draft a new release. Write version (example v1.2.2-macOS) and upload the tarball.
44 | Go to the homebrew-science/ git repository
45 | cd ~/homebrew-science/
46 | open the file Casks/nestgpu.rb
47 | emacs Casks/nestgpu.rb
48 | and change the version, the sha256, the url of the tarball.
49 | push the changes:
50 | git add Casks/nestgpu.rb
51 | git commit -m 'Version 1.2.2'
52 | git push
53 | Try to install it:
54 | brew cask install nestgpu
55 |
--------------------------------------------------------------------------------
/macOS/info.txt:
--------------------------------------------------------------------------------
1 | macOS distribution folder
2 |
--------------------------------------------------------------------------------
/macOS/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ $# -eq 0 ]
3 | then
4 | echo "No source directory supplied"
5 | exit
6 | fi
7 | srcdir=$1/NESTGPU
8 |
9 | if [ ! -f /usr/local/cuda/lib/libcurand.10.dylib ]; then
10 | echo "File not found /usr/local/cuda/libcurand.10.dylib"
11 | echo "It seems that CUDA toolkit is not properly installed"
12 | echo "Please install it following the instructions in:"
13 | echo "https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html"
14 | exit 1
15 | fi
16 |
17 | # create installation directory if it doesn't exist and clean it
18 | mkdir -p "/usr/local/nestgpu"
19 | rm -fr /usr/local/nestgpu/*
20 | mkdir -p "/usr/local/lib"
21 |
22 | # copy subdirectories
23 | cp -r $srcdir/src /usr/local/nestgpu
24 | cp -r $srcdir/python /usr/local/nestgpu
25 | cp -r $srcdir/c++ /usr/local/nestgpu
26 | cp -r $srcdir/macOS/pythonlib /usr/local/nestgpu
27 | cp -r $srcdir/macOS/lib /usr/local/nestgpu
28 |
29 | #create include directory and copy header file
30 | mkdir /usr/local/nestgpu/include
31 | cp $srcdir/src/nestgpu.h /usr/local/nestgpu/include/
32 |
33 | # find python package directory
34 | SITEDIR=$(python -m site --user-site)
35 | SITEDIR3=$(python3 -m site --user-site)
36 |
37 | # create if it doesn't exist
38 | mkdir -p "$SITEDIR"
39 | mkdir -p "$SITEDIR3"
40 |
41 | # create new .pth file with path to nestgpu python module
42 | echo "/usr/local/nestgpu/pythonlib/" > "$SITEDIR/nestgpu.pth"
43 | echo "/usr/local/nestgpu/pythonlib/" > "$SITEDIR3/nestgpu.pth"
44 |
45 | # create a symbolic link in /usr/local/lib to the dynamic-link library
46 | ln -s /usr/local/nestgpu/lib/libnestgpu.so /usr/local/lib/libnestgpu.so
47 |
--------------------------------------------------------------------------------
/macOS/lib/info.txt:
--------------------------------------------------------------------------------
1 | macOS distribution library folder
2 |
--------------------------------------------------------------------------------
/macOS/nestgpu.rb:
--------------------------------------------------------------------------------
1 | cask 'nestgpu' do
2 | version '1.2.2'
3 | sha256 :no_check
4 |
5 | url "http://0.0.0.0:8000/NESTGPU-macOS-1.2.0.tgz"
6 | name 'Neurongpu'
7 | homepage 'https://github.com/golosio/NESTGPU/wiki'
8 |
9 | depends_on macos: [
10 | :sierra,
11 | :high_sierra,
12 | ]
13 |
14 | depends_on formula: 'libomp'
15 |
16 | depends_on formula: 'openmpi'
17 |
18 | installer script: {
19 | executable: "#{staged_path}/NESTGPU/macOS/install.sh",
20 | args: ["#{staged_path}"],
21 | sudo: true,
22 | }
23 | uninstall script: {
24 | executable: "#{staged_path}/NESTGPU/macOS/uninstall.sh",
25 | sudo: true,
26 | }
27 | caveats "If you have not already done so, for using this software"
28 | caveats "you have to install NVIDIA Web Drivers for your version of macOS,"
29 | caveats "either from this site: https://www.tonymacx86.com/nvidia-drivers/"
30 | caveats "or using homebrew:"
31 | caveats "brew cask install nvidia-web-driver"
32 |
33 | end
34 |
--------------------------------------------------------------------------------
/macOS/uninstall.sh:
--------------------------------------------------------------------------------
1 | # remove installation directory
2 | rm -fr /usr/local/nestgpu
3 |
4 | # find python package directory
5 | SITEDIR=$(python -m site --user-site)
6 | SITEDIR3=$(python3 -m site --user-site)
7 |
8 | # remove .pth file
9 | rm -f "$SITEDIR/nestgpu.pth"
10 | rm -f "$SITEDIR3/nestgpu.pth"
11 |
12 | # remove symbolic link to the dynamic-link library from /usr/local/lib
13 | rm -f /usr/local/lib/libnestgpu.so
14 |
--------------------------------------------------------------------------------
/patch.sh:
--------------------------------------------------------------------------------
1 | echo "Makefile patch for renaming libnestgpu.la to libnestgpu.so"
2 | cat Makefile | sed 's/libnestgpu.la/libnestgpu.so/'> tmpfile
3 | mv tmpfile Makefile
4 |
--------------------------------------------------------------------------------
/postinstall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo "libtool running postinstall.sh"
3 | install_name_tool -change @rpath/libcurand.10.dylib /usr/local/cuda/lib/libcurand.10.dylib /usr/local/lib/libnestgpu.so
4 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [tool.isort]
2 | profile = "black"
3 |
4 | [tool.black]
5 | line-length = 120
6 |
--------------------------------------------------------------------------------
/python/Potjans_2014/log_time_10s_gtx1050mob.txt:
--------------------------------------------------------------------------------
1 | 9970.100
2 | 9980.100
3 | 9990.100
4 | 10000.100
5 |
6 | SpikeBufferUpdate_time: 5.4432
7 | poisson_generator_time: 14.1657
8 | neuron_Update_time: 6.83508
9 | copy_ext_spike_time: 0
10 | SendExternalSpike_time: 0
11 | SendSpikeToRemote_time: 0
12 | RecvSpikeFromRemote_time: 0
13 | NestedLoop_time: 25.1129
14 | GetSpike_time: 4.0969
15 | SpikeReset_time: 1.47109
16 | ExternalSpikeReset_time: 0
17 | Build real time = 61.468404
18 | Simulation real time = 58.720442
19 |
20 | Times:
21 | Total time: 119.988 s
22 | Time to initialize: 0.001 s
23 | Time to create: 3.572 s
24 | Time to connect: 54.720 s
25 | Time to calibrate: 2.975 s
26 | Time to simulate: 58.721 s
27 |
--------------------------------------------------------------------------------
/python/Potjans_2014/log_time_10s_gtx1050mob_b.txt:
--------------------------------------------------------------------------------
1 | 9980.100
2 | 9990.100
3 | 10000.100
4 |
5 | SpikeBufferUpdate_time: 5.46896
6 | poisson_generator_time: 14.22
7 | neuron_Update_time: 6.81275
8 | copy_ext_spike_time: 0
9 | SendExternalSpike_time: 0
10 | SendSpikeToRemote_time: 0
11 | RecvSpikeFromRemote_time: 0
12 | NestedLoop_time: 25.5739
13 | GetSpike_time: 4.04125
14 | SpikeReset_time: 1.47209
15 | ExternalSpikeReset_time: 0
16 | Build real time = 61.078281
17 | Simulation real time = 59.141828
18 |
19 | Times:
20 | Total time: 119.954 s
21 | Time to initialize: 0.001 s
22 | Time to create: 3.471 s
23 | Time to connect: 54.384 s
24 | Time to calibrate: 2.956 s
25 | Time to simulate: 59.142 s
26 |
--------------------------------------------------------------------------------
/python/Potjans_2014/log_time_10s_gtx1050mob_cde.txt:
--------------------------------------------------------------------------------
1 | 9980.100
2 | 9990.100
3 | 10000.100
4 |
5 | SpikeBufferUpdate_time: 5.60435
6 | poisson_generator_time: 14.2593
7 | neuron_Update_time: 7.17554
8 | copy_ext_spike_time: 0
9 | SendExternalSpike_time: 0
10 | SendSpikeToRemote_time: 0
11 | RecvSpikeFromRemote_time: 0
12 | NestedLoop_time: 23.9151
13 | GetSpike_time: 4.14154
14 | SpikeReset_time: 1.55617
15 | ExternalSpikeReset_time: 0
16 | Build real time = 59.962113
17 | Simulation real time = 58.118082
18 |
19 | Times:
20 | Total time: 117.812 s
21 | Time to initialize: 0.001 s
22 | Time to create: 3.331 s
23 | Time to connect: 53.476 s
24 | Time to calibrate: 2.891 s
25 | Time to simulate: 58.114 s
26 |
--------------------------------------------------------------------------------
/python/Potjans_2014/log_time_10s_gtx1050mob_g_cde.txt:
--------------------------------------------------------------------------------
1 | 9980.100
2 | 9990.100
3 | 10000.100
4 |
5 | SpikeBufferUpdate_time: 5.61054
6 | poisson_generator_time: 14.261
7 | neuron_Update_time: 6.37199
8 | copy_ext_spike_time: 0
9 | SendExternalSpike_time: 0
10 | SendSpikeToRemote_time: 0
11 | RecvSpikeFromRemote_time: 0
12 | NestedLoop_time: 24.1544
13 | GetSpike_time: 4.14891
14 | SpikeReset_time: 1.56336
15 | ExternalSpikeReset_time: 0
16 | Build real time = 61.708650
17 | Simulation real time = 57.645261
18 |
19 | Times:
20 | Total time: 118.356 s
21 | Time to initialize: 0.012 s
22 | Time to create: 3.385 s
23 | Time to connect: 54.386 s
24 | Time to calibrate: 2.928 s
25 | Time to simulate: 57.646 s
26 |
--------------------------------------------------------------------------------
/python/Potjans_2014/script.sh:
--------------------------------------------------------------------------------
1 | for i in $(seq 0 9); do
2 | cat sim_params.templ | sed "s/__seed__/1234$i/" > sim_params.py
3 | python3 run_microcircuit.py
4 | mv data data$i
5 | done
6 |
--------------------------------------------------------------------------------
/python/Potjans_2014/script_eval_time.sh:
--------------------------------------------------------------------------------
1 | for i in $(seq 0 9); do
2 | cat sim_params_norec.templ | sed "s/__seed__/1234$i/" > sim_params_norec.py
3 | python3 eval_microcircuit_time.py | tee log$i.txt
4 | done
5 |
--------------------------------------------------------------------------------
/python/Potjans_2014_hc/log_time_10s_gtx1050mob.txt:
--------------------------------------------------------------------------------
1 | 9970.100
2 | 9980.100
3 | 9990.100
4 | 10000.100
5 |
6 | SpikeBufferUpdate_time: 5.4432
7 | poisson_generator_time: 14.1657
8 | neuron_Update_time: 6.83508
9 | copy_ext_spike_time: 0
10 | SendExternalSpike_time: 0
11 | SendSpikeToRemote_time: 0
12 | RecvSpikeFromRemote_time: 0
13 | NestedLoop_time: 25.1129
14 | GetSpike_time: 4.0969
15 | SpikeReset_time: 1.47109
16 | ExternalSpikeReset_time: 0
17 | Build real time = 61.468404
18 | Simulation real time = 58.720442
19 |
20 | Times:
21 | Total time: 119.988 s
22 | Time to initialize: 0.001 s
23 | Time to create: 3.572 s
24 | Time to connect: 54.720 s
25 | Time to calibrate: 2.975 s
26 | Time to simulate: 58.721 s
27 |
--------------------------------------------------------------------------------
/python/Potjans_2014_hc/log_time_10s_gtx1050mob_b.txt:
--------------------------------------------------------------------------------
1 | 9980.100
2 | 9990.100
3 | 10000.100
4 |
5 | SpikeBufferUpdate_time: 5.46896
6 | poisson_generator_time: 14.22
7 | neuron_Update_time: 6.81275
8 | copy_ext_spike_time: 0
9 | SendExternalSpike_time: 0
10 | SendSpikeToRemote_time: 0
11 | RecvSpikeFromRemote_time: 0
12 | NestedLoop_time: 25.5739
13 | GetSpike_time: 4.04125
14 | SpikeReset_time: 1.47209
15 | ExternalSpikeReset_time: 0
16 | Build real time = 61.078281
17 | Simulation real time = 59.141828
18 |
19 | Times:
20 | Total time: 119.954 s
21 | Time to initialize: 0.001 s
22 | Time to create: 3.471 s
23 | Time to connect: 54.384 s
24 | Time to calibrate: 2.956 s
25 | Time to simulate: 59.142 s
26 |
--------------------------------------------------------------------------------
/python/Potjans_2014_hc/log_time_10s_gtx1050mob_cde.txt:
--------------------------------------------------------------------------------
1 | 9980.100
2 | 9990.100
3 | 10000.100
4 |
5 | SpikeBufferUpdate_time: 5.60435
6 | poisson_generator_time: 14.2593
7 | neuron_Update_time: 7.17554
8 | copy_ext_spike_time: 0
9 | SendExternalSpike_time: 0
10 | SendSpikeToRemote_time: 0
11 | RecvSpikeFromRemote_time: 0
12 | NestedLoop_time: 23.9151
13 | GetSpike_time: 4.14154
14 | SpikeReset_time: 1.55617
15 | ExternalSpikeReset_time: 0
16 | Build real time = 59.962113
17 | Simulation real time = 58.118082
18 |
19 | Times:
20 | Total time: 117.812 s
21 | Time to initialize: 0.001 s
22 | Time to create: 3.331 s
23 | Time to connect: 53.476 s
24 | Time to calibrate: 2.891 s
25 | Time to simulate: 58.114 s
26 |
--------------------------------------------------------------------------------
/python/Potjans_2014_hc/script.sh:
--------------------------------------------------------------------------------
1 | for i in $(seq 0 9); do
2 | cat sim_params.templ | sed "s/__seed__/1234$i/" > sim_params.py
3 | python3 run_microcircuit.py
4 | mv data data$i
5 | done
6 |
--------------------------------------------------------------------------------
/python/Potjans_2014_s/log_time_10s_gtx1050mob.txt:
--------------------------------------------------------------------------------
1 | 9970.100
2 | 9980.100
3 | 9990.100
4 | 10000.100
5 |
6 | SpikeBufferUpdate_time: 7.70698
7 | poisson_generator_time: 0
8 | neuron_Update_time: 27.6643
9 | copy_ext_spike_time: 0
10 | SendExternalSpike_time: 0
11 | SendSpikeToRemote_time: 0
12 | RecvSpikeFromRemote_time: 0
13 | NestedLoop_time: 26.118
14 | GetSpike_time: 27.6134
15 | SpikeReset_time: 1.02209
16 | ExternalSpikeReset_time: 0
17 | Build real time = 60.323811
18 | Simulation real time = 93.485882
19 |
20 | Times:
21 | Total time: 153.604 s
22 | Time to initialize: 0.001 s
23 | Time to create: 3.325 s
24 | Time to connect: 53.894 s
25 | Time to calibrate: 2.898 s
26 | Time to simulate: 93.486 s
27 |
--------------------------------------------------------------------------------
/python/Potjans_2014_s/log_time_10s_gtx1050mob_b.txt:
--------------------------------------------------------------------------------
1 | 9980.100
2 | 9990.100
3 | 10000.100
4 |
5 | SpikeBufferUpdate_time: 7.73518
6 | poisson_generator_time: 14.4706
7 | neuron_Update_time: 28.6859
8 | copy_ext_spike_time: 0
9 | SendExternalSpike_time: 0
10 | SendSpikeToRemote_time: 0
11 | RecvSpikeFromRemote_time: 0
12 | NestedLoop_time: 26.3585
13 | GetSpike_time: 7.26078
14 | SpikeReset_time: 1.13737
15 | ExternalSpikeReset_time: 0
16 | Build real time = 61.179162
17 | Simulation real time = 89.148102
18 |
19 | Times:
20 | Total time: 150.032 s
21 | Time to initialize: 0.001 s
22 | Time to create: 3.435 s
23 | Time to connect: 54.511 s
24 | Time to calibrate: 2.936 s
25 | Time to simulate: 89.149 s
26 |
--------------------------------------------------------------------------------
/python/Potjans_2014_s/log_time_10s_gtx1050mob_c.txt:
--------------------------------------------------------------------------------
1 | 9970.100
2 | 9980.100
3 | 9990.100
4 | 10000.100
5 |
6 | SpikeBufferUpdate_time: 7.98513
7 | poisson_generator_time: 14.6824
8 | neuron_Update_time: 22.2784
9 | copy_ext_spike_time: 0
10 | SendExternalSpike_time: 0
11 | SendSpikeToRemote_time: 0
12 | RecvSpikeFromRemote_time: 0
13 | NestedLoop_time: 27.8786
14 | GetSpike_time: 7.09352
15 | SpikeReset_time: 1.39474
16 | ExternalSpikeReset_time: 0
17 | Build real time = 61.780456
18 | Simulation real time = 85.018697
19 |
20 | Times:
21 | Total time: 146.518 s
22 | Time to initialize: 0.001 s
23 | Time to create: 3.598 s
24 | Time to connect: 54.839 s
25 | Time to calibrate: 3.062 s
26 | Time to simulate: 85.019 s
27 |
--------------------------------------------------------------------------------
/python/Potjans_2014_s/log_time_10s_gtx1050mob_ring_spike_buffer.txt:
--------------------------------------------------------------------------------
1 | 9980.100
2 | 9990.100
3 | 10000.100
4 |
5 | SpikeBufferUpdate_time: 11.1038
6 | poisson_generator_time: 14.6276
7 | neuron_Update_time: 22.5145
8 | copy_ext_spike_time: 0
9 | SendExternalSpike_time: 0
10 | SendSpikeToRemote_time: 0
11 | RecvSpikeFromRemote_time: 0
12 | NestedLoop_time: 26.8862
13 | GetSpike_time: 7.09354
14 | SpikeReset_time: 1.36537
15 | ExternalSpikeReset_time: 0
16 | Build real time = 60.817244
17 | Simulation real time = 87.142144
18 |
19 | Times:
20 | Total time: 147.697 s
21 | Time to initialize: 0.001 s
22 | Time to create: 3.357 s
23 | Time to connect: 54.246 s
24 | Time to calibrate: 2.952 s
25 | Time to simulate: 87.142 s
26 |
--------------------------------------------------------------------------------
/python/Potjans_2014_s/script.sh:
--------------------------------------------------------------------------------
1 | for i in $(seq 0 9); do
2 | cat sim_params.templ | sed "s/__seed__/1234$i/" > sim_params.py
3 | python3 run_microcircuit.py
4 | mv data data$i
5 | done
6 |
--------------------------------------------------------------------------------
/python/examples/example1.py:
--------------------------------------------------------------------------------
1 | import nestgpu as ngpu
2 |
3 | neuron = ngpu.Create("aeif_cond_beta")
4 |
5 | ngpu.SetStatus(neuron, {"I_e":1000.0})
6 |
7 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
8 |
9 | ngpu.Simulate()
10 |
11 | data_list = ngpu.GetRecordData(record)
12 | t=[row[0] for row in data_list]
13 | V_m=[row[1] for row in data_list]
14 |
15 | import matplotlib.pyplot as plt
16 |
17 | plt.figure(1)
18 | plt.plot(t, V_m)
19 |
20 | plt.draw()
21 | plt.pause(1)
22 | ngpu.waitenter("")
23 | plt.close()
24 |
--------------------------------------------------------------------------------
/python/examples/example2.py:
--------------------------------------------------------------------------------
1 | import nestgpu as ngpu
2 |
3 | neuron = ngpu.Create("aeif_cond_beta")
4 | poiss_gen = ngpu.Create("poisson_generator");
5 |
6 | ngpu.SetStatus(poiss_gen, "rate", 12000.0)
7 |
8 | conn_dict={"rule": "one_to_one"}
9 | syn_dict={"weight": 0.05, "delay": 2.0, "receptor":0}
10 |
11 | ngpu.Connect(poiss_gen, neuron, conn_dict, syn_dict)
12 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
13 |
14 | ngpu.Simulate()
15 |
16 | data_list = ngpu.GetRecordData(record)
17 | t=[row[0] for row in data_list]
18 | V_m=[row[1] for row in data_list]
19 |
20 | import matplotlib.pyplot as plt
21 |
22 | plt.figure(1)
23 | plt.plot(t, V_m)
24 |
25 | plt.draw()
26 | plt.pause(1)
27 | ngpu.waitenter("")
28 | plt.close()
29 |
--------------------------------------------------------------------------------
/python/examples/plot_aeif_cond_alpha.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0001
5 | neuron = ngpu.Create('aeif_cond_alpha', 1)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6,
7 | "g_L":300.0, 'E_rev_ex':20.0, 'E_rev_in': -85.0,
8 | 'tau_syn_ex':40.0, 'tau_syn_in': 20.0})
9 |
10 | spike = ngpu.Create("spike_generator")
11 | spike_times = [10.0, 400.0]
12 | n_spikes = 2
13 |
14 | # set spike times and heights
15 | ngpu.SetStatus(spike, {"spike_times": spike_times})
16 | delay = [1.0, 100.0]
17 | weight = [0.1, 0.2]
18 |
19 | conn_spec={"rule": "all_to_all"}
20 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
21 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
22 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
23 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
24 |
25 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
26 |
27 | ngpu.Simulate(800.0)
28 |
29 | data_list = ngpu.GetRecordData(record)
30 | t=[row[0] for row in data_list]
31 | V_m=[row[1] for row in data_list]
32 |
33 | data = np.loadtxt('../test/test_aeif_cond_alpha_nest.txt', delimiter="\t")
34 | t1=[x[0] for x in data ]
35 | V_m1=[x[1] for x in data ]
36 | print (len(t))
37 | print (len(t1))
38 |
39 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
40 | #print(dV)
41 | rmse =np.std(dV)/abs(np.mean(V_m))
42 | print("rmse : ", rmse, " tolerance: ", tolerance)
43 | #if rmse>tolerance:
44 | # sys.exit(1)
45 | #sys.exit(0)
46 |
47 | import matplotlib.pyplot as plt
48 |
49 | fig1 = plt.figure(1)
50 | plt.plot(t, V_m, "r-", label="NEST GPU")
51 | plt.plot(t1, V_m1, "b--", label="NEST")
52 | plt.legend()
53 | plt.draw()
54 | plt.pause(1)
55 | ngpu.waitenter("")
56 | plt.close()
57 |
--------------------------------------------------------------------------------
/python/examples/plot_aeif_cond_alpha_multisynapse.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('aeif_cond_alpha_multisynapse', 1, 3)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6,
7 | "g_L":300.0, 'E_rev':[20.0, 0.0, -85.0], \
8 | 'tau_syn':[40.0, 20.0, 30.0]})
9 | spike = ngpu.Create("spike_generator")
10 | spike_times = [10.0, 400.0]
11 | n_spikes = 2
12 |
13 | # set spike times and heights
14 | ngpu.SetStatus(spike, {"spike_times": spike_times})
15 | delay = [1.0, 100.0, 130.0]
16 | weight = [0.1, 0.2, 0.5]
17 |
18 | conn_spec={"rule": "all_to_all"}
19 | for syn in range(3):
20 | syn_spec={'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]}
21 | ngpu.Connect(spike, neuron, conn_spec, syn_spec)
22 |
23 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
24 | #voltmeter = nest.Create('voltmeter')
25 | #nest.Connect(voltmeter, neuron)
26 |
27 | ngpu.Simulate(800.0)
28 |
29 | data_list = ngpu.GetRecordData(record)
30 | t=[row[0] for row in data_list]
31 | V_m=[row[1] for row in data_list]
32 | #dmm = nest.GetStatus(voltmeter)[0]
33 | #V_m = dmm["events"]["V_m"]
34 | #t = dmm["events"]["times"]
35 | #with open('test_aeif_cond_alpha_nest.txt', 'w') as f:
36 | # for i in range(len(t)):
37 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
38 |
39 | data = np.loadtxt('../test/test_aeif_cond_alpha_multisynapse_nest.txt', delimiter="\t")
40 | t1=[x[0] for x in data ]
41 | V_m1=[x[1] for x in data ]
42 | print (len(t))
43 | print (len(t1))
44 |
45 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
46 | rmse =np.std(dV)/abs(np.mean(V_m))
47 | print("rmse : ", rmse, " tolerance: ", tolerance)
48 | #if rmse>tolerance:
49 | # sys.exit(1)
50 |
51 | #sys.exit(0)
52 | import matplotlib.pyplot as plt
53 |
54 | fig1 = plt.figure(1)
55 | plt.plot(t, V_m, "r-", label="NEST GPU")
56 | plt.plot(t1, V_m1, "b--", label="NEST")
57 | plt.legend()
58 | plt.draw()
59 | plt.pause(1)
60 | ngpu.waitenter("")
61 | plt.close()
62 |
--------------------------------------------------------------------------------
/python/examples/plot_aeif_cond_beta.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.00005
5 | neuron = ngpu.Create('aeif_cond_beta', 1)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, "g_L":300.0,
7 | 'E_rev_ex': 20.0, 'E_rev_in': -85.0,
8 | 'tau_decay_ex': 40.0,
9 | 'tau_decay_in': 20.0,
10 | 'tau_rise_ex': 20.0,
11 | 'tau_rise_in': 5.0})
12 | spike = ngpu.Create("spike_generator")
13 | spike_times = [10.0, 400.0]
14 | n_spikes = 2
15 |
16 | # set spike times and heights
17 | ngpu.SetStatus(spike, {"spike_times": spike_times})
18 | delay = [1.0, 100.0]
19 | weight = [0.1, 0.2]
20 |
21 | conn_spec={"rule": "all_to_all"}
22 | for syn in range(2):
23 | syn_spec={'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]}
24 | ngpu.Connect(spike, neuron, conn_spec, syn_spec)
25 |
26 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
27 |
28 | ngpu.Simulate(800.0)
29 |
30 | data_list = ngpu.GetRecordData(record)
31 | t=[row[0] for row in data_list]
32 | V_m=[row[1] for row in data_list]
33 |
34 | data = np.loadtxt('../test/test_aeif_cond_beta_nest.txt', delimiter="\t")
35 | t1=[x[0] for x in data ]
36 | V_m1=[x[1] for x in data ]
37 | print (len(t))
38 | print (len(t1))
39 |
40 |
41 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
42 | rmse =np.std(dV)/abs(np.mean(V_m))
43 | print("rmse : ", rmse, " tolerance: ", tolerance)
44 | #if rmse>tolerance:
45 | # sys.exit(1)
46 | #sys.exit(0)
47 |
48 | import matplotlib.pyplot as plt
49 |
50 | fig1 = plt.figure(1)
51 | plt.plot(t, V_m, "r-", label="NEST GPU")
52 | plt.plot(t1, V_m1, "b--", label="NEST")
53 | plt.legend()
54 | plt.draw()
55 | plt.pause(1)
56 | ngpu.waitenter("")
57 | plt.close()
58 |
--------------------------------------------------------------------------------
/python/examples/plot_fast_iaf_psc_exp.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 |
6 | E_L = -65.0
7 |
8 | ngpu.SetKernelStatus("verbosity_level", 0)
9 | neuron = ngpu.Create('iaf_psc_exp_g', 1)
10 |
11 | spike = ngpu.Create("spike_generator")
12 | spike_times = [10.0, 400.0]
13 | n_spikes = 2
14 |
15 | # set spike times and height
16 | ngpu.SetStatus(spike, {"spike_times": spike_times})
17 | delay = [1.0, 100.0]
18 | weight = [1.0, -2.0]
19 |
20 | conn_spec={"rule": "all_to_all"}
21 |
22 |
23 | syn_spec_ex={'weight': weight[0], 'delay': delay[0]}
24 | syn_spec_in={'weight': weight[1], 'delay': delay[1]}
25 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
26 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
27 |
28 | record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0])
29 | #voltmeter = nest.Create('voltmeter')
30 | #nest.Connect(voltmeter, neuron)
31 |
32 | ngpu.Simulate(800.0)
33 |
34 | data_list = ngpu.GetRecordData(record)
35 | t=[row[0] for row in data_list]
36 | V_m=[row[1]+E_L for row in data_list]
37 | #dmm = nest.GetStatus(voltmeter)[0]
38 | #V_m = dmm["events"]["V_m"]
39 | #t = dmm["events"]["times"]
40 | #with open('test_iaf_psc_exp_nest.txt', 'w') as f:
41 | # for i in range(len(t)):
42 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
43 |
44 | data = np.loadtxt('../test/test_fast_iaf_psc_exp_nest.txt', delimiter="\t")
45 | t1=[x[0] for x in data ]
46 | V_m1=[x[1] for x in data ]
47 | #print (len(t))
48 | #print (len(t1))
49 |
50 | #dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
51 | #rmse =np.std(dV)/abs(np.mean(V_m))
52 | #print("rmse : ", rmse, " tolerance: ", tolerance)
53 | #if rmse>tolerance:
54 | # sys.exit(1)
55 |
56 | #sys.exit(0)
57 | import matplotlib.pyplot as plt
58 |
59 | fig1 = plt.figure(1)
60 | plt.plot(t, V_m, "r-", label="NEST GPU")
61 | plt.plot(t1, V_m1, "b--", label="NEST")
62 | plt.legend()
63 | plt.draw()
64 | plt.pause(1)
65 | ngpu.waitenter("")
66 | plt.close()
67 |
--------------------------------------------------------------------------------
/python/examples/plot_iaf_psc_alpha.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 |
5 | """
6 | This example provides a comparison of
7 | the iaf_psc_alpha implementation in NEST and
8 | NEST GPU. A neuron is injected with two spikes
9 | and the plot shows the neuron membrane potential,
10 | compared with the one obtained with
11 | an analogous NEST simulation.
12 |
13 | """
14 |
15 | neuron = ngpu.Create('iaf_psc_alpha')
16 | spike = ngpu.Create("spike_generator")
17 | spike_times = [10.0, 400.0]
18 | n_spikes = 2
19 |
20 | print(ngpu.GetStatus(neuron))
21 | ngpu.SetStatus(neuron, {"tau_syn_ex": 10.0, "tau_syn_in": 5.0})
22 |
23 | # set spike times and height
24 | ngpu.SetStatus(spike, {"spike_times": spike_times})
25 | delay = [1.0, 100.0]
26 | weight = [1.0, -2.0]
27 |
28 | conn_spec={"rule": "all_to_all"}
29 |
30 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
31 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
32 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
33 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
34 |
35 | record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0])
36 |
37 | ngpu.Simulate(800.0)
38 |
39 | data_list = ngpu.GetRecordData(record)
40 | t=[row[0] for row in data_list]
41 | V_m=[-70.0+row[1] for row in data_list]
42 |
43 | data = np.loadtxt('../test/test_iaf_psc_alpha_nest.txt', delimiter="\t")
44 | t1=[x[0]+0.1 for x in data ]
45 | V_m1=[x[1] for x in data ]
46 | print (len(t))
47 | print (len(t1))
48 |
49 | import matplotlib.pyplot as plt
50 |
51 | fig1 = plt.figure(1)
52 | plt.plot(t, V_m, "r-", label="NEST GPU")
53 | plt.plot(t1, V_m1, "b--", label="NEST")
54 | plt.legend()
55 | plt.draw()
56 | plt.pause(1)
57 | ngpu.waitenter("")
58 | plt.close()
59 |
--------------------------------------------------------------------------------
/python/examples/plot_iaf_psc_exp.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('iaf_psc_exp', 1)
6 | spike = ngpu.Create("spike_generator")
7 | spike_times = [10.0, 400.0]
8 | n_spikes = 2
9 |
10 | # set spike times and height
11 | ngpu.SetStatus(spike, {"spike_times": spike_times})
12 | delay = [1.0, 100.0]
13 | weight = [1.0, -2.0]
14 |
15 | conn_spec={"rule": "all_to_all"}
16 |
17 |
18 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
19 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
20 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
21 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
22 |
23 | record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0])
24 | #voltmeter = nest.Create('voltmeter')
25 | #nest.Connect(voltmeter, neuron)
26 |
27 | ngpu.Simulate(800.0)
28 |
29 | data_list = ngpu.GetRecordData(record)
30 | t=[row[0] for row in data_list]
31 | V_m=[-70.0+row[1] for row in data_list]
32 | #dmm = nest.GetStatus(voltmeter)[0]
33 | #V_m = dmm["events"]["V_m"]
34 | #t = dmm["events"]["times"]
35 | #with open('test_iaf_psc_exp_nest.txt', 'w') as f:
36 | # for i in range(len(t)):
37 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
38 |
39 | data = np.loadtxt('../test/test_iaf_psc_exp_nest.txt', delimiter="\t")
40 | t1=[x[0] for x in data ]
41 | V_m1=[x[1] for x in data ]
42 | #print (len(t))
43 | #print (len(t1))
44 |
45 | #dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
46 | #rmse =np.std(dV)/abs(np.mean(V_m))
47 | #print("rmse : ", rmse, " tolerance: ", tolerance)
48 | #if rmse>tolerance:
49 | # sys.exit(1)
50 |
51 | #sys.exit(0)
52 | import matplotlib.pyplot as plt
53 |
54 | fig1 = plt.figure(1)
55 | plt.plot(t, V_m, "r-", label="NEST GPU")
56 | plt.plot(t1, V_m1, "b--", label="NEST")
57 | plt.legend()
58 | plt.draw()
59 | plt.pause(1)
60 | ngpu.waitenter("")
61 | plt.close()
62 |
--------------------------------------------------------------------------------
/python/examples/plot_iaf_psc_exp_g.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('iaf_psc_exp_g', 1)
6 | spike = ngpu.Create("spike_generator")
7 | spike_times = [10.0, 400.0]
8 | n_spikes = 2
9 |
10 | # set spike times and height
11 | ngpu.SetStatus(spike, {"spike_times": spike_times})
12 | delay = [1.0, 100.0]
13 | weight = [1.0, -2.0]
14 |
15 | conn_spec={"rule": "all_to_all"}
16 |
17 |
18 | syn_spec_ex={'weight': weight[0], 'delay': delay[0]}
19 | syn_spec_in={'weight': weight[1], 'delay': delay[1]}
20 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
21 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
22 |
23 | record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0])
24 | #voltmeter = nest.Create('voltmeter')
25 | #nest.Connect(voltmeter, neuron)
26 |
27 | ngpu.Simulate(800.0)
28 |
29 | data_list = ngpu.GetRecordData(record)
30 | t=[row[0] for row in data_list]
31 | V_m=[-65.0+row[1] for row in data_list]
32 | #dmm = nest.GetStatus(voltmeter)[0]
33 | #V_m = dmm["events"]["V_m"]
34 | #t = dmm["events"]["times"]
35 | #with open('test_iaf_psc_exp_nest.txt', 'w') as f:
36 | # for i in range(len(t)):
37 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
38 |
39 | data = np.loadtxt('../test/test_fast_iaf_psc_exp_nest.txt', delimiter="\t")
40 | t1=[x[0] for x in data ]
41 | V_m1=[x[1] for x in data ]
42 | #print (len(t))
43 | #print (len(t1))
44 |
45 | #dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
46 | #rmse =np.std(dV)/abs(np.mean(V_m))
47 | #print("rmse : ", rmse, " tolerance: ", tolerance)
48 | #if rmse>tolerance:
49 | # sys.exit(1)
50 |
51 | #sys.exit(0)
52 | import matplotlib.pyplot as plt
53 |
54 | fig1 = plt.figure(1)
55 | plt.plot(t, V_m, "r-", label="NEST GPU")
56 | plt.plot(t1, V_m1, "b--", label="NEST")
57 | plt.legend()
58 | plt.draw()
59 | plt.pause(1)
60 | ngpu.waitenter("")
61 | plt.close()
62 |
--------------------------------------------------------------------------------
/python/examples/plot_izh.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('izhikevich', 1)
6 | #ngpu.SetStatus(neuron, {"tau_syn": 1.0e-6})
7 | spike = ngpu.Create("spike_generator")
8 | spike_times = [10.0, 40.0]
9 | n_spikes = 2
10 |
11 | # set spike times and height
12 | ngpu.SetStatus(spike, {"spike_times": spike_times})
13 | delay = [1.0, 10.0]
14 | weight = [1.0, -2.0]
15 |
16 | conn_spec={"rule": "all_to_all"}
17 |
18 |
19 | syn_spec_ex={'weight': weight[0], 'delay': delay[0]}
20 | syn_spec_in={'weight': weight[1], 'delay': delay[1]}
21 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
22 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
23 |
24 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
25 | #voltmeter = nest.Create('voltmeter')
26 | #nest.Connect(voltmeter, neuron)
27 |
28 | ngpu.Simulate(80.0)
29 |
30 | data_list = ngpu.GetRecordData(record)
31 | t=[row[0] for row in data_list]
32 | V_m=[row[1] for row in data_list]
33 | #dmm = nest.GetStatus(voltmeter)[0]
34 | #V_m = dmm["events"]["V_m"]
35 | #t = dmm["events"]["times"]
36 | #with open('test_iaf_psc_exp_nest.txt', 'w') as f:
37 | # for i in range(len(t)):
38 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
39 |
40 | data = np.loadtxt('../test/test_izh_nest.txt', delimiter="\t")
41 | t1=[x[0] for x in data ]
42 | V_m1=[x[1] for x in data ]
43 | #print (len(t))
44 | #print (len(t1))
45 |
46 | #dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
47 | #rmse =np.std(dV)/abs(np.mean(V_m))
48 | #print("rmse : ", rmse, " tolerance: ", tolerance)
49 | #if rmse>tolerance:
50 | # sys.exit(1)
51 |
52 | #sys.exit(0)
53 | import matplotlib.pyplot as plt
54 |
55 | fig1 = plt.figure(1)
56 | plt.plot(t, V_m, "r-", label="NEST GPU")
57 | plt.plot(t1, V_m1, "b--", label="NEST")
58 | plt.legend()
59 | plt.draw()
60 | plt.pause(1)
61 | ngpu.waitenter("")
62 | plt.close()
63 |
--------------------------------------------------------------------------------
/python/test/err.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 |
4 | tolerance = 1.0e-6
5 |
6 | neuron = ngpu.Create("aeif_cond_beta", 3)
7 |
8 | ngpu.SetStatus(neuron, {"I_e":1000.0})
9 |
10 | spike_det = ngpu.Create("spike_detector")
11 |
12 |
13 | conn_dict={"rule": "one_to_one"}
14 | syn_dict1={"weight": 1.0, "delay": 10.0, "receptor":0}
15 | syn_dict2={"weight": 2.0, "delay": 20.0, "receptor":0}
16 | syn_dict3={"weight": 3.0, "delay": 30.0, "receptor":0}
17 |
18 | ngpu.Connect(neuron[0:0], spike_det, conn_dict, syn_dict1)
19 |
20 | ngpu.Connect(neuron[1:1], spike_det, conn_dict, syn_dict2)
21 |
22 | ngpu.Connect(neuron[2:2], spike_det, conn_dict, syn_dict3)
23 |
24 | record_n = ngpu.CreateRecord("", ["spike"], [neuron[0]], [0])
25 |
26 | record_sd = ngpu.CreateRecord("", ["spike_height"], [spike_det[0]], [0])
27 |
28 | ngpu.Simulate()
29 |
30 | data_n = ngpu.GetRecordData(record_n)
31 | t_n=[row[0] for row in data_n]
32 | spike_n=[row[1] for row in data_n]
33 |
34 | data_sd = ngpu.GetRecordData(record_sd)
35 | t_sd=[row[0] for row in data_sd]
36 | spike_sd=[row[1] for row in data_sd]
37 |
38 | for i in range(len(t_n)-400):
39 | if spike_n[i]>0.5:
40 | j1 = i + 101
41 | j2 = i + 201
42 | j3 = i + 301
43 | if abs(spike_sd[j1] - 1.0)>tolerance:
44 | print("Expected spike height: 1.0, simulated: ", spike_sd[j1])
45 | sys.exit(1)
46 | if abs(spike_sd[j2] - 2.0)>tolerance:
47 | print("Expected spike height: 2.0, simulated: ", spike_sd[j2])
48 | sys.exit(1)
49 | if abs(spike_sd[j3] - 3.0)>tolerance:
50 | print("Expected spike height: 3.0, simulated: ", spike_sd[j3])
51 | sys.exit(1)
52 |
53 | #import matplotlib.pyplot as plt
54 |
55 | #plt.figure(1)
56 | #plt.plot(t_n, spike_n)
57 |
58 | #plt.figure(2)
59 | #plt.plot(t_sd, spike_sd)
60 |
61 | #plt.draw()
62 | #plt.pause(1)
63 | #raw_input("")
64 | #plt.close()
65 | sys.exit(1)
66 |
--------------------------------------------------------------------------------
/python/test/logp3_getarr.txt:
--------------------------------------------------------------------------------
1 |
2 | -- NEST GPU --
3 |
4 | Copyright (C) 2021 The NEST Initiative
5 |
6 | This program is provided AS IS and comes with
7 | NO WARRANTY. See the file LICENSE for details.
8 |
9 | Homepage: https://github.com/nest/nest-gpu
10 |
11 | [[10.0, 400.0], [10.0, 400.0]]
12 | [[1.0, 0.5], [1.0, 0.5]]
13 |
14 | [[4.0]]
15 | [[2.0]]
16 |
17 | [[50.0, 20.0, 80.0]]
18 | [[0.10000000149011612, 0.30000001192092896, 0.20000000298023224]]
19 |
20 |
21 | [[4.0], [50.0, 20.0, 80.0], [10.0, 400.0], [10.0, 400.0]]
22 | [[2.0], [0.10000000149011612, 0.30000001192092896, 0.20000000298023224], [1.0, 0.5], [1.0, 0.5]]
23 |
24 |
25 | [{'spike_times': [4.0], 'spike_heights': [2.0]}]
26 |
27 |
28 | [{'spike_times': [4.0], 'spike_heights': [2.0]}, {'spike_times': [50.0, 20.0, 80.0], 'spike_heights': [0.10000000149011612, 0.30000001192092896, 0.20000000298023224]}, {'spike_times': [10.0, 400.0], 'spike_heights': [1.0, 0.5]}, {'spike_times': [10.0, 400.0], 'spike_heights': [1.0, 0.5]}]
29 |
--------------------------------------------------------------------------------
/python/test/logp3_setvar2.txt:
--------------------------------------------------------------------------------
1 |
2 | -- NEST GPU --
3 |
4 | Copyright (C) 2021 The NEST Initiative
5 |
6 | This program is provided AS IS and comes with
7 | NO WARRANTY. See the file LICENSE for details.
8 |
9 | Homepage: https://github.com/nest/nest-gpu
10 |
11 | read_td [[80.0, 40.0], [70.0, 30.0], [80.0, 40.0], [70.0, 30.0], [80.0, 40.0], [70.0, 30.0]]
12 | read_tr [[60.0, 20.0], [50.0, 10.0], [60.0, 20.0], [50.0, 10.0], [60.0, 20.0], [50.0, 10.0]]
13 | read_Vm [-80.0, -90.0, -80.0, -90.0, -80.0, -90.0]
14 | read_Vth [-40.0, -30.0, -40.0, -30.0, -40.0, -30.0]
15 | read_g1 [[0.4000000059604645, 0.20000000298023224], [0.30000001192092896, 0.10000000149011612], [0.4000000059604645, 0.20000000298023224], [0.30000001192092896, 0.10000000149011612], [0.4000000059604645, 0.20000000298023224], [0.30000001192092896, 0.10000000149011612]]
16 | read1_td [[80.0, 40.0], [80.0, 40.0], [80.0, 40.0], [70.0, 30.0], [70.0, 30.0], [70.0, 30.0]]
17 | read1_tr [[60.0, 20.0], [60.0, 20.0], [60.0, 20.0], [50.0, 10.0], [50.0, 10.0], [50.0, 10.0]]
18 | read1_Vm [-80.0, -80.0, -80.0, -90.0, -90.0, -90.0]
19 | read1_Vth [-40.0, -40.0, -40.0, -30.0, -30.0, -30.0]
20 | read1_g1 [[0.4000000059604645, 0.20000000298023224], [0.4000000059604645, 0.20000000298023224], [0.4000000059604645, 0.20000000298023224], [0.30000001192092896, 0.10000000149011612], [0.30000001192092896, 0.10000000149011612], [0.30000001192092896, 0.10000000149011612]]
21 |
--------------------------------------------------------------------------------
/python/test/logp3_syn_group.txt:
--------------------------------------------------------------------------------
1 |
2 | -- NEST GPU --
3 |
4 | Copyright (C) 2021 The NEST Initiative
5 |
6 | This program is provided AS IS and comes with
7 | NO WARRANTY. See the file LICENSE for details.
8 |
9 | Homepage: https://github.com/nest/nest-gpu
10 |
11 | {'fact': 1.0, 'offset': 2.0}
12 | {'fact': 3.0, 'offset': 4.0}
13 | {'fact': 5.0, 'offset': 6.0}
14 | fact: 5.0
15 | offset: 6.0
16 | 5.0
17 | 6.0
18 | [5.0, 6.0]
19 | [6.0, 5.0]
20 |
--------------------------------------------------------------------------------
/python/test/nest_iaf_psc_alpha.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nest
3 | import numpy as np
4 |
5 | tolerance = 0.00005
6 | neuron = nest.Create('iaf_psc_alpha')
7 | spike = nest.Create("spike_generator")
8 | spike_times = [10.0, 400.0]
9 | n_spikes = 2
10 |
11 | print(nest.GetStatus(neuron))
12 | nest.SetStatus(neuron, {"tau_syn_ex": 10.0, "tau_syn_in": 5.0})
13 |
14 | # set spike times and height
15 | nest.SetStatus(spike, {"spike_times": spike_times})
16 | delay = [1.0, 100.0]
17 | weight = [1.0, -2.0]
18 |
19 | conn_spec={"rule": "all_to_all"}
20 |
21 | syn_spec_ex={'weight': weight[0], 'delay': delay[0]}
22 | syn_spec_in={'weight': weight[1], 'delay': delay[1]}
23 | nest.Connect(spike, neuron, conn_spec, syn_spec_ex)
24 | nest.Connect(spike, neuron, conn_spec, syn_spec_in)
25 |
26 | #record = nest.CreateRecord("", ["V_m_rel"], [neuron[0]], [0])
27 | voltmeter = nest.Create('voltmeter')
28 | nest.Connect(voltmeter, neuron)
29 |
30 | nest.Simulate(800.0)
31 |
32 | #data_list = nest.GetRecordData(record)
33 | #t=[row[0] for row in data_list]
34 | #V_m=[-70.0+row[1] for row in data_list]
35 |
36 | #import matplotlib.pyplot as plt
37 | #plt.figure()
38 | #plt.plot(t, V_m, "r-")
39 | #plt.show()
40 |
41 | #sys.exit()
42 | dmm = nest.GetStatus(voltmeter)[0]
43 | V_m = dmm["events"]["V_m"]
44 | t = dmm["events"]["times"]
45 | with open('test_iaf_psc_alpha_nest.txt', 'w') as f:
46 | for i in range(len(t)):
47 | f.write("%s\t%s\n" % (t[i], V_m[i]))
48 |
49 | import matplotlib.pyplot as plt
50 | plt.figure()
51 | plt.plot(t, V_m, "r-")
52 | plt.show()
53 |
54 | sys.exit()
55 | data = np.loadtxt('test_iaf_psc_alpha_nest.txt', delimiter="\t")
56 | t1=[x[0] for x in data ]
57 | V_m1=[x[1] for x in data ]
58 | print (len(t))
59 | print (len(t1))
60 |
61 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
62 | rmse =np.std(dV)/abs(np.mean(V_m))
63 | print("rmse : ", rmse, " tolerance: ", tolerance)
64 | if rmse>tolerance:
65 | sys.exit(1)
66 |
67 | sys.exit(0)
68 |
--------------------------------------------------------------------------------
/python/test/plot_aeif_psc_delta_multisynapse.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 |
4 | neuron = ngpu.Create('aeif_psc_delta_multisynapse')
5 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, \
6 | "g_L":300.0, "C_m":20000.0})
7 | spike = ngpu.Create("spike_generator")
8 | spike_times = [10.0, 400.0]
9 | n_spikes = 2
10 |
11 | # set spike times and height
12 | ngpu.SetStatus(spike, {"spike_times": spike_times})
13 | delay = [1.0, 100.0]
14 | weight = [1.0, -2.0]
15 |
16 | conn_spec={"rule": "all_to_all"}
17 |
18 |
19 | syn_spec_ex={'weight': weight[0], 'delay': delay[0]}
20 | syn_spec_in={'weight': weight[1], 'delay': delay[1]}
21 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
22 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
23 |
24 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
25 | #voltmeter = nest.Create('voltmeter')
26 | #nest.Connect(voltmeter, neuron)
27 |
28 | ngpu.Simulate(800.0)
29 |
30 | data_list = ngpu.GetRecordData(record)
31 | t=[row[0] for row in data_list]
32 | V_m=[row[1] for row in data_list]
33 | #dmm = nest.GetStatus(voltmeter)[0]
34 | #V_m = dmm["events"]["V_m"]
35 | #t = dmm["events"]["times"]
36 |
37 | import matplotlib.pyplot as plt
38 |
39 | plt.figure(1)
40 | plt.plot(t, V_m)
41 |
42 | plt.draw()
43 | plt.pause(1)
44 | raw_input("")
45 | plt.close()
46 |
--------------------------------------------------------------------------------
/python/test/test_aeif_cond_alpha.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.00005
5 | neuron = ngpu.Create('aeif_cond_alpha', 1)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6,
7 | "g_L":300.0, 'E_rev_ex':20.0, 'E_rev_in': -85.0,
8 | 'tau_syn_ex':40.0, 'tau_syn_in': 20.0})
9 |
10 | spike = ngpu.Create("spike_generator")
11 | spike_times = [10.0, 400.0]
12 | n_spikes = 2
13 |
14 | # set spike times and heights
15 | ngpu.SetStatus(spike, {"spike_times": spike_times})
16 | delay = [1.0, 100.0]
17 | weight = [0.1, 0.2]
18 |
19 | conn_spec={"rule": "all_to_all"}
20 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
21 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
22 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
23 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
24 |
25 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
26 |
27 | ngpu.Simulate(800.0)
28 |
29 | data_list = ngpu.GetRecordData(record)
30 | t=[row[0] for row in data_list]
31 | V_m=[row[1] for row in data_list]
32 |
33 | data = np.loadtxt('test_aeif_cond_alpha_nest.txt', delimiter="\t")
34 | t1=[x[0] for x in data ]
35 | V_m1=[x[1] for x in data ]
36 | print (len(t))
37 | print (len(t1))
38 |
39 | """
40 | import matplotlib.pyplot as plt
41 | plt.figure()
42 | plt.plot(t, V_m, "r--")
43 | plt.plot(t1, V_m1, "b--")
44 | plt.show()
45 | """
46 |
47 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
48 | #print(dV)
49 | rmse =np.std(dV)/abs(np.mean(V_m))
50 | print("rmse : ", rmse, " tolerance: ", tolerance)
51 | if rmse>tolerance:
52 | sys.exit(1)
53 |
54 | sys.exit(0)
55 |
--------------------------------------------------------------------------------
/python/test/test_aeif_cond_alpha_multisynapse.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('aeif_cond_alpha_multisynapse', 1, 3)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6,
7 | "g_L":300.0, 'E_rev':[20.0, 0.0, -85.0], \
8 | 'tau_syn':[40.0, 20.0, 30.0]})
9 | spike = ngpu.Create("spike_generator")
10 | spike_times = [10.0, 400.0]
11 | n_spikes = 2
12 |
13 | # set spike times and heights
14 | ngpu.SetStatus(spike, {"spike_times": spike_times})
15 | delay = [1.0, 100.0, 130.0]
16 | weight = [0.1, 0.2, 0.5]
17 |
18 | conn_spec={"rule": "all_to_all"}
19 | for syn in range(3):
20 | syn_spec={'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]}
21 | ngpu.Connect(spike, neuron, conn_spec, syn_spec)
22 |
23 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
24 | #voltmeter = nest.Create('voltmeter')
25 | #nest.Connect(voltmeter, neuron)
26 |
27 | ngpu.Simulate(800.0)
28 |
29 | data_list = ngpu.GetRecordData(record)
30 | t=[row[0] for row in data_list]
31 | V_m=[row[1] for row in data_list]
32 | #dmm = nest.GetStatus(voltmeter)[0]
33 | #V_m = dmm["events"]["V_m"]
34 | #t = dmm["events"]["times"]
35 | #with open('test_aeif_cond_alpha_nest.txt', 'w') as f:
36 | # for i in range(len(t)):
37 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
38 |
39 | data = np.loadtxt('test_aeif_cond_alpha_multisynapse_nest.txt', delimiter="\t")
40 | t1=[x[0] for x in data ]
41 | V_m1=[x[1] for x in data ]
42 | print (len(t))
43 | print (len(t1))
44 |
45 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
46 | rmse =np.std(dV)/abs(np.mean(V_m))
47 | print("rmse : ", rmse, " tolerance: ", tolerance)
48 | if rmse>tolerance:
49 | sys.exit(1)
50 |
51 | sys.exit(0)
52 |
--------------------------------------------------------------------------------
/python/test/test_aeif_cond_beta.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.00005
5 | neuron = ngpu.Create('aeif_cond_beta', 1)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, "g_L":300.0,
7 | 'E_rev_ex': 20.0, 'E_rev_in': -85.0,
8 | 'tau_decay_ex': 40.0,
9 | 'tau_decay_in': 20.0,
10 | 'tau_rise_ex': 20.0,
11 | 'tau_rise_in': 5.0})
12 | spike = ngpu.Create("spike_generator")
13 | spike_times = [10.0, 400.0]
14 | n_spikes = 2
15 |
16 | # set spike times and heights
17 | ngpu.SetStatus(spike, {"spike_times": spike_times})
18 | delay = [1.0, 100.0]
19 | weight = [0.1, 0.2]
20 |
21 | conn_spec={"rule": "all_to_all"}
22 | for syn in range(2):
23 | syn_spec={'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]}
24 | ngpu.Connect(spike, neuron, conn_spec, syn_spec)
25 |
26 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
27 |
28 | ngpu.Simulate(800.0)
29 |
30 | data_list = ngpu.GetRecordData(record)
31 | t=[row[0] for row in data_list]
32 | V_m=[row[1] for row in data_list]
33 |
34 | data = np.loadtxt('test_aeif_cond_beta_nest.txt', delimiter="\t")
35 | t1=[x[0] for x in data ]
36 | V_m1=[x[1] for x in data ]
37 | print (len(t))
38 | print (len(t1))
39 |
40 | """
41 | import matplotlib.pyplot as plt
42 | plt.figure()
43 | plt.plot(t,V_m, "r--")
44 | plt.plot(t1,V_m1, "b--")
45 | plt.show()
46 | """
47 |
48 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
49 | rmse =np.std(dV)/abs(np.mean(V_m))
50 | print("rmse : ", rmse, " tolerance: ", tolerance)
51 | if rmse>tolerance:
52 | sys.exit(1)
53 |
54 | sys.exit(0)
55 |
--------------------------------------------------------------------------------
/python/test/test_aeif_cond_beta_multisynapse.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('aeif_cond_beta_multisynapse', 1, 3)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6,
7 | "g_L":300.0, 'E_rev':[20.0, 0.0, -85.0], \
8 | 'tau_decay':[40.0, 20.0, 30.0], \
9 | 'tau_rise':[20.0, 10.0, 5.0]})
10 | spike = ngpu.Create("spike_generator")
11 | spike_times = [10.0, 400.0]
12 | n_spikes = 2
13 |
14 | # set spike times and heights
15 | ngpu.SetStatus(spike, {"spike_times": spike_times})
16 | delay = [1.0, 100.0, 130.0]
17 | weight = [0.1, 0.2, 0.5]
18 |
19 | conn_spec={"rule": "all_to_all"}
20 | for syn in range(3):
21 | syn_spec={'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]}
22 | ngpu.Connect(spike, neuron, conn_spec, syn_spec)
23 |
24 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
25 | #voltmeter = nest.Create('voltmeter')
26 | #nest.Connect(voltmeter, neuron)
27 |
28 | ngpu.Simulate(800.0)
29 |
30 | data_list = ngpu.GetRecordData(record)
31 | t=[row[0] for row in data_list]
32 | V_m=[row[1] for row in data_list]
33 | #dmm = nest.GetStatus(voltmeter)[0]
34 | #V_m = dmm["events"]["V_m"]
35 | #t = dmm["events"]["times"]
36 | #with open('test_aeif_cond_beta_nest.txt', 'w') as f:
37 | # for i in range(len(t)):
38 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
39 |
40 | data = np.loadtxt('test_aeif_cond_beta_multisynapse_nest.txt', delimiter="\t")
41 | t1=[x[0] for x in data ]
42 | V_m1=[x[1] for x in data ]
43 | print (len(t))
44 | print (len(t1))
45 |
46 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
47 | rmse =np.std(dV)/abs(np.mean(V_m))
48 | print("rmse : ", rmse, " tolerance: ", tolerance)
49 | if rmse>tolerance:
50 | sys.exit(1)
51 |
52 | sys.exit(0)
53 |
--------------------------------------------------------------------------------
/python/test/test_aeif_psc_alpha.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 3e-6
5 | neuron = ngpu.Create('aeif_psc_alpha', 1)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6,
7 | "g_L":300.0,
8 | "tau_syn_ex": 40.0,
9 | "tau_syn_in": 20.0})
10 | spike = ngpu.Create("spike_generator")
11 | spike_times = [10.0, 400.0]
12 | n_spikes = 2
13 |
14 | # set spike times and height
15 | ngpu.SetStatus(spike, {"spike_times": spike_times})
16 | delay = [1.0, 100.0]
17 | weight = [1.0, 2.0]
18 |
19 | conn_spec={"rule": "all_to_all"}
20 |
21 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
22 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
23 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
24 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
25 |
26 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
27 | #voltmeter = nest.Create('voltmeter')
28 | #nest.Connect(voltmeter, neuron)
29 |
30 | ngpu.Simulate(800.0)
31 |
32 | data_list = ngpu.GetRecordData(record)
33 | t=[row[0] for row in data_list]
34 | V_m=[row[1] for row in data_list]
35 | #dmm = nest.GetStatus(voltmeter)[0]
36 | #V_m = dmm["events"]["V_m"]
37 | #t = dmm["events"]["times"]
38 | #with open('test_aeif_psc_alpha_nest.txt', 'w') as f:
39 | # for i in range(len(t)):
40 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
41 |
42 | data = np.loadtxt('test_aeif_psc_alpha_nest.txt', delimiter="\t")
43 | t1=[x[0] for x in data ]
44 | V_m1=[x[1] for x in data ]
45 | print (len(t))
46 | print (len(t1))
47 |
48 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
49 | rmse =np.std(dV)/abs(np.mean(V_m))
50 | print("rmse : ", rmse, " tolerance: ", tolerance)
51 | if rmse>tolerance:
52 | sys.exit(1)
53 |
54 | sys.exit(0)
55 |
--------------------------------------------------------------------------------
/python/test/test_aeif_psc_alpha_multisynapse.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('aeif_psc_alpha_multisynapse', 1, 2)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, \
7 | "g_L":300.0, "tau_syn":[40.0, 20.0]})
8 | spike = ngpu.Create("spike_generator")
9 | spike_times = [10.0, 400.0]
10 | n_spikes = 2
11 |
12 | # set spike times and height
13 | ngpu.SetStatus(spike, {"spike_times": spike_times})
14 | delay = [1.0, 100.0]
15 | weight = [1.0, -2.0]
16 |
17 | conn_spec={"rule": "all_to_all"}
18 |
19 |
20 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
21 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
22 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
23 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
24 |
25 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
26 | #voltmeter = nest.Create('voltmeter')
27 | #nest.Connect(voltmeter, neuron)
28 |
29 | ngpu.Simulate(800.0)
30 |
31 | data_list = ngpu.GetRecordData(record)
32 | t=[row[0] for row in data_list]
33 | V_m=[row[1] for row in data_list]
34 | #dmm = nest.GetStatus(voltmeter)[0]
35 | #V_m = dmm["events"]["V_m"]
36 | #t = dmm["events"]["times"]
37 | #with open('test_aeif_psc_alpha_nest.txt', 'w') as f:
38 | # for i in range(len(t)):
39 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
40 |
41 | data = np.loadtxt('test_aeif_psc_alpha_multisynapse_nest.txt', delimiter="\t")
42 | t1=[x[0] for x in data ]
43 | V_m1=[x[1] for x in data ]
44 | print (len(t))
45 | print (len(t1))
46 |
47 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
48 | rmse =np.std(dV)/abs(np.mean(V_m))
49 | print("rmse : ", rmse, " tolerance: ", tolerance)
50 | if rmse>tolerance:
51 | sys.exit(1)
52 |
53 | sys.exit(0)
54 |
--------------------------------------------------------------------------------
/python/test/test_aeif_psc_delta.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('aeif_psc_delta')
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, \
7 | "g_L":300.0, "C_m":20000.0})
8 | spike = ngpu.Create("spike_generator")
9 | spike_times = [10.0, 400.0]
10 | n_spikes = 2
11 |
12 | # set spike times and height
13 | ngpu.SetStatus(spike, {"spike_times": spike_times})
14 | delay = [1.0, 100.0]
15 | # the aeif_psc_delta model has one port, negative inputs require negative weights
16 | weight = [1.0, -2.0]
17 |
18 | conn_spec={"rule": "all_to_all"}
19 |
20 |
21 | syn_spec_ex={'weight': weight[0], 'delay': delay[0]}
22 | syn_spec_in={'weight': weight[1], 'delay': delay[1]}
23 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
24 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
25 |
26 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
27 | #voltmeter = nest.Create('voltmeter')
28 | #nest.Connect(voltmeter, neuron)
29 |
30 | ngpu.Simulate(800.0)
31 |
32 | data_list = ngpu.GetRecordData(record)
33 | t=[row[0] for row in data_list]
34 | V_m=[row[1] for row in data_list]
35 | #dmm = nest.GetStatus(voltmeter)[0]
36 | #V_m = dmm["events"]["V_m"]
37 | #t = dmm["events"]["times"]
38 | #with open('test_aeif_psc_delta_nest.txt', 'w') as f:
39 | # for i in range(len(t)):
40 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
41 |
42 | data = np.loadtxt('test_aeif_psc_delta_nest.txt', delimiter="\t")
43 | t1=[x[0] for x in data ]
44 | V_m1=[x[1] for x in data ]
45 | print (len(t))
46 | print (len(t1))
47 |
48 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
49 | rmse =np.std(dV)/abs(np.mean(V_m))
50 | print("rmse : ", rmse, " tolerance: ", tolerance)
51 | if rmse>tolerance:
52 | sys.exit(1)
53 |
54 | sys.exit(0)
55 |
--------------------------------------------------------------------------------
/python/test/test_aeif_psc_exp.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 5e-6
5 | neuron = ngpu.Create('aeif_psc_exp', 1)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5,
7 | "E_L":-70.6,
8 | "g_L":300.0,
9 | "tau_syn_ex": 40.0,
10 | "tau_syn_in": 20.0})
11 | spike = ngpu.Create("spike_generator")
12 | spike_times = [10.0, 400.0]
13 | n_spikes = 2
14 |
15 | # set spike times and height
16 | ngpu.SetStatus(spike, {"spike_times": spike_times})
17 | delay = [1.0, 100.0]
18 | weight = [1.0, 2.0]
19 |
20 | conn_spec={"rule": "all_to_all"}
21 |
22 |
23 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
24 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
25 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
26 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
27 |
28 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
29 | #voltmeter = nest.Create('voltmeter')
30 | #nest.Connect(voltmeter, neuron)
31 |
32 | ngpu.Simulate(800.0)
33 |
34 | data_list = ngpu.GetRecordData(record)
35 | t=[row[0] for row in data_list]
36 | V_m=[row[1] for row in data_list]
37 | #dmm = nest.GetStatus(voltmeter)[0]
38 | #V_m = dmm["events"]["V_m"]
39 | #t = dmm["events"]["times"]
40 | #with open('test_aeif_psc_exp_nest.txt', 'w') as f:
41 | # for i in range(len(t)):
42 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
43 |
44 | data = np.loadtxt('test_aeif_psc_exp_nest.txt', delimiter="\t")
45 | t1=[x[0] for x in data ]
46 | V_m1=[x[1] for x in data ]
47 | print (len(t))
48 | print (len(t1))
49 |
50 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
51 | rmse =np.std(dV)/abs(np.mean(V_m))
52 | print("rmse : ", rmse, " tolerance: ", tolerance)
53 | if rmse>tolerance:
54 | sys.exit(1)
55 |
56 | sys.exit(0)
57 |
--------------------------------------------------------------------------------
/python/test/test_aeif_psc_exp_multisynapse.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('aeif_psc_exp_multisynapse', 1, 2)
6 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, \
7 | "g_L":300.0, "tau_syn":[40.0, 20.0]})
8 | spike = ngpu.Create("spike_generator")
9 | spike_times = [10.0, 400.0]
10 | n_spikes = 2
11 |
12 | # set spike times and height
13 | ngpu.SetStatus(spike, {"spike_times": spike_times})
14 | delay = [1.0, 100.0]
15 | weight = [1.0, -2.0]
16 |
17 | conn_spec={"rule": "all_to_all"}
18 |
19 |
20 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
21 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
22 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
23 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
24 |
25 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
26 | #voltmeter = nest.Create('voltmeter')
27 | #nest.Connect(voltmeter, neuron)
28 |
29 | ngpu.Simulate(800.0)
30 |
31 | data_list = ngpu.GetRecordData(record)
32 | t=[row[0] for row in data_list]
33 | V_m=[row[1] for row in data_list]
34 | #dmm = nest.GetStatus(voltmeter)[0]
35 | #V_m = dmm["events"]["V_m"]
36 | #t = dmm["events"]["times"]
37 | #with open('test_aeif_psc_exp_nest.txt', 'w') as f:
38 | # for i in range(len(t)):
39 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
40 |
41 | data = np.loadtxt('test_aeif_psc_exp_multisynapse_nest.txt', delimiter="\t")
42 | t1=[x[0] for x in data ]
43 | V_m1=[x[1] for x in data ]
44 | print (len(t))
45 | print (len(t1))
46 |
47 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
48 | rmse =np.std(dV)/abs(np.mean(V_m))
49 | print("rmse : ", rmse, " tolerance: ", tolerance)
50 | if rmse>tolerance:
51 | sys.exit(1)
52 |
53 | sys.exit(0)
54 |
--------------------------------------------------------------------------------
/python/test/test_all.sh:
--------------------------------------------------------------------------------
1 | pass_str[0]="TEST PASSED"
2 | pass_str[1]="TEST NOT PASSED"
3 | :>log.txt
4 | for fn in test_iaf_psc_exp_g.py test_fixed_total_number.py test_iaf_psc_exp.py test_spike_times.py test_aeif_cond_alpha.py test_aeif_cond_beta.py test_aeif_psc_alpha.py test_aeif_psc_delta.py test_aeif_psc_exp.py test_aeif_cond_alpha_multisynapse.py test_aeif_cond_beta_multisynapse.py test_aeif_psc_alpha_multisynapse.py test_aeif_psc_exp_multisynapse.py test_stdp_list.py test_stdp.py test_syn_model.py test_brunel_list.py test_brunel_outdegree.py test_brunel_user_m1.py test_spike_detector.py; do
5 | python3 $fn >> log.txt 2>err.txt
6 | res=$?
7 | cat err.txt >> log.txt
8 | rm -f err.txt
9 | if [ "$res" -ne "0" ]; then
10 | res=1
11 | fi
12 | echo $fn : ${pass_str[$res]}
13 | done
14 | for fn in syn_group connect getarr setvar2 group_param; do
15 | python3 test_$fn.py 2>&1 | grep -v dyl > tmp
16 | diff -qs tmp logp3_$fn.txt 2>&1 >> log.txt
17 | res=$?
18 | echo $fn : ${pass_str[$res]}
19 | done
20 | rm -f tmp
21 |
--------------------------------------------------------------------------------
/python/test/test_distribution.py:
--------------------------------------------------------------------------------
1 | import nestgpu as ngpu
2 | import numpy as np
3 |
4 | neuron = ngpu.Create("aeif_cond_beta_multisynapse",100000)
5 |
6 | ngpu.SetStatus(neuron, {"V_m": {"distribution":"normal_clipped",
7 | "mu":-70.0, "low":-90.0,
8 | "high":-50.0,
9 | "sigma":5.0}})
10 | l = ngpu.GetStatus(neuron, "V_m")
11 | d=[]
12 | for elem in l:
13 | d.append(elem[0])
14 |
15 | print (len(d))
16 | import matplotlib.pyplot as plt
17 |
18 | # An "interface" to matplotlib.axes.Axes.hist() method
19 | n, bins, patches = plt.hist(d, bins='auto', color='#0504aa', alpha=0.7, rwidth=0.85)
20 | plt.grid(axis='y', alpha=0.75)
21 | plt.xlabel('Value')
22 | plt.ylabel('Frequency')
23 | plt.title('V_m Histogram')
24 | plt.text(23, 45, r'$\mu=15, b=3$')
25 | maxfreq = n.max()
26 | # Set a clean upper y-axis limit.
27 | plt.ylim(ymax=np.ceil(maxfreq / 10) * 10 if maxfreq % 10 else maxfreq + 10)
28 | plt.show()
29 |
--------------------------------------------------------------------------------
/python/test/test_ext_neuron.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 | neuron = ngpu.Create('ext_neuron', 1, 3)
6 | spike = ngpu.Create("spike_generator")
7 | spike_times = [50.0, 100.0, 400.0, 600.0]
8 | n_spikes = 4
9 |
10 | # set spike times and heights
11 | ngpu.SetStatus(spike, {"spike_times": spike_times})
12 | delay = [1.0, 50.0, 100.0]
13 | weight = [0.1, 0.2, 0.5]
14 |
15 | conn_spec={"rule": "all_to_all"}
16 | for syn in range(3):
17 | syn_spec={'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]}
18 | ngpu.Connect(spike, neuron, conn_spec, syn_spec)
19 |
20 | i_neuron_arr = [neuron[0], neuron[0], neuron[0]]
21 | i_receptor_arr = [0, 1, 2]
22 | var_name_arr = ["port_value", "port_value", "port_value"]
23 | record = ngpu.CreateRecord("", var_name_arr, i_neuron_arr,
24 | i_receptor_arr)
25 |
26 | ngpu.Simulate(800.0)
27 |
28 | data_list = ngpu.GetRecordData(record)
29 | t=[row[0] for row in data_list]
30 | val1=[row[1] for row in data_list]
31 | val2=[row[2] for row in data_list]
32 | val3=[row[3] for row in data_list]
33 |
34 | import matplotlib.pyplot as plt
35 |
36 | fig1 = plt.figure(1)
37 | plt.plot(t, val1)
38 | fig2 = plt.figure(2)
39 | plt.plot(t, val2)
40 | fig3 = plt.figure(3)
41 | plt.plot(t, val3)
42 |
43 | plt.draw()
44 | plt.pause(1)
45 | ngpu.waitenter("")
46 | plt.close()
47 |
--------------------------------------------------------------------------------
/python/test/test_getarr.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 |
4 | spike = ngpu.Create("spike_generator", 4)
5 | spike0 = spike[0:2]
6 | spike1 = spike[2:3]
7 | spike2 = spike[3:4]
8 |
9 | spike_time0 = [10.0, 400.0]
10 | spike_height0 = [1.0, 0.5]
11 | spike_time1 = [4.0]
12 | spike_height1 = [2.0]
13 | spike_time2 = [50.0, 20.0, 80.0]
14 | spike_height2 = [0.1, 0.3, 0.2]
15 |
16 |
17 | # set spike times and heights
18 | ngpu.SetStatus(spike0, {"spike_times": spike_time0,
19 | "spike_heights":spike_height0})
20 |
21 | ngpu.SetStatus(spike1, {"spike_times": spike_time1,
22 | "spike_heights":spike_height1})
23 |
24 | ngpu.SetStatus(spike2, {"spike_times": spike_time2,
25 | "spike_heights":spike_height2})
26 |
27 | print(ngpu.GetStatus(spike0, "spike_times"))
28 | print(ngpu.GetStatus(spike0, "spike_heights"))
29 | print()
30 | print(ngpu.GetStatus(spike1, "spike_times"))
31 | print(ngpu.GetStatus(spike1, "spike_heights"))
32 | print()
33 | print(ngpu.GetStatus(spike2, "spike_times"))
34 | print(ngpu.GetStatus(spike2, "spike_heights"))
35 |
36 | print()
37 | print()
38 | neuron_list = [spike[2], spike[3], spike[0], spike[1]]
39 | print(ngpu.GetStatus(neuron_list, "spike_times"))
40 | print(ngpu.GetStatus(neuron_list, "spike_heights"))
41 | print()
42 | print()
43 | print(ngpu.GetStatus(spike1))
44 | print()
45 | print()
46 | print(ngpu.GetStatus(neuron_list))
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/python/test/test_group_param.py:
--------------------------------------------------------------------------------
1 | import nestgpu as ngpu
2 | n=ngpu.Create('iaf_psc_exp_g',3)
3 | print(ngpu.GetStatus(n))
4 | print(ngpu.GetStatus(n, "V_m_rel"))
5 | print(ngpu.GetStatus(n, "C_m"))
6 | print(ngpu.GetStatus(n, "tau_m"))
7 | print(ngpu.GetStatus(n, "I_syn"))
8 | ngpu.SetStatus(n, {"C_m":120.0, "V_m_rel":17.0, "tau_m":7.0, "I_syn":600.0})
9 | print(ngpu.GetStatus(n))
10 | print(ngpu.GetStatus(n, "V_m_rel"))
11 | print(ngpu.GetStatus(n, "C_m"))
12 | print(ngpu.GetStatus(n, "tau_m"))
13 | print(ngpu.GetStatus(n, "I_syn"))
14 | ngpu.SetStatus(n[0:2], "V_m_rel", 10.0)
15 | ngpu.SetStatus(n, "C_m", 80.0)
16 | ngpu.SetStatus(n, "tau_m", 0.9)
17 | ngpu.SetStatus(n[2:3], "I_syn", 200.0)
18 | print(ngpu.GetStatus(n))
19 | print(ngpu.GetStatus(n, "V_m_rel"))
20 | print(ngpu.GetStatus(n, "C_m"))
21 | print(ngpu.GetStatus(n, "tau_m"))
22 | print(ngpu.GetStatus(n, "I_syn"))
23 | print(ngpu.GetStatus(n[1:3], "V_m_rel"))
24 | print(ngpu.GetStatus(n[0:2], "C_m"))
25 | print(ngpu.GetStatus(n[1:3], "C_m"))
26 | print(ngpu.GetStatus(n[1:3], "I_syn"))
27 | print(ngpu.GetStatus(n[1:3], ["V_m_rel", "C_m"]))
28 |
--------------------------------------------------------------------------------
/python/test/test_iaf_psc_alpha.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.00005
5 |
6 | neuron = ngpu.Create('iaf_psc_alpha')
7 | spike = ngpu.Create("spike_generator")
8 | spike_times = [10.0, 400.0]
9 | n_spikes = 2
10 |
11 | print(ngpu.GetStatus(neuron))
12 | ngpu.SetStatus(neuron, {"tau_syn_ex": 10.0, "tau_syn_in": 5.0})
13 |
14 | # set spike times and height
15 | ngpu.SetStatus(spike, {"spike_times": spike_times})
16 | delay = [1.0, 100.0]
17 | weight = [1.0, -2.0]
18 |
19 | conn_spec={"rule": "all_to_all"}
20 |
21 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
22 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
23 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
24 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
25 |
26 | record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0])
27 | #voltmeter = nest.Create('voltmeter')
28 | #nest.Connect(voltmeter, neuron)
29 |
30 | ngpu.Simulate(800.0)
31 |
32 | data_list = ngpu.GetRecordData(record)
33 | t=[row[0] for row in data_list]
34 | V_m=[-70.0+row[1] for row in data_list]
35 |
36 |
37 |
38 | #dmm = nest.GetStatus(voltmeter)[0]
39 | #V_m = dmm["events"]["V_m"]
40 | #t = dmm["events"]["times"]
41 | #with open('test_iaf_psc_alpha_nest.txt', 'w') as f:
42 | # for i in range(len(t)):
43 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
44 |
45 | data = np.loadtxt('test_iaf_psc_alpha_nest.txt', delimiter="\t")
46 | t1=[x[0] for x in data ]
47 | V_m1=[x[1] for x in data ]
48 | print (len(t))
49 | print (len(t1))
50 |
51 | dV=[V_m[i*10+10]-V_m1[i] for i in range(len(t1))]
52 | rmse =np.std(dV)/abs(np.mean(V_m))
53 | print("rmse : ", rmse, " tolerance: ", tolerance)
54 |
55 | if rmse>tolerance:
56 | sys.exit(1)
57 |
58 | sys.exit(0)
59 |
--------------------------------------------------------------------------------
/python/test/test_iaf_psc_exp.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.00005
5 | neuron = ngpu.Create('iaf_psc_exp')
6 | spike = ngpu.Create("spike_generator")
7 | spike_times = [10.0, 400.0]
8 | n_spikes = 2
9 |
10 | # set spike times and height
11 | ngpu.SetStatus(spike, {"spike_times": spike_times})
12 | delay = [1.0, 100.0]
13 | weight = [1.0, -2.0]
14 |
15 | conn_spec={"rule": "all_to_all"}
16 |
17 | syn_spec_ex={'receptor':0, 'weight': weight[0], 'delay': delay[0]}
18 | syn_spec_in={'receptor':1, 'weight': weight[1], 'delay': delay[1]}
19 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
20 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
21 |
22 | record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0])
23 | #voltmeter = nest.Create('voltmeter')
24 | #nest.Connect(voltmeter, neuron)
25 |
26 | ngpu.Simulate(800.0)
27 |
28 | data_list = ngpu.GetRecordData(record)
29 | t=[row[0] for row in data_list]
30 | V_m=[-70.0+row[1] for row in data_list]
31 | #dmm = nest.GetStatus(voltmeter)[0]
32 | #V_m = dmm["events"]["V_m"]
33 | #t = dmm["events"]["times"]
34 | #with open('test_iaf_psc_exp_nest.txt', 'w') as f:
35 | # for i in range(len(t)):
36 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
37 |
38 | data = np.loadtxt('test_iaf_psc_exp_nest.txt', delimiter="\t")
39 | t1=[x[0] for x in data ]
40 | V_m1=[x[1] for x in data ]
41 | print (len(t))
42 | print (len(t1))
43 |
44 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
45 | rmse =np.std(dV)/abs(np.mean(V_m))
46 | print("rmse : ", rmse, " tolerance: ", tolerance)
47 | if rmse>tolerance:
48 | sys.exit(1)
49 |
50 | sys.exit(0)
51 |
--------------------------------------------------------------------------------
/python/test/test_iaf_psc_exp_g.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 |
6 | E_L = -65.0
7 |
8 | ngpu.SetKernelStatus("verbosity_level", 0)
9 | neuron = ngpu.Create('iaf_psc_exp_g', 1)
10 |
11 | spike = ngpu.Create("spike_generator")
12 | spike_times = [10.0, 400.0]
13 | n_spikes = 2
14 |
15 | # set spike times and height
16 | ngpu.SetStatus(spike, {"spike_times": spike_times})
17 | delay = [1.0, 100.0]
18 | weight = [1.0, -2.0]
19 |
20 | conn_spec={"rule": "all_to_all"}
21 |
22 |
23 | syn_spec_ex={'weight': weight[0], 'delay': delay[0]}
24 | syn_spec_in={'weight': weight[1], 'delay': delay[1]}
25 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
26 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
27 |
28 | record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0])
29 | #voltmeter = nest.Create('voltmeter')
30 | #nest.Connect(voltmeter, neuron)
31 |
32 | ngpu.Simulate(800.0)
33 |
34 | data_list = ngpu.GetRecordData(record)
35 | t=[row[0] for row in data_list]
36 | V_m=[row[1]+E_L for row in data_list]
37 | #dmm = nest.GetStatus(voltmeter)[0]
38 | #V_m = dmm["events"]["V_m"]
39 | #t = dmm["events"]["times"]
40 | #with open('test_iaf_psc_exp_nest.txt', 'w') as f:
41 | # for i in range(len(t)):
42 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
43 |
44 | data = np.loadtxt('../test/test_fast_iaf_psc_exp_nest.txt', delimiter="\t")
45 | t1=[x[0] for x in data ]
46 | V_m1=[x[1] for x in data ]
47 | #print (len(t))
48 | #print (len(t1))
49 |
50 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
51 | rmse =np.std(dV)/abs(np.mean(V_m))
52 | print("rmse : ", rmse, " tolerance: ", tolerance)
53 | if rmse>tolerance:
54 | sys.exit(1)
55 |
56 | sys.exit(0)
57 |
--------------------------------------------------------------------------------
/python/test/test_iaf_psc_exp_hc.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.0005
5 |
6 | E_L = -65.0
7 |
8 | ngpu.SetKernelStatus("verbosity_level", 0)
9 | neuron = ngpu.Create('iaf_psc_exp_hc', 1)
10 |
11 | spike = ngpu.Create("spike_generator")
12 | spike_times = [10.0, 400.0]
13 | n_spikes = 2
14 |
15 | # set spike times and height
16 | ngpu.SetStatus(spike, {"spike_times": spike_times})
17 | delay = [1.0, 100.0]
18 | weight = [1.0, -2.0]
19 |
20 | conn_spec={"rule": "all_to_all"}
21 |
22 |
23 | syn_spec_ex={'weight': weight[0], 'delay': delay[0]}
24 | syn_spec_in={'weight': weight[1], 'delay': delay[1]}
25 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
26 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
27 |
28 | record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0])
29 | #voltmeter = nest.Create('voltmeter')
30 | #nest.Connect(voltmeter, neuron)
31 |
32 | ngpu.Simulate(800.0)
33 |
34 | data_list = ngpu.GetRecordData(record)
35 | t=[row[0] for row in data_list]
36 | V_m=[row[1]+E_L for row in data_list]
37 | #dmm = nest.GetStatus(voltmeter)[0]
38 | #V_m = dmm["events"]["V_m"]
39 | #t = dmm["events"]["times"]
40 | #with open('test_iaf_psc_exp_nest.txt', 'w') as f:
41 | # for i in range(len(t)):
42 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
43 |
44 | data = np.loadtxt('../test/test_fast_iaf_psc_exp_nest.txt', delimiter="\t")
45 | t1=[x[0] for x in data ]
46 | V_m1=[x[1] for x in data ]
47 | #print (len(t))
48 | #print (len(t1))
49 |
50 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
51 | rmse =np.std(dV)/abs(np.mean(V_m))
52 | print("rmse : ", rmse, " tolerance: ", tolerance)
53 | if rmse>tolerance:
54 | sys.exit(1)
55 |
56 | sys.exit(0)
57 |
--------------------------------------------------------------------------------
/python/test/test_izh.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 | import numpy as np
4 | tolerance = 0.005
5 | neuron = ngpu.Create('izhikevich', 1)
6 | #ngpu.SetStatus(neuron, {"tau_syn": 1.0e-6})
7 | spike = ngpu.Create("spike_generator")
8 | spike_times = [10.0, 40.0]
9 | n_spikes = 2
10 |
11 | # set spike times and height
12 | ngpu.SetStatus(spike, {"spike_times": spike_times})
13 | delay = [1.0, 10.0]
14 | weight = [1.0, -2.0]
15 |
16 | conn_spec={"rule": "all_to_all"}
17 |
18 |
19 | syn_spec_ex={'weight': weight[0], 'delay': delay[0]}
20 | syn_spec_in={'weight': weight[1], 'delay': delay[1]}
21 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex)
22 | ngpu.Connect(spike, neuron, conn_spec, syn_spec_in)
23 |
24 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
25 | #voltmeter = nest.Create('voltmeter')
26 | #nest.Connect(voltmeter, neuron)
27 |
28 | ngpu.Simulate(80.0)
29 |
30 | data_list = ngpu.GetRecordData(record)
31 | t=[row[0] for row in data_list]
32 | V_m=[row[1] for row in data_list]
33 | #dmm = nest.GetStatus(voltmeter)[0]
34 | #V_m = dmm["events"]["V_m"]
35 | #t = dmm["events"]["times"]
36 | #with open('test_iaf_psc_exp_nest.txt', 'w') as f:
37 | # for i in range(len(t)):
38 | # f.write("%s\t%s\n" % (t[i], V_m[i]))
39 |
40 | data = np.loadtxt('../test/test_izh_nest.txt', delimiter="\t")
41 | t1=[x[0] for x in data ]
42 | V_m1=[x[1] for x in data ]
43 | #print (len(t))
44 | #print (len(t1))
45 |
46 | dV=[V_m[i*10+20]-V_m1[i] for i in range(len(t1))]
47 | rmse =np.std(dV)/abs(np.mean(V_m))
48 | print("rmse : ", rmse, " tolerance: ", tolerance)
49 | if rmse>tolerance:
50 | sys.exit(1)
51 |
52 | sys.exit(0)
53 | #import matplotlib.pyplot as plt
54 |
55 | #fig1 = plt.figure(1)
56 | #plt.plot(t, V_m)
57 | #fig1.suptitle("NEST GPU")
58 | #fig2 = plt.figure(2)
59 | #plt.plot(t1, V_m1)
60 | #fig2.suptitle("NEST")
61 | #plt.draw()
62 | #plt.pause(1)
63 | #ngpu.waitenter("")
64 | #plt.close()
65 |
--------------------------------------------------------------------------------
/python/test/test_mpi.sh:
--------------------------------------------------------------------------------
1 | mpi_pass_str[0]="MPI TEST PASSED"
2 | mpi_pass_str[1]="MPI TEST NOT PASSED"
3 | :>log.txt
4 | for fn in test_brunel_mpi.py test_brunel_outdegree_mpi.py; do
5 | mpirun -np 2 python3 $fn >> log.txt 2>err.txt
6 | res=$?
7 | cat err.txt >> log.txt
8 | rm -f err.txt
9 | if [ "$res" -ne "0" ]; then
10 | res=1
11 | fi
12 | echo $fn : ${mpi_pass_str[$res]}
13 | done
14 |
--------------------------------------------------------------------------------
/python/test/test_setvar2.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 |
4 | n_neurons = 6
5 |
6 | # create n_neurons neurons with 2 receptor ports
7 | neuron = ngpu.Create('aeif_cond_beta_multisynapse', n_neurons, 2)
8 | neuron_even = [neuron[0], neuron[2], neuron[4]]
9 | neuron_odd = [neuron[3], neuron[5], neuron[1]]
10 | ngpu.SetStatus(neuron_even, {'tau_decay':[80.0, 40.0],
11 | 'tau_rise':[60.0, 20.0]})
12 | ngpu.SetStatus(neuron_odd, {'tau_decay':[70.0, 30.0],
13 | 'tau_rise':[50.0, 10.0]})
14 |
15 | ngpu.SetStatus(neuron_even, {'V_m':-80.0})
16 | ngpu.SetStatus(neuron_odd, {'V_m':-90.0})
17 |
18 | ngpu.SetStatus(neuron_even, {'g1':[0.4, 0.2]})
19 | ngpu.SetStatus(neuron_odd, {'g1':[0.3, 0.1]})
20 |
21 | ngpu.SetStatus(neuron_even, {'V_th':-40.0})
22 | ngpu.SetStatus(neuron_odd, {'V_th':-30.0})
23 |
24 | # reading parameters and variables test
25 | read_td = ngpu.GetNeuronStatus(neuron, "tau_decay")
26 | read_tr = ngpu.GetNeuronStatus(neuron, "tau_rise")
27 | read_Vm = ngpu.GetNeuronStatus(neuron, "V_m")
28 | read_Vth = ngpu.GetNeuronStatus(neuron, "V_th")
29 | read_g1 = ngpu.GetNeuronStatus(neuron, "g1")
30 |
31 | print("read_td", read_td)
32 | print("read_tr", read_tr)
33 | print("read_Vm", read_Vm)
34 | print("read_Vth", read_Vth)
35 | print("read_g1", read_g1)
36 |
37 | # reading parameters and variables from neuron list test
38 | neuron_list = [neuron[0], neuron[2], neuron[4], neuron[1], neuron[3],
39 | neuron[5]]
40 | read1_td = ngpu.GetNeuronStatus(neuron_list, "tau_decay")
41 | read1_tr = ngpu.GetNeuronStatus(neuron_list, "tau_rise")
42 | read1_Vm = ngpu.GetNeuronStatus(neuron_list, "V_m")
43 | read1_Vth = ngpu.GetNeuronStatus(neuron_list, "V_th")
44 | read1_g1 = ngpu.GetNeuronStatus(neuron_list, "g1")
45 |
46 | print("read1_td", read1_td)
47 | print("read1_tr", read1_tr)
48 | print("read1_Vm", read1_Vm)
49 | print("read1_Vth", read1_Vth)
50 | print("read1_g1", read1_g1)
51 |
52 |
--------------------------------------------------------------------------------
/python/test/test_spike_detector.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 |
4 | tolerance = 1.0e-6
5 |
6 | neuron = ngpu.Create("aeif_cond_beta_multisynapse", 3)
7 |
8 | ngpu.SetStatus(neuron, {"I_e":1000.0})
9 |
10 | spike_det = ngpu.Create("spike_detector")
11 |
12 |
13 | conn_dict={"rule": "one_to_one"}
14 | syn_dict1={"weight": 1.0, "delay": 10.0, "receptor":0}
15 | syn_dict2={"weight": 2.0, "delay": 20.0, "receptor":0}
16 | syn_dict3={"weight": 3.0, "delay": 30.0, "receptor":0}
17 |
18 | ngpu.Connect([neuron[0]], spike_det, conn_dict, syn_dict1)
19 |
20 | ngpu.Connect([neuron[1]], spike_det, conn_dict, syn_dict2)
21 |
22 | ngpu.Connect([neuron[2]], spike_det, conn_dict, syn_dict3)
23 |
24 | record_n = ngpu.CreateRecord("", ["spike"], [neuron[0]], [0])
25 |
26 | record_sd = ngpu.CreateRecord("", ["spike_height"], [spike_det[0]], [0])
27 |
28 | ngpu.Simulate()
29 |
30 | data_n = ngpu.GetRecordData(record_n)
31 | t_n=[row[0] for row in data_n]
32 | spike_n=[row[1] for row in data_n]
33 |
34 | data_sd = ngpu.GetRecordData(record_sd)
35 | t_sd=[row[0] for row in data_sd]
36 | spike_sd=[row[1] for row in data_sd]
37 |
38 | for i in range(len(t_n)-400):
39 | if spike_n[i]>0.5:
40 | j1 = i + 101
41 | j2 = i + 201
42 | j3 = i + 301
43 | if abs(spike_sd[j1] - 1.0)>tolerance:
44 | print("Expected spike height: 1.0, simulated: ", spike_sd[j1])
45 | sys.exit(1)
46 | if abs(spike_sd[j2] - 2.0)>tolerance:
47 | print("Expected spike height: 2.0, simulated: ", spike_sd[j2])
48 | sys.exit(1)
49 | if abs(spike_sd[j3] - 3.0)>tolerance:
50 | print("Expected spike height: 3.0, simulated: ", spike_sd[j3])
51 | sys.exit(1)
52 |
53 | #import matplotlib.pyplot as plt
54 |
55 | #plt.figure(1)
56 | #plt.plot(t_n, spike_n)
57 |
58 | #plt.figure(2)
59 | #plt.plot(t_sd, spike_sd)
60 |
61 | #plt.draw()
62 | #plt.pause(1)
63 | #raw_input("")
64 | #plt.close()
65 | sys.exit(0)
66 |
--------------------------------------------------------------------------------
/python/test/test_stdp/cases/swap.sh:
--------------------------------------------------------------------------------
1 | for i in $(seq 1 5); do
2 | fn=case${i}.py
3 | j=$(expr $i + 5)
4 | fn1=case${j}.py
5 | echo "$fn -> $fn1"
6 | cat $fn | sed 's/pre/POST/g;s/post/PRE/g' > tmp.py
7 | cat tmp.py | sed 's/POST/post/g;s/PRE/pre/g' > tmp1.py
8 | cat tmp1.py | sed 's/neuron_post, neuron_pre/neuron_pre, neuron_post/' > tmp2.py
9 | cat tmp2.py | sed 's/delay = 1.0/delay = 3.0/' > tmp3.py
10 | cat tmp3.py | sed 's/den_delay = 3.0/den_delay = 1.0/' > tmp4.py
11 | cat tmp4.py | sed 's/neuron_pre, {\"den_delay\"/neuron_post, {\"den_delay\"/' > $fn1
12 | done
13 | rm -f tmp.py
14 | rm -f tmp1.py
15 | rm -f tmp2.py
16 | rm -f tmp3.py
17 |
--------------------------------------------------------------------------------
/python/test/test_stdp/cases/test_all.sh:
--------------------------------------------------------------------------------
1 | for i in $(seq 1 10); do python3 case$i.py | tail -1; done
2 |
--------------------------------------------------------------------------------
/python/test/test_syn_group.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 |
4 | syn_group = ngpu.CreateSynGroup("test_syn_model", {"fact":1.0, "offset":2.0})
5 | print(ngpu.GetStatus(syn_group))
6 | ngpu.SetStatus(syn_group, "fact", 3.0)
7 | ngpu.SetStatus(syn_group, "offset", 4.0)
8 | print(ngpu.GetStatus(syn_group))
9 |
10 | ngpu.SetStatus(syn_group, {"fact":5.0, "offset":6.0})
11 | print(ngpu.GetStatus(syn_group))
12 |
13 | fact = ngpu.GetSynGroupParam(syn_group, "fact")
14 | print("fact: ", fact)
15 | offset = ngpu.GetSynGroupParam(syn_group, "offset")
16 | print("offset: ", offset)
17 |
18 | print(ngpu.GetStatus(syn_group, "fact"))
19 |
20 | print(ngpu.GetStatus(syn_group, "offset"))
21 |
22 | print(ngpu.GetStatus(syn_group, ["fact", "offset"]))
23 |
24 | print(ngpu.GetStatus(syn_group, ["offset", "fact"]))
25 |
26 |
27 |
--------------------------------------------------------------------------------
/python/test/test_syn_model.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 |
4 | tolerance = 1.0e-6
5 | dt_step = 0.1
6 | N = 5
7 | fact = 0.2
8 | offset = 0.03
9 |
10 | syn_group = ngpu.CreateSynGroup("test_syn_model")
11 | ngpu.SetSynGroupParam(syn_group, "fact", fact)
12 | ngpu.SetSynGroupParam(syn_group, "offset", offset)
13 |
14 | sg = ngpu.Create("spike_generator", N)
15 | neuron = ngpu.Create("aeif_cond_beta_multisynapse", 2*N)
16 | ngpu.SetStatus(neuron, {"t_ref": 10.0})
17 | neuron0 = neuron[0:N]
18 | neuron1 = neuron[N:2*N]
19 | dt_list = []
20 | for i in range(N):
21 | dt_list.append(dt_step*(-0.5*(N-1) + i))
22 |
23 | spike_time = [50.0]
24 | spike_height = [1.0]
25 | n_spikes = 1
26 | time_diff = 10.0
27 |
28 | # set spike times and height
29 | ngpu.SetStatus(sg, {"spike_times": spike_time, "spike_heights":spike_height})
30 | delay0 = 1.0
31 | delay1 = delay0 + time_diff
32 | weight_sg = 17.9
33 | weight_test = 0.0
34 |
35 | conn_dict={"rule": "one_to_one"}
36 | syn_dict0={"weight":weight_sg, "delay":delay0, "receptor":0, "synapse_group":0}
37 | syn_dict1={"weight":weight_sg, "delay":delay1, "receptor":0, "synapse_group":0}
38 |
39 | ngpu.Connect(sg, neuron0, conn_dict, syn_dict0)
40 | ngpu.Connect(sg, neuron1, conn_dict, syn_dict1)
41 |
42 | for i in range(N):
43 | delay_test = time_diff - dt_list[i]
44 | syn_dict_test={"weight":weight_test, "delay":delay_test, "receptor":0, \
45 | "synapse_group":syn_group}
46 | ngpu.Connect([neuron0[i]], [neuron1[i]], conn_dict, syn_dict_test)
47 |
48 | ngpu.Simulate(200.0)
49 |
50 | conn_id = ngpu.GetConnections(neuron0, neuron1)
51 | conn_status_dict = ngpu.GetStatus(conn_id, ["weight", "delay"])
52 | #print (conn_status_dict)
53 | for i in range(N):
54 | #print dt_list[i], conn_status_dict[i][0]
55 | expect_w = dt_list[i]*fact + offset
56 | if abs(expect_w - conn_status_dict[i][0])>tolerance:
57 | print("Expected weight: ", expect_w, " simulated: ", \
58 | conn_status_dict[i][0])
59 | sys.exit(1)
60 |
61 | sys.exit(0)
62 |
--------------------------------------------------------------------------------
/python/test/test_t_ref.py:
--------------------------------------------------------------------------------
1 | import nestgpu as ngpu
2 |
3 | neuron = ngpu.Create("aeif_cond_beta_multisynapse", 1, 1)
4 | ngpu.SetStatus(neuron, {"t_ref":100.0, "I_e":1000.0})
5 |
6 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
7 |
8 | ngpu.Simulate()
9 |
10 | data_list = ngpu.GetRecordData(record)
11 | t=[row[0] for row in data_list]
12 | V_m=[row[1] for row in data_list]
13 |
14 | import matplotlib.pyplot as plt
15 |
16 | plt.figure(1)
17 | plt.plot(t, V_m)
18 |
19 | plt.draw()
20 | plt.pause(1)
21 | raw_input("")
22 | plt.close()
23 |
--------------------------------------------------------------------------------
/python/test/test_user_m1.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import nestgpu as ngpu
3 |
4 | neuron = ngpu.Create('user_m1', 1, 3)
5 | ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5,
6 | "E_L":-70.6, "g_L":300.0})
7 | ngpu.SetStatus(neuron, {'E_rev':[20.0, 0.0, -85.0],
8 | 'tau_decay':[40.0, 20.0, 30.0],
9 | 'tau_rise':[20.0, 10.0, 5.0]})
10 | spike = ngpu.Create("spike_generator")
11 | spike_times = [10.0, 400.0]
12 | spike_heights = [1.0, 0.5]
13 | n_spikes = 2
14 |
15 | # set spike times and height
16 | ngpu.SetStatus(spike, {"spike_times": spike_times, \
17 | "spike_heights":spike_heights})
18 | delay = [1.0, 100.0, 130.0]
19 | weight = [0.1, 0.2, 0.15]
20 |
21 | conn_spec={"rule": "all_to_all"}
22 | for syn in range(3):
23 | syn_spec={ #'model': 'static_synapse', 'receptor_type': syn,
24 | 'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]}
25 | ngpu.Connect(spike, neuron, conn_spec, syn_spec)
26 |
27 | record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0])
28 |
29 | ngpu.Simulate(800.0)
30 |
31 | data_list = ngpu.GetRecordData(record)
32 | t=[row[0] for row in data_list]
33 | V_m=[row[1] for row in data_list]
34 |
35 | import matplotlib.pyplot as plt
36 |
37 | plt.figure(1)
38 | plt.plot(t, V_m)
39 |
40 | plt.draw()
41 | plt.pause(1)
42 | raw_input("")
43 | plt.close()
44 |
--------------------------------------------------------------------------------
/pythonlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # pynest/CMakeLists.txt
2 | #
3 | # This file is part of NEST GPU.
4 | #
5 | # Copyright (C) 2004 The NEST Initiative
6 | #
7 | # NEST GPU is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 2 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # NEST GPU is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with NEST GPU. If not, see .
19 |
20 | install( FILES ${PROJECT_SOURCE_DIR}/pythonlib/nestgpu.py
21 | DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYEXECDIR} )
22 |
--------------------------------------------------------------------------------
/pythonlib/Makefile.am:
--------------------------------------------------------------------------------
1 | python_PYTHON = nestgpu.py
2 |
--------------------------------------------------------------------------------
/src/aeif_cond_alpha_multisynapse_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aeif_cond_alpha_multisynapse_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef AEIFCONDALPHAMULTISYNAPSERK5_H
28 | #define AEIFCONDALPHAMULTISYNAPSERK5_H
29 |
30 | struct aeif_cond_alpha_multisynapse_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | aeif_cond_alpha_multisynapse_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | aeif_cond_alpha_multisynapse_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, aeif_cond_alpha_multisynapse_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, aeif_cond_alpha_multisynapse_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/aeif_cond_beta_multisynapse_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aeif_cond_beta_multisynapse_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef AEIFCONDBETAMULTISYNAPSERK5_H
28 | #define AEIFCONDBETAMULTISYNAPSERK5_H
29 |
30 | struct aeif_cond_beta_multisynapse_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | aeif_cond_beta_multisynapse_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | aeif_cond_beta_multisynapse_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, aeif_cond_beta_multisynapse_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, aeif_cond_beta_multisynapse_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/aeif_psc_alpha_multisynapse_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aeif_psc_alpha_multisynapse_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef AEIFPSCALPHAMULTISYNAPSERK5_H
28 | #define AEIFPSCALPHAMULTISYNAPSERK5_H
29 |
30 | struct aeif_psc_alpha_multisynapse_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | aeif_psc_alpha_multisynapse_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | aeif_psc_alpha_multisynapse_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, aeif_psc_alpha_multisynapse_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, aeif_psc_alpha_multisynapse_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/aeif_psc_delta_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aeif_psc_delta_multisynapse_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef AEIFPSCDELTAMULTISYNAPSERK5_H
28 | #define AEIFPSCDELTAMULTISYNAPSERK5_H
29 |
30 | struct aeif_psc_delta_multisynapse_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | aeif_psc_delta_multisynapse_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | aeif_psc_delta_multisynapse_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, aeif_psc_delta_multisynapse_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, aeif_psc_delta_multisynapse_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/aeif_psc_exp_multisynapse_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * aeif_psc_exp_multisynapse_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef AEIFPSCEXPMULTISYNAPSERK5_H
28 | #define AEIFPSCEXPMULTISYNAPSERK5_H
29 |
30 | struct aeif_psc_exp_multisynapse_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | aeif_psc_exp_multisynapse_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | aeif_psc_exp_multisynapse_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, aeif_psc_exp_multisynapse_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, aeif_psc_exp_multisynapse_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/cuda_error.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cuda_error.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef CUDAERROR_H
28 | #define CUDAERROR_H
29 | #include
30 | #include "ngpu_exception.h"
31 |
32 | #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
33 | inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
34 | {
35 | if (code != cudaSuccess)
36 | {
37 | fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
38 | if (abort) throw ngpu_exception("CUDA error");
39 | }
40 | }
41 |
42 | #define CUDA_CALL(x) do { if((x) != cudaSuccess) { \
43 | printf("Error at %s:%d\n",__FILE__,__LINE__); \
44 | throw ngpu_exception("CUDA error");}} while(0)
45 | #define CURAND_CALL(x) do { if((x) != CURAND_STATUS_SUCCESS) { \
46 | printf("Error at %s:%d\n",__FILE__,__LINE__); \
47 | throw ngpu_exception("CUDA error");}} while(0)
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/src/dir_connect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * dir_connect.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef DIRCONNECT_H
28 | #define DIRCONNECT_H
29 |
30 | struct DirectConnection
31 | {
32 | int irel_source_;
33 | int i_target_;
34 | unsigned char port_;
35 | float weight_;
36 | float delay_;
37 | };
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/src/dummyfile.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | int dummy_function_for_nestgpu()
3 | #include
4 | {
5 | #include
6 | return 0;
7 | #include
8 | }
9 |
--------------------------------------------------------------------------------
/src/fix_headers.sh:
--------------------------------------------------------------------------------
1 | for fn in $(ls *.h); do
2 | a=$(echo "$fn" | tr 'a-z' 'A-Z' | tr -d '_' | tr '.' '_')
3 | b=$(grep \#ifndef $fn | awk '{print $2}' | head -1)
4 | c=$(grep -A1 \#ifndef $fn | grep '#define' | awk '{print $2}' | head -1)
5 | if [ "$b" != "$a" ]; then
6 | echo "1 $fn $a $b"
7 | cat $fn | sed "s/$b/$a/" > tmp.txt
8 | /bin/mv tmp.txt $fn
9 | elif [ "$c" != "$a" ]; then
10 | echo "2 $fn $a $c"
11 | cat $fn | sed "s/$c/$a/" > tmp.txt
12 | /bin/mv tmp.txt $fn
13 | fi
14 | #echo "$a $b $c"
15 | done
16 |
--------------------------------------------------------------------------------
/src/getRealTime.h:
--------------------------------------------------------------------------------
1 | /*
2 | * getRealTime.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef GETREALTIME_H
28 | #define GETREALTIME_H
29 |
30 | double getRealTime();
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/src/get_spike.h:
--------------------------------------------------------------------------------
1 | /*
2 | * get_spike.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef GETSPIKE_H
28 | #define GETSPIKE_H
29 |
30 | __global__ void GetSpikes(double *spike_array, int array_size, int n_port,
31 | int n_var,
32 | float *port_weight_arr,
33 | int port_weight_arr_step,
34 | int port_weight_port_step, //float *y_arr);
35 | float *port_input_arr,
36 | int port_input_arr_step,
37 | int port_input_port_step);
38 |
39 |
40 | __global__ void CollectSpikeKernel(int n_spikes, int *SpikeTargetNum);
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/iaf_psc_exp_hc_params.h:
--------------------------------------------------------------------------------
1 | #ifndef IAFPSCEXPHCPARAMS_H
2 | #define IAFPSCEXPHCPARAMS_H
3 |
4 | #define P11 8.1873075E-01
5 | #define P22 9.9004983E-01
6 | #define P21 3.6067175E-04
7 | #define P20 3.9800665E-04
8 | #define Theta_rel 1.5000000E+01
9 | #define V_reset_rel 0.0000000E+00
10 | #define n_refractory_steps 20
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/src/izhikevich_cond_beta_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * izhikevich_cond_beta_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef IZHIKEVICHCONDBETARK5_H
28 | #define IZHIKEVICHCONDBETARK5_H
29 |
30 | struct izhikevich_cond_beta_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | izhikevich_cond_beta_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | izhikevich_cond_beta_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, izhikevich_cond_beta_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, izhikevich_cond_beta_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/locate.cu:
--------------------------------------------------------------------------------
1 | #include "locate.h"
2 |
3 | __device__ int locate(int val, int *data, int n)
4 | {
5 | int i_left = 0;
6 | int i_right = n-1;
7 | int i = (i_left+i_right)/2;
8 | while(i_right-i_left>1) {
9 | if (data[i] > val) i_right = i;
10 | else if (data[i].
20 | *
21 | */
22 |
23 | /////////////////////////////////////
24 | // ngpu_exception class definition
25 | // This class handles runtime errors
26 | /////////////////////////////////////
27 |
28 | #ifndef NGPUEXCEPTION_H
29 | #define NGPUEXCEPTION_H
30 | #include
31 | #include
32 | #include
33 |
34 | ///////////////////////////////////
35 | // ngpu_exception class definition
36 | // in case of errors displays a message and stop the execution
37 | //////////////////////////////////
38 | class ngpu_exception: public std::exception
39 | {
40 | const char *Message; // error message
41 |
42 | public:
43 | // constructors
44 | ngpu_exception(const char *ch) {Message=strdup(ch);}
45 | ngpu_exception(std::string s) {Message=strdup(s.c_str());}
46 | // throw method
47 | virtual const char* what() const throw()
48 | {
49 | return Message;
50 | }
51 | };
52 |
53 | #define BEGIN_TRY try
54 | #define END_TRY catch (ngpu_exception &e){ \
55 | std::cerr << "Error: " << e.what() << "\n"; } \
56 | catch (bad_alloc&) { std::cerr << "Error allocating memory." << "\n"; } \
57 | catch (...) { std::cerr << "Unrecognized error\n"; }
58 |
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/src/node_group.h:
--------------------------------------------------------------------------------
1 | /*
2 | * node_group.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef NODEGROUP_H
28 | #define NODEGROUP_H
29 |
30 | #define MAX_N_NODE_GROUPS 128
31 |
32 | struct NodeGroupStruct
33 | {
34 | int node_type_;
35 | int i_node_0_;
36 | int n_node_;
37 | int n_port_;
38 | int n_param_;
39 | double *get_spike_array_;
40 | int *spike_count_;
41 | float *rec_spike_times_;
42 | int *n_rec_spike_times_;
43 | int max_n_rec_spike_times_;
44 | float *den_delay_arr_;
45 | };
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/src/nota2.txt:
--------------------------------------------------------------------------------
1 | Confusione nei nomi delle variabili
2 |
3 | In spike_buffer.cu, get_spike.cu NestedLoopFunction0 e in send_spike.cu
4 | i_conn = SpikeConnIdx[i_spike] rappresenta l'indice del gruppo di connessioni che hanno lo stesso delay (ossia dovrebbe essere chiamato i_delay)
5 | ->rinominare in i_conn_group
6 |
7 | l'indice della connessione all'interno di questo gruppo si chiama i_syn
8 | ->rinominare in?
9 |
10 |
11 | In GetConnectionStatus i_conn è l'indice della connessione all'interno del gruppo
12 | -> rinominare in?
13 | i_group è l'indice del gruppo di connessioni che hanno lo stesso delay
14 | rinominare in i_conn_group
15 |
--------------------------------------------------------------------------------
/src/nota3.txt:
--------------------------------------------------------------------------------
1 | aeif_cond_alpha.cu
2 | Init()
3 | n_scal_param_ = N_SCAL_PARAM;
4 |
5 | var_arr_ = rk5_.GetYArr();
6 | param_arr_ = rk5_.GetParamArr();
7 |
8 | scal_param_name_ = aeif_cond_alpha_scal_param_name;
9 |
10 | port_weight_arr_ = GetParamArr() + n_scal_param_
11 | + GetPortParamIdx("g0");
12 |
13 | port_input_arr_ = GetVarArr() + n_scal_var_
14 | + GetPortVarIdx("g1");
15 |
16 |
--------------------------------------------------------------------------------
/src/poiss_gen_variables.h:
--------------------------------------------------------------------------------
1 | /*
2 | * poiss_gen_variables.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef POISSGENVARIABLES_H
28 | #define POISSGENVARIABLES_H
29 |
30 | #include
31 |
32 | enum {
33 | i_rate = 0,
34 | i_origin,
35 | i_start,
36 | i_stop,
37 | N_POISS_GEN_SCAL_PARAM
38 | };
39 |
40 | const std::string poiss_gen_scal_param_name[N_POISS_GEN_SCAL_PARAM] = {
41 | "rate",
42 | "origin",
43 | "start",
44 | "stop",
45 | };
46 |
47 | #define rate param[i_rate]
48 | #define origin param[i_origin]
49 | #define start param[i_start]
50 | #define stop param[i_stop]
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/src/poisson.h:
--------------------------------------------------------------------------------
1 | /*
2 | * poisson.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef POISSON_H
28 | #define POISSON_H
29 | #include
30 | #include
31 |
32 | extern __device__ unsigned int *PoissonData;
33 |
34 | class PoissonGenerator
35 | {
36 | unsigned int *dev_poisson_data_;
37 | int poisson_data_size_;
38 |
39 | int buffer_size_;
40 | int n_steps_;
41 | int i_step_;
42 | float lambda_;
43 | int more_steps_;
44 | int i_node_0_;
45 |
46 |
47 | int Init(curandGenerator_t *random_generator, unsigned int n);
48 |
49 | public:
50 | curandGenerator_t *random_generator_;
51 | int n_node_;
52 |
53 | PoissonGenerator();
54 |
55 | ~PoissonGenerator();
56 |
57 | int Free();
58 |
59 | int Create(curandGenerator_t *random_generator,
60 | int i_node_0, int n_node, float lambda);
61 |
62 | int Generate();
63 |
64 | int Generate(int max_n_steps);
65 |
66 | int Update(int max_n_steps);
67 |
68 | };
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/src/prefix_scan.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * prefix_scan.cu
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #include
28 | #include
29 | #include "prefix_scan.h"
30 | #include "scan.h"
31 |
32 | const unsigned int PrefixScan::AllocSize = 13 * 1048576 / 2;
33 |
34 | int PrefixScan::Init()
35 | {
36 | //printf("Initializing CUDA-C scan...\n\n");
37 | //initScan();
38 |
39 | return 0;
40 | }
41 |
42 | int PrefixScan::Scan(int *d_Output, int *d_Input, int n)
43 | {
44 | prefix_scan(d_Output, d_Input, n, true);
45 |
46 | return 0;
47 | }
48 |
49 | int PrefixScan::Free()
50 | {
51 | //closeScan();
52 | //gpuErrchk(cudaFree(d_Output));
53 | //gpuErrchk(cudaFree(d_Input));
54 |
55 | return 0;
56 | }
57 |
--------------------------------------------------------------------------------
/src/prefix_scan.h:
--------------------------------------------------------------------------------
1 | /*
2 | * prefix_scan.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef PREFIXSCAN_H
28 | #define PREFIXSCAN_H
29 |
30 | class PrefixScan
31 | {
32 | public:
33 | static const unsigned int AllocSize;
34 |
35 | /*
36 | uint *d_Input;
37 |
38 | uint *d_Output;
39 |
40 | uint *h_Input;
41 |
42 | uint *h_OutputCPU;
43 |
44 | uint *h_OutputGPU;
45 | */
46 |
47 | int Init();
48 |
49 | int Scan(int *d_Output, int *d_Input, int n);
50 |
51 | int Free();
52 | };
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/propagate_error.h:
--------------------------------------------------------------------------------
1 | #ifndef PROPAGATEERROR_H
2 | #define PROPAGATEERROR_H
3 |
4 | #define BEGIN_ERR_PROP \
5 | checkNESTGPUInstance(); \
6 | NESTGPU_instance->SetErrorFlag(false); \
7 | NESTGPU_instance->SetErrorMessage(""); \
8 | NESTGPU_instance->SetErrorCode(0); \
9 | try
10 |
11 | #define END_ERR_PROP \
12 | catch (ngpu_exception &e){ \
13 | NESTGPU_instance->SetErrorFlag(true); \
14 | NESTGPU_instance->SetErrorMessage(e.what()); \
15 | NESTGPU_instance->SetErrorCode(2); \
16 | } \
17 | catch (std::bad_alloc&) { \
18 | NESTGPU_instance->SetErrorFlag(true); \
19 | NESTGPU_instance->SetErrorMessage("Memory allocation error."); \
20 | NESTGPU_instance->SetErrorCode(1); \
21 | } \
22 | catch (...) { \
23 | NESTGPU_instance->SetErrorFlag(true); \
24 | NESTGPU_instance->SetErrorMessage("Error in NESTGPU function."); \
25 | NESTGPU_instance->SetErrorCode(255); \
26 | } \
27 | if (NESTGPU_instance->OnException() == ON_EXCEPTION_EXIT) { \
28 | std::cerr << NESTGPU_instance->GetErrorMessage(); \
29 | exit(NESTGPU_instance->GetErrorCode()); \
30 | }
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/src/propagator_stability.h:
--------------------------------------------------------------------------------
1 | /*
2 | * propagator_stability.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 | #ifndef PROPAGATOR_STABILITY_H
24 | #define PROPAGATOR_STABILITY_H
25 |
26 | // Propagators to handle similar tau_m and tau_syn_* time constants.
27 | __device__
28 | double propagator_31( double tau_syn, double tau, double C, double h );
29 | __device__
30 | double propagator_32( double tau_syn, double tau, double C, double h );
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/src/pypath.m4:
--------------------------------------------------------------------------------
1 | AC_DEFUN([adl_CHECK_PYTHON],
2 | [AM_PATH_PYTHON([2.0])
3 | AC_CACHE_CHECK([for $am_display_PYTHON includes directory],
4 | [adl_cv_python_inc],
5 | [adl_cv_python_inc=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()" 2>/dev/null`])
6 | AC_SUBST([PYTHONINC], [$adl_cv_python_inc])])
7 |
--------------------------------------------------------------------------------
/src/random.h:
--------------------------------------------------------------------------------
1 | #ifndef RANDOM_H
2 | #define RANDOM_H
3 | #include
4 |
5 | unsigned int *curand_int(curandGenerator_t &gen, size_t n);
6 |
7 | float *curand_uniform(curandGenerator_t &gen, size_t n);
8 |
9 | float *curand_normal(curandGenerator_t &gen, size_t n, float mean,
10 | float stddev);
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/src/rev_spike.h:
--------------------------------------------------------------------------------
1 | /*
2 | * rev_spike.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef REVSPIKE_H
28 | #define REVSPIKE_H
29 |
30 | extern unsigned int *d_RevSpikeNum;
31 | extern unsigned int *d_RevSpikeTarget;
32 | extern int *d_RevSpikeNConn;
33 |
34 | __global__ void RevSpikeReset();
35 |
36 | __global__ void RevSpikeBufferUpdate(unsigned int n_node);
37 |
38 | __global__ void SynapseUpdateKernel(int n_rev_spikes, int *RevSpikeNConn);
39 |
40 | int RevSpikeInit(NetConnection *net_connection);
41 |
42 | int RevSpikeFree();
43 |
44 | int ResetConnectionSpikeTimeDown(NetConnection *net_connection);
45 |
46 | int ResetConnectionSpikeTimeUp(NetConnection *net_connection);
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/rk5_interface.h:
--------------------------------------------------------------------------------
1 | /*
2 | * rk5_interface.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef RK5INTERFACE_H
28 | #define RK5INTERFACE_H
29 |
30 | #include "aeif_cond_beta_multisynapse_rk5.h"
31 | #include "aeif_psc_exp_multisynapse_rk5.h"
32 |
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/src/scan.h:
--------------------------------------------------------------------------------
1 | /*
2 | Matt Dean - https://github.com/mattdean1/cuda
3 | */
4 |
5 | #ifndef SCANCUH
6 | #define SCANCUH
7 |
8 | __global__ void prescan_arbitrary(int *g_odata, int *g_idata, int n, int powerOfTwo);
9 | __global__ void prescan_arbitrary_unoptimized(int *g_odata, int *g_idata, int n, int powerOfTwo);
10 |
11 | __global__ void prescan_large(int *g_odata, int *g_idata, int n, int* sums);
12 | __global__ void prescan_large_unoptimized(int *output, int *input, int n, int *sums);
13 |
14 | __global__ void add(int *output, int length, int *n1);
15 | __global__ void add(int *output, int length, int *n1, int *n2);
16 |
17 | void _checkCudaError(const char *message, cudaError_t err, const char *caller);
18 | void printResult(const char* prefix, int result, long nanoseconds);
19 | void printResult(const char* prefix, int result, float milliseconds);
20 |
21 | bool isPowerOfTwo(int x);
22 | int nextPowerOfTwo(int x);
23 |
24 | long get_nanos();
25 |
26 | void prefix_scan(int *output, int *input, int length, bool bcao);
27 | void scanLargeDeviceArray(int *output, int *input, int length, bool bcao);
28 | void scanSmallDeviceArray(int *d_out, int *d_in, int length, bool bcao);
29 | void scanLargeEvenDeviceArray(int *output, int *input, int length, bool bcao);
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/script.sh:
--------------------------------------------------------------------------------
1 |
2 | for syn in cond_alpha cond_beta psc_alpha psc_exp psc_delta; do
3 | SYN=$(echo $syn | tr 'a-z' 'A-Z' | tr -d '_')
4 |
5 | umf=user_m1_$syn
6 | um=user_m1
7 | UM=USERM1
8 | for fn in $(ls aeif_${syn}*.cu aeif_${syn}*.h); do
9 | fn1=$(echo $fn | sed "s/aeif_${syn}/$umf/")
10 | echo "$fn $fn1"
11 | cat $fn | sed "s/aeif_${syn}/$um/g; s/AEIF${SYN}/$UM/g" > \
12 | $fn1
13 | done
14 |
15 | umf=user_m2_$syn
16 | um=user_m2
17 | UM=USERM2
18 | for fn in $(ls aeif_${syn}*.cu aeif_${syn}*.h); do
19 | fn1=$(echo $fn | sed "s/aeif_${syn}/$umf/")
20 | echo "$fn $fn1"
21 | cat $fn | sed "s/aeif_${syn}/$um/g; s/AEIF${SYN}/$UM/g" > \
22 | $fn1
23 | done
24 | done
25 |
26 | for syn in psc_exp psc_exp_g; do
27 | SYN=$(echo $syn | tr 'a-z' 'A-Z' | tr -d '_')
28 |
29 | umf=user_m1_iaf_$syn
30 | um=user_m1
31 | UM=USERM1
32 | for fn in $(ls iaf_${syn}*.cu iaf_${syn}*.h); do
33 | fn1=$(echo $fn | sed "s/iaf_${syn}/$umf/")
34 | echo "$fn $fn1"
35 | cat $fn | sed "s/iaf_${syn}/$um/g; s/IAF${SYN}/$UM/g" > \
36 | $fn1
37 | done
38 |
39 | umf=user_m2_iaf_$syn
40 | um=user_m2
41 | UM=USERM2
42 | for fn in $(ls iaf_${syn}*.cu iaf_${syn}*.h); do
43 | fn1=$(echo $fn | sed "s/iaf_${syn}/$umf/")
44 | echo "$fn $fn1"
45 | cat $fn | sed "s/iaf_${syn}/$um/g; s/IAF${SYN}/$UM/g" > \
46 | $fn1
47 | done
48 | done
49 |
50 | /bin/cp user_m1_cond_beta.cu user_m1.cu
51 | /bin/cp user_m1_cond_beta.h user_m1.h
52 | /bin/cp user_m1_cond_beta_kernel.h user_m1_kernel.h
53 | /bin/cp user_m1_cond_beta_rk5.h user_m1_rk5.h
54 |
55 | /bin/cp user_m2_cond_beta.cu user_m2.cu
56 | /bin/cp user_m2_cond_beta.h user_m2.h
57 | /bin/cp user_m2_cond_beta_kernel.h user_m2_kernel.h
58 | /bin/cp user_m2_cond_beta_rk5.h user_m2_rk5.h
59 |
60 |
--------------------------------------------------------------------------------
/src/send_spike.h:
--------------------------------------------------------------------------------
1 | /*
2 | * send_spike.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef SENDSPIKE_H
28 | #define SENDSPIKE_H
29 |
30 | extern int *d_SpikeNum;
31 | extern int *d_SpikeSourceIdx;
32 | extern int *d_SpikeConnIdx;
33 | extern float *d_SpikeHeight;
34 | extern int *d_SpikeTargetNum;
35 |
36 | extern __device__ int MaxSpikeNum;
37 | extern __device__ int *SpikeNum;
38 | extern __device__ int *SpikeSourceIdx;
39 | extern __device__ int *SpikeConnIdx;
40 | extern __device__ float *SpikeHeight;
41 | extern __device__ int *SpikeTargetNum;
42 |
43 | __global__ void DeviceSpikeInit(int *spike_num, int *spike_source_idx,
44 | int *spike_conn_idx, float *spike_height,
45 | int *spike_target_num, int max_spike_num);
46 |
47 | __device__ void SendSpike(int i_source, int i_conn, float height,
48 | int target_num);
49 |
50 | void SpikeInit(int max_spike_num);
51 |
52 | __global__ void SpikeReset();
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/syn_model.h:
--------------------------------------------------------------------------------
1 | /*
2 | * syn_model.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef SYNMODEL_H
28 | #define SYNMODEL_H
29 |
30 | #include
31 | #include
32 |
33 | #define MAX_SYN_DT 16384
34 | enum SynModels {
35 | i_null_syn_model = 0, i_test_syn_model, i_stdp_model,
36 | N_SYN_MODELS
37 | };
38 |
39 | const std::string syn_model_name[N_SYN_MODELS] = {
40 | "", "test_syn_model", "stdp"
41 | };
42 |
43 | class SynModel
44 | {
45 | protected:
46 | int type_;
47 | int n_param_;
48 | const std::string *param_name_;
49 | float *d_param_arr_;
50 | public:
51 | virtual int Init() {return 0;}
52 | int GetNParam();
53 | std::vector GetParamNames();
54 | bool IsParam(std::string param_name);
55 | int GetParamIdx(std::string param_name);
56 | virtual float GetParam(std::string param_name);
57 | virtual int SetParam(std::string param_name, float val);
58 |
59 | friend class NESTGPU;
60 | };
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/src/test_syn_model.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * test_syn_model.cu
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #include
28 | #include
29 | #include
30 | #include "ngpu_exception.h"
31 | #include "cuda_error.h"
32 | #include "test_syn_model.h"
33 |
34 | using namespace test_syn_model_ns;
35 |
36 | __device__ void TestSynModelUpdate(float *w, float Dt, float *param)
37 | {
38 | float fact = param[0];
39 | float offset = param[1];
40 | *w += offset + fact*Dt;
41 | }
42 |
43 | int TestSynModel::Init()
44 | {
45 | type_ = i_test_syn_model;
46 | n_param_ = N_PARAM;
47 | param_name_ = test_syn_model_param_name;
48 | gpuErrchk(cudaMalloc(&d_param_arr_, n_param_*sizeof(float)));
49 | SetParam("fact", 0.1);
50 | SetParam("offset", 0.0);
51 |
52 | return 0;
53 | }
54 |
--------------------------------------------------------------------------------
/src/test_syn_model.h:
--------------------------------------------------------------------------------
1 | /*
2 | * test_syn_model.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef TESTSYNMODEL_H
28 | #define TESTSYNMODEL_H
29 |
30 | #include "syn_model.h"
31 |
32 | class TestSynModel : public SynModel
33 | {
34 | public:
35 | TestSynModel() {Init();}
36 | int Init();
37 | };
38 |
39 | namespace test_syn_model_ns
40 | {
41 | enum ParamIndexes {
42 | i_fact = 0, i_offset,
43 | N_PARAM
44 | };
45 |
46 | const std::string test_syn_model_param_name[N_PARAM] = {
47 | "fact", "offset"
48 | };
49 |
50 | }
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/src/user_m1.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1_H
28 | #define USERM1_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m1_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m1 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m1_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m1.h.bk:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2020 Bruno Golosio
3 | This program is free software: you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation, either version 3 of the License, or
6 | (at your option) any later version.
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | You should have received a copy of the GNU General Public License
12 | along with this program. If not, see .
13 | */
14 |
15 | #ifndef USERM1H
16 | #define USERM1H
17 |
18 | #include
19 | #include
20 | #include "cuda_error.h"
21 | #include "rk5.h"
22 | #include "node_group.h"
23 | #include "base_neuron.h"
24 | #include "neuron_models.h"
25 |
26 | #define MAX_PORT_NUM 20
27 |
28 | struct user_m1_rk5
29 | {
30 | int i_node_0_;
31 | };
32 |
33 | class user_m1 : public BaseNeuron
34 | {
35 | public:
36 | RungeKutta5 rk5_;
37 | float h_min_;
38 | float h_;
39 | user_m1_rk5 rk5_data_struct_;
40 |
41 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
42 | unsigned long long *seed);
43 |
44 | int Calibrate(double time_min, float time_resolution);
45 |
46 | int Update(long long it, double t1);
47 |
48 | int GetX(int i_neuron, int n_node, double *x) {
49 | return rk5_.GetX(i_neuron, n_node, x);
50 | }
51 |
52 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
53 | return rk5_.GetY(i_var, i_neuron, n_node, y);
54 | }
55 |
56 | template
57 | int UpdateNR(long long it, double t1);
58 |
59 | };
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/src/user_m1_cond_alpha.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_cond_alpha.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1CONDALPHA_H
28 | #define USERM1CONDALPHA_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m1_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m1 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m1_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m1_cond_alpha_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_cond_alpha_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1CONDALPHARK5_H
28 | #define USERM1CONDALPHARK5_H
29 |
30 | struct user_m1_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m1_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m1_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m1_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m1_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m1_cond_beta.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_cond_beta.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1CONDBETA_H
28 | #define USERM1CONDBETA_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m1_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m1 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m1_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m1_cond_beta_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_cond_beta_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1CONDBETARK5_H
28 | #define USERM1CONDBETARK5_H
29 |
30 | struct user_m1_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m1_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m1_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m1_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m1_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m1_iaf_psc_exp_hc_params.h:
--------------------------------------------------------------------------------
1 | #ifndef USERM1IAFPSCEXPHCPARAMS_H
2 | #define USERM1IAFPSCEXPHCPARAMS_H
3 |
4 | #define P11 8.1873075E-01
5 | #define P22 9.9004983E-01
6 | #define P21 3.6067175E-04
7 | #define P20 3.9800665E-04
8 | #define Theta_rel 1.5000000E+01
9 | #define V_reset_rel 0.0000000E+00
10 | #define n_refractory_steps 20
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/src/user_m1_psc_alpha.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_psc_alpha.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1PSCALPHA_H
28 | #define USERM1PSCALPHA_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m1_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m1 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m1_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m1_psc_alpha_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_psc_alpha_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1PSCALPHARK5_H
28 | #define USERM1PSCALPHARK5_H
29 |
30 | struct user_m1_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m1_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m1_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m1_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m1_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m1_psc_delta.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_psc_delta.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1PSCDELTA_H
28 | #define USERM1PSCDELTA_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m1_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m1 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m1_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | };
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/src/user_m1_psc_delta_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_psc_delta_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1PSCDELTARK5_H
28 | #define USERM1PSCDELTARK5_H
29 |
30 | struct user_m1_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m1_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m1_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m1_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m1_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m1_psc_exp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_psc_exp.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1PSCEXP_H
28 | #define USERM1PSCEXP_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m1_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m1 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m1_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m1_psc_exp_hc_params.h:
--------------------------------------------------------------------------------
1 | #ifndef USERM1PSCEXPHCPARAMS_H
2 | #define USERM1PSCEXPHCPARAMS_H
3 |
4 |
5 | #define P11 8.1873075E-01
6 | #define P22 9.9004983E-01
7 | #define P21 3.6067175E-04
8 | #define P20 3.9800665E-04
9 | #define Theta_rel 1.5000000E+01
10 | #define V_reset_rel 0.0000000E+00
11 | #define n_refractory_steps 20
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/user_m1_psc_exp_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_psc_exp_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1PSCEXPRK5_H
28 | #define USERM1PSCEXPRK5_H
29 |
30 | struct user_m1_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m1_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m1_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m1_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m1_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m1_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m1_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM1RK5_H
28 | #define USERM1RK5_H
29 |
30 | struct user_m1_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m1_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m1_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m1_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m1_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m1_rk5.h.bk:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2020 Bruno Golosio
3 | This program is free software: you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation, either version 3 of the License, or
6 | (at your option) any later version.
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | You should have received a copy of the GNU General Public License
12 | along with this program. If not, see .
13 | */
14 |
15 | #ifndef USERM1RK5H
16 | #define USERM1RK5H
17 |
18 | struct user_m1_rk5;
19 |
20 |
21 | template
22 | __device__
23 | void Derivatives(double x, float *y, float *dydx, float *param,
24 | user_m1_rk5 data_struct);
25 |
26 | template
27 | __device__
28 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
29 | user_m1_rk5 data_struct);
30 |
31 | __device__
32 | void NodeInit(int n_var, int n_param, double x, float *y,
33 | float *param, user_m1_rk5 data_struct);
34 |
35 | __device__
36 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
37 | float *param, user_m1_rk5 data_struct);
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/src/user_m2.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2_H
28 | #define USERM2_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m2_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m2 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m2_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m2_cond_alpha.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_cond_alpha.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2CONDALPHA_H
28 | #define USERM2CONDALPHA_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m2_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m2 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m2_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m2_cond_alpha_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_cond_alpha_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2CONDALPHARK5_H
28 | #define USERM2CONDALPHARK5_H
29 |
30 | struct user_m2_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m2_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m2_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m2_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m2_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m2_cond_beta.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_cond_beta.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2CONDBETA_H
28 | #define USERM2CONDBETA_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m2_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m2 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m2_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m2_cond_beta_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_cond_beta_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2CONDBETARK5_H
28 | #define USERM2CONDBETARK5_H
29 |
30 | struct user_m2_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m2_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m2_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m2_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m2_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m2_iaf_psc_exp_hc_params.h:
--------------------------------------------------------------------------------
1 | #ifndef USERM2IAFPSCEXPHCPARAMS_H
2 | #define USERM2IAFPSCEXPHCPARAMS_H
3 |
4 | #define P11 8.1873075E-01
5 | #define P22 9.9004983E-01
6 | #define P21 3.6067175E-04
7 | #define P20 3.9800665E-04
8 | #define Theta_rel 1.5000000E+01
9 | #define V_reset_rel 0.0000000E+00
10 | #define n_refractory_steps 20
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/src/user_m2_psc_alpha.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_psc_alpha.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2PSCALPHA_H
28 | #define USERM2PSCALPHA_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m2_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m2 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m2_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m2_psc_alpha_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_psc_alpha_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2PSCALPHARK5_H
28 | #define USERM2PSCALPHARK5_H
29 |
30 | struct user_m2_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m2_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m2_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m2_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m2_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m2_psc_delta.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_psc_delta.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2PSCDELTA_H
28 | #define USERM2PSCDELTA_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m2_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m2 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m2_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | };
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/src/user_m2_psc_delta_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_psc_delta_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2PSCDELTARK5_H
28 | #define USERM2PSCDELTARK5_H
29 |
30 | struct user_m2_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m2_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m2_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m2_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m2_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m2_psc_exp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_psc_exp.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2PSCEXP_H
28 | #define USERM2PSCEXP_H
29 |
30 | #include
31 | #include
32 | #include "cuda_error.h"
33 | #include "rk5.h"
34 | #include "node_group.h"
35 | #include "base_neuron.h"
36 | #include "neuron_models.h"
37 |
38 | #define MAX_PORT_NUM 20
39 |
40 | struct user_m2_rk5
41 | {
42 | int i_node_0_;
43 | };
44 |
45 | class user_m2 : public BaseNeuron
46 | {
47 | public:
48 | RungeKutta5 rk5_;
49 | float h_min_;
50 | float h_;
51 | user_m2_rk5 rk5_data_struct_;
52 |
53 | int Init(int i_node_0, int n_neuron, int n_port, int i_group,
54 | unsigned long long *seed);
55 |
56 | int Calibrate(double time_min, float time_resolution);
57 |
58 | int Update(long long it, double t1);
59 |
60 | int GetX(int i_neuron, int n_node, double *x) {
61 | return rk5_.GetX(i_neuron, n_node, x);
62 | }
63 |
64 | int GetY(int i_var, int i_neuron, int n_node, float *y) {
65 | return rk5_.GetY(i_var, i_neuron, n_node, y);
66 | }
67 |
68 | template
69 | int UpdateNR(long long it, double t1);
70 |
71 | };
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/src/user_m2_psc_exp_hc_params.h:
--------------------------------------------------------------------------------
1 | #ifndef USERM2PSCEXPHCPARAMS_H
2 | #define USERM2PSCEXPHCPARAMS_H
3 |
4 | #define P11 8.1873075E-01
5 | #define P22 9.9004983E-01
6 | #define P21 3.6067175E-04
7 | #define P20 3.9800665E-04
8 | #define Theta_rel 1.5000000E+01
9 | #define V_reset_rel 0.0000000E+00
10 | #define n_refractory_steps 20
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/src/user_m2_psc_exp_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_psc_exp_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2PSCEXPRK5_H
28 | #define USERM2PSCEXPRK5_H
29 |
30 | struct user_m2_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m2_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m2_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m2_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m2_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/user_m2_rk5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * user_m2_rk5.h
3 | *
4 | * This file is part of NEST GPU.
5 | *
6 | * Copyright (C) 2021 The NEST Initiative
7 | *
8 | * NEST GPU is free software: you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation, either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * NEST GPU is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with NEST GPU. If not, see .
20 | *
21 | */
22 |
23 |
24 |
25 |
26 |
27 | #ifndef USERM2RK5_H
28 | #define USERM2RK5_H
29 |
30 | struct user_m2_rk5;
31 |
32 |
33 | template
34 | __device__
35 | void Derivatives(double x, float *y, float *dydx, float *param,
36 | user_m2_rk5 data_struct);
37 |
38 | template
39 | __device__
40 | void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
41 | user_m2_rk5 data_struct);
42 |
43 | __device__
44 | void NodeInit(int n_var, int n_param, double x, float *y,
45 | float *param, user_m2_rk5 data_struct);
46 |
47 | __device__
48 | void NodeCalibrate(int n_var, int n_param, double x, float *y,
49 | float *param, user_m2_rk5 data_struct);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/write_iaf_psc_exp_hc_params.py:
--------------------------------------------------------------------------------
1 | time_res = 0.1
2 | tau_m = 10.0
3 | C_m = 250.0
4 | E_L = -65.0
5 | Theta_rel = 15.0
6 | V_reset_rel = 0.0
7 | tau_syn = 0.5
8 | t_ref = 2.0
9 |
10 |
11 | import numpy as np
12 |
13 | def propagator_32(tau_syn, tau, C, h):
14 | P32_linear = 1.0 / ( 2.0 * C * tau * tau ) * h * h \
15 | * ( tau_syn - tau ) * np.exp( -h / tau )
16 | P32_singular = h / C * np.exp( -h / tau )
17 | P32 = -tau / ( C * ( 1 - tau / tau_syn ) ) * np.exp( -h / tau_syn ) \
18 | * np.expm1( h * ( 1 / tau_syn - 1 / tau ) )
19 |
20 | dev_P32 = abs( P32 - P32_singular )
21 |
22 | if ( tau == tau_syn or ( abs( tau - tau_syn ) < 0.1 and dev_P32 > 2.0
23 | * abs( P32_linear ) ) ):
24 | return P32_singular
25 | else:
26 | return P32
27 |
28 | h = time_res
29 | P11 = np.exp( -h / tau_syn )
30 | P22 = np.exp( -h / tau_m )
31 | P21 = propagator_32( tau_syn, tau_m, C_m, h )
32 | P20 = tau_m / C_m * ( 1.0 - P22 )
33 |
34 | n_refractory_steps = int(round(t_ref/time_res))
35 |
36 | with open('iaf_psc_exp_hc_params.h', 'w') as p_file:
37 | p_file.write('#define P11 ' + '{:.7E}'.format(P11) + '\n')
38 | p_file.write('#define P22 ' + '{:.7E}'.format(P22) + '\n')
39 | p_file.write('#define P21 ' + '{:.7E}'.format(P21) + '\n')
40 | p_file.write('#define P20 ' + '{:.7E}'.format(P20) + '\n')
41 | p_file.write('#define Theta_rel ' + '{:.7E}'.format(Theta_rel) + '\n')
42 | p_file.write('#define V_reset_rel ' + '{:.7E}'.format(V_reset_rel) + '\n')
43 | p_file.write('#define n_refractory_steps ' + str(n_refractory_steps) + '\n')
44 |
--------------------------------------------------------------------------------
/todo.txt:
--------------------------------------------------------------------------------
1 | Produce build system and check it on different OSs: linux, mac, windows?
2 |
3 | Write tutorial
4 |
5 | implement new tests and improve existing ones
6 |
7 | implement other neuron models
8 |
9 | Make rk5 dynamic?
10 |
11 |
--------------------------------------------------------------------------------
/tox.ini:
--------------------------------------------------------------------------------
1 | [flake8]
2 | ignore = C901,E121,E123,E126,E203,E226,E24,E704,W503,W504,F401,E265,E275,F841
3 | statistics = True
4 | max-line-length = 120
5 | max-complexity = 10
6 |
--------------------------------------------------------------------------------