Skip to content

Commit

Permalink
updates and installation
Browse files Browse the repository at this point in the history
  • Loading branch information
neworderofjamie committed Feb 22, 2024
1 parent f3f1a99 commit 484d638
Show file tree
Hide file tree
Showing 18 changed files with 463 additions and 139 deletions.
2 changes: 1 addition & 1 deletion documentation/5/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 8fcd4cc66e68152844a59c6365600984
config: e7f4ce9044f550b7edaf1bcaedd3edcc
tags: 645f666f9bcd5a90fca523b33c5a78b7
33 changes: 21 additions & 12 deletions documentation/5/_sources/building_networks.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Building networks
The model
---------
A network model is defined as follows:
A :class:`.GeNNModel` must be created with a name and a default precision (see \ref floatPrecision)}:
A :class:`.GeNNModel` must be created with a default precision (see \ref floatPrecision) and a name:

.. code-block:: python
Expand All @@ -22,7 +22,7 @@ For example, the single-threaded CPU backend could be manually selected with:
model = GeNNModel("float", "YourModelName",
backend="single_threaded_cpu")
When running models on a GPU, smaller models may not fully occupy the device. In some scenerios such as gradient-based training and parameter sweeping,
When running models on a GPU, smaller models may not fully occupy the device. In some scenarios such as gradient-based training and parameter sweeping,
this can be overcome by runing multiple copies of the same model at the same time (batching in Machine Learning speak).
Batching can be enabled on a GeNN model with:

Expand All @@ -35,12 +35,19 @@ Whether state variables are duplicated or shared is controlled by the :class:`.V
associated with each variable. Please see TODO for more details.

Additionally, any preferences exposed by the backend can be configured here.
For example, the CUDA backend allows you to select which CUDA device to use via the manual_device_id
For example, the CUDA backend allows you to select which CUDA device to use via the manual_device_id:

.. code-block:: python
model = GeNNModel("float", "YourModelName",
backend="cuda", manual_device_id=0)
-----------
Populations
-----------

Populations formalise the concept of groups of neurons or synapses that are functionally related or a practical grouping, e.g. a brain region in a neuroscience model or a layer in a machine learning context.

Parameters
----------
Parameters are initialised to constant numeric values which are homogeneous across an entire population:
Expand All @@ -49,9 +56,10 @@ Parameters are initialised to constant numeric values which are homogeneous acro
ini = {"m": 0.0529324, ...}
They are very efficient to access from models as their values are either hard-coded into the kernels
They are very efficient to access from models as their values are either hard-coded into the backend code
or, on the GPU, delivered via high-performance constant cache.
However
However, they can only be used if literally no changes are needed for the entire simulation and all members of
the population have the exact same parameter value.

Extra global parameters
-----------------------
Expand All @@ -63,33 +71,34 @@ TODO

Variables
----------
Variables can be initialised in many ways.
By using the GPU to fill them with a constant value:
Variables contain values that are individual to the members of a population and can change over time. They can be initialised in many ways. The initialisation is configured through a Python dictionary that is then passed to :meth:`.GeNNModel.add_neuron_population` or :meth:`.GeNNModel.add_synapse_population` which create the populations.

To initialise variables one can use the backend, e.g. GPU, to fill them with a constant value:

.. code-block:: python
ini = {"m": 0.0529324, ...}
by copying in a sequence of values from Python:
or copy a sequence of values from Python:

.. code-block:: python
ini = {"m": np.arange(400.0), ...}
or by using a variable initialisation snippet configured using the following function:
or use a variable initialisation snippet returned by the following function:

.. autofunction:: pygenn.init_var
:noindex:

and then used in the dictionary the same way:
The resulting initialisation snippet can then be used in the dictionary in the usual way:

.. code-block:: python
ini = {"m": init, ...}
Variables references
--------------------
As well as variables and parameters, various types of model have variable references which are used to reference variables belonging to other populations.
As well as variables and parameters, various types of models have variable references which are used to reference variables belonging to other populations.
For example, postsynaptic update models can reference variables in the postsynaptic neuron model and custom updates are 'attached' to other populations based on their variable references.

A variable reference called R could be assigned to various types of variable using the following syntax:
Expand Down Expand Up @@ -213,4 +222,4 @@ updating model *variables*, they update model *connectivity* (current only with
Custom connectivity updates are added to a model using:

.. automethod:: .GeNNModel.add_custom_connectivity_update
:noindex:
:noindex:
5 changes: 3 additions & 2 deletions documentation/5/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ Note, this documentation is under construction. If you cannot find what you are
.. toctree::
:maxdepth: 4
:titlesonly:


installation
upgrading
building_networks
simulating_networks
custom_models
bibliography

userproject/index

Reference documentation <source/pygenn>
Expand Down
60 changes: 60 additions & 0 deletions documentation/5/_sources/installation.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. py:currentmodule:: pygenn
============
Installation
============
In future we plan on providing binary builds of GeNN via conda. However, for now, GeNN
needs to be installed from source.

----------------
Pre-installation
----------------
1. Install the C++ compiler on the machine, if not already present.
For Windows, Visual Studio 2019 or above is required. The Microsoft Visual Studio
Community Edition can be downloaded from
https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx.
When installing Visual Studio, one should select the 'Desktop
development with C++' configuration. On Linux, the GNU Compiler
Collection (GCC) 7.5 or above is required. This can be obtained from your
Linux distribution repository, for example on Ubuntu by running ``sudo apt-get install g++``,
or alternatively from https://gcc.gnu.org/index.html.
2. If your machine has an NVIDIA GPU and you haven't installed CUDA already,
obtain a fresh installation of the NVIDIA CUDA toolkit from
https://developer.nvidia.com/cuda-downloads
Again, be sure to pick CUDA and C++ compiler versions which are compatible
with each other. The latest C++ compiler need not necessarily be
compatible with the latest CUDA toolkit.
3. GeNN uses the ``CUDA_PATH`` environment variable to determine which
version of CUDA to build against. On Windows, this is set automatically when
installing CUDA. However, if you choose, you can verify which version is
selected by running ``echo %CUDA_PATH`` in a command prompt.
However, on Linux and Mac you need to set ``CUDA_PATH`` manually with:
```bash
export CUDA_PATH=/usr/local/cuda
```
assuming CUDA is installed in /usr/local/cuda (the standard location
on Ubuntu Linux). Again, to make this change persistent, this can
be added to your login script (e.g. ``.profile`` or ``.bashrc``)
4. Either download the latest release of GeNN and extract into your
home directory or clone using git from https://github.com/genn-team/genn
5. On Linux, install the development version of libffi. For example, on Ubuntu you can do this
by running ``sudo apt-get install libffi-dev``.
6. Install the pybind11, psutil and numpy packages with pip i.e. ``pip install pybind11 psutil numpy``.

----------------------
Building with setup.py
----------------------
From the GeNN directory, the GeNN libraries and python package can be built
with ``python setup.py install``. If you wish to create an editable install
(most useful if you are intending to modify GeNN yourself) you can also used
``python setup.py develop``. On Linux (or Windows if you have a debug version
of the python libraries installed) you can build a debug version of GeNN with
``python setup.py build_ext --debug develop``.

-----------------
Building with pip
-----------------
From the GeNN directory, the GeNN libraries and python package can be built
with ``pip install .``. If you wish to create an editable install
(most useful if you are intending to modify GeNN yourself) you can also used
``pip install --editable .``.
8 changes: 8 additions & 0 deletions documentation/5/_sources/source/pygenn.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ pygenn.custom\_update\_models module
:undoc-members:
:show-inheritance:

pygenn.genn module
------------------

.. automodule:: pygenn.genn
:members:
:undoc-members:
:show-inheritance:

pygenn.genn\_groups module
--------------------------

Expand Down
15 changes: 12 additions & 3 deletions documentation/5/_sources/upgrading.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ Syntax changes
In order to streamline the modelling process and reduce the number of ways to achieve the same thing we have to maintain,
several areas of GeNN syntax have changed:

- single PSM code string
- Postsynaptic models were previously implemented with two code strings: ``apply_input_code`` and
``decay_code``. This was unnecessarily complex and the order these were evaluated in wasn't obvious.
Therefore, these have been replaced by a single ``sim_code`` code string from which input can be
delivered to the postsynaptic neuron using the ``injectCurrent(x)`` function.

- :meth:`.GeNNModel.add_synapse_population` was becoming rather cumbersome and this was only made worse by postsynaptic models and weight update models now taking variable references.
To improve this:

Expand All @@ -30,5 +34,10 @@ several areas of GeNN syntax have changed:

- The row build and diagonal build state variables in sparse/toeplitz connectivity building code were really ugly and confusing. Sparse connectivity init snippets now just let the user write whatever sort of loop they want and do the initialisation outside and toeplitz reuses the for_each_synapse structure described above to do similar.
- ``GLOBALG`` and ``INDIVIDUALG`` confused almost all new users and were really only used with ``StaticPulse`` weight update models. Same functionality can be achieved with a ``StaticPulseConstantWeight`` version with the weight as a parameter. Then I've renamed all the 'obvious' :class:`.SynapseMatrixType` variants so you just chose :attr:`.SynapseMatrixType.SPARSE`, :attr:`.SynapseMatrixType.DENSE`, :attr:`.SynapseMatrixType.TOEPLITZ` or :attr:`.SynapseMatrixType.PROCEDURAL` (with :attr:`.SynapseMatrixType.DENSE_PROCEDURALG` and :attr:`.SynapseMatrixType.PROCEDURAL_KERNELG` for more unusual options)
- Extra global parameters only support the 'pointer' form, awaiting a PR to implement settable parameters to replace the other sort
- Removed implicit variable referneces
- Extra global parameters used to be creatable with pointer types to allow models to access
arbitrary sized arrays and non-pointer types to create parameters that could be modified at runtime.
The latter use case is now handled much more efficiently using the `Dynamic parameters`_ system.
- Weight update and postsynaptic models could previous refer to neuron variables via _implicit_
references. For example ``$(V_pre)`` would refer to a variable called ``V`` on the presynaptic
neuron population. This mechanism has been replaced by adding _explicit_ references to
weight update, postsynaptic and current source model (see `Variables references`_).
Loading

0 comments on commit 484d638

Please sign in to comment.