Skip to content

Commit 35829b2

Browse files
Merge branch 'genn_5'
2 parents 6a549a0 + 1bbd4d8 commit 35829b2

File tree

1,417 files changed

+101970
-402647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,417 files changed

+101970
-402647
lines changed

.dockerignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
.git
22
build
33
dist
4-
documentation
5-
doxygen
4+
docs
65
lib
76
obj*
87
tests
9-
userproject
10-
!userproject/include
118
**/*.so
129
**/*.lib

Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LABEL maintainer="J.C.Knight@sussex.ac.uk" \
88
org.opencontainers.image.source="https://github.com/genn-team/genn" \
99
org.opencontainers.image.title="GeNN Docker image"
1010

11-
# Update APT database and upgrade any outdated packages and install Python, pip and swig
11+
# Update APT database and upgrade any outdated packages and install Python, pip and pkgconfig
1212
RUN apt-get update && \
1313
apt-get upgrade -y && \
1414
apt-get install -yq --no-install-recommends python3-dev python3-pip swig gosu nano
@@ -22,7 +22,7 @@ RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
2222

2323
# Upgrade pip itself and install numpy and jupyter
2424
RUN python -m pip install --upgrade pip && \
25-
python -m pip install numpy jupyter matplotlib
25+
python -m pip install numpy jupyter matplotlib psutil pybind11
2626

2727
# Copy GeNN into /opt
2828
COPY . ${GENN_PATH}
@@ -31,9 +31,7 @@ COPY . ${GENN_PATH}
3131
WORKDIR ${GENN_PATH}
3232

3333
# Install GeNN and PyGeNN
34-
RUN make install -j `lscpu -p | egrep -v '^#' | sort -u -t, -k 2,4 | wc -l`
35-
RUN make DYNAMIC=1 LIBRARY_DIRECTORY=${GENN_PATH}/pygenn/genn_wrapper/ -j `lscpu -p | egrep -v '^#' | sort -u -t, -k 2,4 | wc -l`
36-
RUN python setup.py develop
34+
RUN python3 setup.py develop
3735

3836
# Start entrypoint
3937
# **NOTE** in 'exec' mode shell arguments aren't expanded so can't use environment variables

Jenkinsfile

Lines changed: 122 additions & 81 deletions
Large diffs are not rendered by default.

LICENSE

Lines changed: 504 additions & 0 deletions
Large diffs are not rendered by default.

LICENSE.txt

Lines changed: 0 additions & 339 deletions
This file was deleted.

Makefile

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,35 @@
22
include src/genn/MakefileCommon
33

44
# List of backends
5-
BACKENDS :=single_threaded_cpu
5+
BACKENDS :=single_threaded_cpu_backend
66
ifdef CUDA_PATH
7-
BACKENDS +=cuda
7+
BACKENDS +=cuda_backend
88
endif
99

1010
ifdef OPENCL_PATH
11-
BACKENDS +=opencl
11+
BACKENDS +=opencl_backend
1212
endif
1313

1414
# Build list of libraries
15-
BACKEND_LIBS :=$(BACKENDS:%=$(LIBRARY_DIRECTORY)/libgenn_%_backend$(GENN_PREFIX).$(LIBRARY_EXTENSION))
15+
BACKEND_LIBS :=$(BACKENDS:%=$(LIBRARY_DIRECTORY)/libgenn_%$(GENN_PREFIX).$(LIBRARY_EXTENSION))
1616

1717
# Default install location
1818
PREFIX ?= /usr/local
1919

20-
.PHONY: all clean install uninstall libgenn $(BACKENDS)
20+
.PHONY: all clean genn $(BACKENDS)
2121

22-
all: libgenn $(BACKENDS)
22+
all: genn $(BACKENDS)
2323

24-
install: libgenn $(BACKENDS)
25-
@# Make install directories
26-
@mkdir -p $(PREFIX)/bin
27-
@mkdir -p $(PREFIX)/include/genn
28-
@mkdir -p $(PREFIX)/share/genn
29-
@mkdir -p $(PREFIX)/lib
30-
@mkdir -p $(PREFIX)/src/genn/generator
31-
@# Deploy libraries, headers and data
32-
@cp -f $(LIBRARY_DIRECTORY)/libgenn*.a $(PREFIX)/lib
33-
@cp -rf $(GENN_DIR)/include/genn/* $(PREFIX)/include/genn/
34-
@cp -rf $(GENN_DIR)/share/genn/* $(PREFIX)/share/genn/
35-
@# Deploy minimal set of Makefiles for building generator
36-
@cp -r $(GENN_DIR)/src/genn/MakefileCommon $(PREFIX)/src/genn
37-
@cp -r $(GENN_DIR)/src/genn/generator/Makefile* $(PREFIX)/src/genn/generator
38-
@# Deploy genn_generator source and shell scripts
39-
@cp -r $(GENN_DIR)/src/genn/generator/generator.cc $(PREFIX)/src/genn/generator
40-
@cp -r $(GENN_DIR)/bin/genn-buildmodel.sh $(PREFIX)/bin
41-
@cp -r $(GENN_DIR)/bin/genn-create-user-project.sh $(PREFIX)/bin
42-
43-
uninstall:
44-
@# Delete installed resources
45-
@rm -rf $(PREFIX)/src/genn
46-
@rm -rf $(PREFIX)/lib/libgenn*.a
47-
@rm -rf $(PREFIX)/include/genn
48-
@rm -f $(PREFIX)/share/genn
49-
# Delete installed executables
50-
@rm -f $(PREFIX)/bin/genn-buildmodel.sh
51-
@rm -f $(PREFIX)/bin/genn-create-user-project.sh
52-
53-
libgenn:
24+
genn:
5425
$(MAKE) -C src/genn/genn
5526

56-
single_threaded_cpu:
27+
single_threaded_cpu_backend: genn
5728
$(MAKE) -C src/genn/backends/single_threaded_cpu
5829

59-
cuda:
30+
cuda_backend: genn
6031
$(MAKE) -C src/genn/backends/cuda
6132

62-
opencl:
33+
opencl_backend: genn
6334
$(MAKE) -C src/genn/backends/opencl
6435

6536
clean:

README.md

Lines changed: 45 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -33,74 +33,55 @@ purposes and are opened and closed without warning.
3333

3434
### Installing GeNN
3535

36-
Installing GeNN comprises a few simple steps [^1] to create the GeNN
37-
development environment:
38-
39-
[^1]: While GeNN models are normally simulated using CUDA on NVIDIA GPUs, if you want to use GeNN on a machine without an NVIDIA GPU, you can skip steps v and vi and use GeNN in "CPU_ONLY" mode.
40-
41-
1. If you have downloaded a zip file, unpack GeNN.zip in a convenient
42-
location. Otherwise enter the directory where you downloaded the Git
43-
repository.
44-
45-
2. Add GeNN's 'bin' directory to your path, e.g. if you are running Linux or Mac OS X and extracted/downloaded GeNN to
46-
``$HOME/GeNN``, this can be done with:
47-
```bash
48-
export PATH=$PATH:$HOME/GeNN/bin
49-
```
50-
to make this change persistent, this can be added to your login script (e.g. `.profile` or `.bashrc`) using your favourite text editor or with:
51-
```bash
52-
echo "export PATH=$PATH:$CUDA_PATH/bin" >> ~/.bash_profile
53-
```
54-
If you are using Windows, the easiest way to modify the path is
55-
by using the 'Environment variables' GUI, which can be accessed by clicking start and searching for
56-
(by starting to type) 'Edit environment variables for your account'.
57-
In the upper 'User variables' section, scroll down until you see 'Path',
58-
select it and click 'Edit'.
59-
Now add a new directory to the path by clicking 'New' in the 'Edit environment variable' window e.g.:
60-
![Screenshot of windows edit environment variable window](/doxygen/images/path_windows.png)
61-
if GeNN is installed in a sub-directory of your home directory (``%USERPROFILE%`` is an environment variable which points to the current user's home directory) called ``genn``.
62-
63-
3. Install the C++ compiler on the machine, if not already present.
64-
For Windows, download Microsoft Visual Studio Community Edition from
65-
https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx.
66-
When installing Visual Studio, one should select the 'Desktop
67-
development with C++' configuration.
68-
Mac users should download and set up Xcode from
69-
https://developer.apple.com/xcode/index.html
70-
, Linux users should install the GNU compiler collection gcc and g++
71-
from their Linux distribution repository, or alternatively from
72-
https://gcc.gnu.org/index.html
73-
74-
4. If your machine has a GPU and you haven't installed CUDA already,
36+
In future we plan on providing binary builds of GeNN via conda. However, for now, GeNN
37+
needs to be installed from source.
38+
39+
#### Pre-installation
40+
41+
1. Install the C++ compiler on the machine, if not already present.
42+
For Windows, Visual Studio 2019 or above is required. The Microsoft Visual Studio
43+
Community Edition can be downloaded from
44+
https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx.
45+
When installing Visual Studio, one should select the 'Desktop
46+
development with C++' configuration. On Linux, the GNU Compiler
47+
Collection (GCC) 7.5 or above is required. This can be obtained from your
48+
Linux distribution repository, for example on Ubuntu by running ``sudo apt-get install g++``,
49+
or alternatively from https://gcc.gnu.org/index.html.
50+
2. If your machine has an NVIDIA GPU and you haven't installed CUDA already,
7551
obtain a fresh installation of the NVIDIA CUDA toolkit from
7652
https://developer.nvidia.com/cuda-downloads
77-
Again, be sure to pick CUDA and C++ compiler versions which are compatible
53+
Be sure to pick CUDA and C++ compiler versions which are compatible
7854
with each other. The latest C++ compiler need not necessarily be
7955
compatible with the latest CUDA toolkit.
80-
81-
5. GeNN uses the ``CUDA_PATH`` environment variable to determine which
56+
3. GeNN uses the ``CUDA_PATH`` environment variable to determine which
8257
version of CUDA to build against. On Windows, this is set automatically when
8358
installing CUDA. However, if you choose, you can verify which version is
84-
selected by looking for the ``CUDA_PATH`` environment variable in the lower 'System variables' section of the GUI you used to configure the path:
85-
![Screenshot of windows edit environment variable window](/doxygen/images/cuda_path_windows.png)
86-
here, CUDA 10.1 and 11.4 are installed and CUDA 11.4 is selected via ``CUDA_PATH``.
87-
However, on Linux and Mac you need to set ``CUDA_PATH`` manually with:
88-
```bash
89-
export CUDA_PATH=/usr/local/cuda
90-
```
59+
selected by running ``echo %CUDA_PATH`` in a command prompt.
60+
However, on Linux, you need to set ``CUDA_PATH`` manually with:
61+
``export CUDA_PATH=/usr/local/cuda``
9162
assuming CUDA is installed in /usr/local/cuda (the standard location
9263
on Ubuntu Linux). Again, to make this change persistent, this can
9364
be added to your login script (e.g. ``.profile`` or ``.bashrc``)
94-
95-
This normally completes the installation. Windows users must close
96-
and reopen their command window so changes to the path take effect.
97-
98-
If you are using GeNN in Windows, the Visual Studio development
99-
environment must be set up within every instance of the CMD.EXE command
100-
window used. One can open an instance of CMD.EXE with the development
101-
environment already set up by navigating to Start - All Programs -
102-
Microsoft Visual Studio - Visual Studio Tools - x64 Native Tools Command Prompt. You may also wish to
103-
create a shortcut for this tool on the desktop, for convenience.
65+
4. Either download the latest release of GeNN and extract into your
66+
home directory or clone using git from https://github.com/genn-team/genn
67+
5. On Linux, install the development version of libffi. For example, on Ubuntu you can do this
68+
by running ``sudo apt-get install libffi-dev``.
69+
6. Install the pybind11, psutil and numpy packages with pip i.e. ``pip install pybind11 psutil numpy``.
70+
71+
72+
#### Building with setup.py
73+
From the GeNN directory, the GeNN libraries and python package can be built
74+
with ``python setup.py install``. If you wish to create an editable install
75+
(most useful if you are intending to modify GeNN yourself) you can also used
76+
``python setup.py develop``. On Linux (or Windows if you have a debug version
77+
of the python libraries installed) you can build a debug version of GeNN with
78+
``python setup.py build_ext --debug develop``.
79+
80+
#### Building with pip
81+
From the GeNN directory, the GeNN libraries and python package can be built
82+
with ``pip install .``. If you wish to create an editable install
83+
(most useful if you are intending to modify GeNN yourself) you can also used
84+
``pip install --editable .``.
10485

10586
### Docker
10687
You can also use GeNN through our CUDA-enabled docker container which comes with GeNN pre-installed.
@@ -158,116 +139,15 @@ docker run --gpus=all -e LOCAL_USER_ID=`id -u $USER` -e LOCAL_GROUP_ID=`id -g $U
158139

159140
### Sample projects
160141

161-
At the moment, the following C++ example projects are provided with GeNN:
162-
163-
- Self-organisation with STDP in the locust olfactory system \([Nowotny et al. 2005][@Nowotnyetal2005]\):
164-
- with all-to-all connectivity, using built-in neuron and synapse models \(for benchmarks see [Yavuz et al. 2016][@Yavuzetal2016]\)
165-
- with sparse connectivity for some synapses, using user-defined neuron-and synapse models \(for benchmarks see [Yavuz et al. 2016][@Yavuzetal2016]\)
166-
- using BITMASK connectivity
167-
- using synapses with axonal delays
168-
- Pulse-coupled network of Izhikevich neurons \([Izhikevich 2003][@Izhikevich2003]\) (for benchmarks see [Yavuz et al. 2016][@Yavuzetal2016])
169-
170-
- Genetic algorithm for tracking parameters in a Hodgkin-Huxley model cell
171-
172-
- Classifier based on an abstraction of the insect olfactory system \([Schmuker et al. 2014][@Schmukeretal2014]\)
142+
At the moment, the following Python example projects are provided with GeNN:
173143

174144
- Cortical microcircuit model \([Potjans et al. 2014][@Potjans2014]\)
145+
- SuperSpike model \([Zenke et al. 2018][@Zenke2018]\)
146+
- MNIST classifier using an insect-inspired mushroom body model
175147

176-
- Toy examples:
177-
- Single neuron population of Izhikevich neuron(s) receiving Poisson spike trains as input
178-
- Single neuron population of Izhikevich neuron(s) with no synapses
179-
- Network of Izhikevich neurons with delayed synapses
180-
181-
In order to get a quick start and run one of the the provided example models, navigate to one of the example project directories in the userproject sub-directory, and then follow the instructions in the README file contained within.
182-
183-
## Simulating a new model
184-
185-
The sample projects listed above are already quite highly integrated examples. If you wanted to use GeNN to develop a new C++ model, you would do the following:
186-
187-
1. The neuronal network of interest is defined in a model definition file,
188-
e.g. ``Example1.cc``.
189-
190-
2. Within the the model definition file ``Example1.cc``, the following tasks
191-
need to be completed:
192-
193-
1. The GeNN file ``modelSpec.h`` needs to be included,
194-
```c++
195-
#include "modelSpec.h"
196-
```
197-
198-
2. The values for initial variables and parameters for neuron and synapse
199-
populations need to be defined, e.g.
200-
```c++
201-
NeuronModels::PoissonNew::ParamValues poissonParams(
202-
10.0); // 0 - firing rate
203-
```
204-
would define the (homogeneous) parameters for a population of Poisson
205-
neurons [^2].
206-
[^2]: The number of required parameters and their meaning is defined by the
207-
neuron or synapse type. Refer to the [User manual](https://genn-team.github.io/genn/documentation/4/html/dc/d05/UserManual.html) for details. We recommend, however, to use comments like
208-
in the above example to achieve maximal clarity of each parameter's
209-
meaning.
210-
211-
If heterogeneous parameter values are required for a particular
212-
population of neurons (or synapses), they need to be defined as "variables"
213-
rather than parameters. See the [User manual](https://genn-team.github.io/genn/documentation/4/html/dc/d05/UserManual.html) for how to define new neuron (or synapse) types and the [Variable initialisation](https://genn-team.github.io/genn/documentation/4/html/d4/dc6/sectVariableInitialisation.html) section for more information on
214-
initialising these variables to hetererogenous values.
215-
216-
3. The actual network needs to be defined in the form of a function
217-
``modelDefinition`` [^3], i.e.
218-
```c++
219-
void modelDefinition(ModelSpec &model);
220-
```
221-
[^3]: The name ``modelDefinition`` and its parameter of type ``ModelSpec&``
222-
are fixed and cannot be changed if GeNN is to recognize it as a
223-
model definition.
224-
225-
4. Inside ``modelDefinition()``, The time step ``DT`` needs to be defined, e.g.
226-
```c++
227-
model.setDT(0.1);
228-
```
229-
\note
230-
All provided examples and pre-defined model elements in GeNN work with
231-
units of mV, ms, nF and uS. However, the choice of units is entirely
232-
left to the user if custom model elements are used.
233-
234-
[MBody1.cc](userproject/MBody1_project/model/MBody1.cc) shows a typical example of a model definition function. In
235-
its core it contains calls to ``ModelSpec::addNeuronPopulation`` and
236-
``ModelSpec::addSynapsePopulation`` to build up the network. For a full range
237-
of options for defining a network, refer to the [User manual](https://genn-team.github.io/genn/documentation/4/html/dc/d05/UserManual.html).
238-
239-
3. The programmer defines their own "simulation" code similar to
240-
the code in [MBody1Sim.cc](userproject/MBody1_project/model/MBody1Sim.cc). In this code,
241-
242-
1. They can manually define the connectivity matrices between neuron groups.
243-
Refer to the \ref subsect34 section for the required format of
244-
connectivity matrices for dense or sparse connectivities.
245-
246-
2. They can define input patterns or individual initial values for neuron and
247-
/ or synapse variables.
248-
\note
249-
The initial values or initialisation "snippets" given in the ``modelDefinition`` are automatically applied.
250-
251-
3. They use ``stepTime()`` to run one time step on either the CPU or GPU depending on the options passed to genn-buildmodel.
252-
253-
4. They use functions like ``copyStateFromDevice()`` etc to transfer the
254-
results from GPU calculations to the main memory of the host computer
255-
for further processing.
256-
257-
5. They analyze the results. In the most simple case this could just be
258-
writing the relevant data to output files.
148+
In order to get a quick start and run one of the the provided example models, navigate to the userproject directory, and run the python script with ``--help`` to see what options are available.
259149

260150
For more details on how to use GeNN, please see [documentation](http://genn-team.github.io/genn/).
261151

262-
If you use GeNN in your work, please cite "Yavuz, E., Turner, J. and Nowotny, T. GeNN: a code generation framework for accelerated brain simulations. Scientific Reports, 6. (2016)"
263-
264-
265-
[@Izhikevich2003]: https://doi.org/10.1109/TNN.2003.820440 "Izhikevich, E. M. Simple model of spiking neurons. IEEE transactions on neural networks 14, 1569–1572 (2003)"
266-
267-
[@Nowotnyetal2005]: https://doi.org/10.1007/s00422-005-0019-7 "Nowotny, T., Huerta, R., Abarbanel, H. D. & Rabinovich, M. I. Self-organization in the olfactory system: one shot odor recognition in insects. Biological cybernetics 93, 436–446 (2005)"
268-
269152
[@Potjans2014]: https://doi.org/10.1093/cercor/bhs358 "Potjans, T. C., & Diesmann, M. The Cell-Type Specific Cortical Microcircuit: Relating Structure and Activity in a Full-Scale Spiking Network Model. Cerebral Cortex, 24(3), 785–806 (2014)"
270-
271-
[@Schmukeretal2014]: https://doi.org/10.1073/pnas.1303053111 "Schmuker, M., Pfeil, T. and Nawrot, M.P. A neuromorphic network for generic multivariate data classification. Proceedings of the National Academy of Sciences, 111(6), pp.2081-2086 (2014)"
272-
273-
[@Yavuzetal2016]: https://doi.org/10.1038%2Fsrep18854 "Yavuz, E., Turner, J. and Nowotny, T. GeNN: a code generation framework for accelerated brain simulations. Scientific reports, 6. (2016)"
153+
[@Zenke2018]: https://doi.org/10.1162/neco_a_01086 "Zenke, F., & Ganguli, S. (2018). SuperSpike: Supervised Learning in Multilayer Spiking Neural Networks. Neural Computation, 30(6), 1514–1541."

0 commit comments

Comments
 (0)