GeNN  2.2.3
GPU enhanced Neuronal Networks (GeNN)
modelSpec.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------
2  Author: Thomas Nowotny
3 
4  Institute: Center for Computational Neuroscience and Robotics
5  University of Sussex
6  Falmer, Brighton BN1 9QJ, UK
7 
8  email to: T.Nowotny@sussex.ac.uk
9 
10  initial version: 2010-02-07
11 
12  This file contains neuron model declarations.
13 
14 --------------------------------------------------------------------------*/
15 
16 //--------------------------------------------------------------------------
23 //--------------------------------------------------------------------------
24 
25 #ifndef _MODELSPEC_H_
26 #define _MODELSPEC_H_
27 
28 #include "neuronModels.h"
29 #include "synapseModels.h"
30 #include "postSynapseModels.h"
31 
32 #include <set>
33 #include <string>
34 #include <vector>
35 
36 using namespace std;
37 
38 
39 void initGeNN();
40 extern unsigned int GeNNReady;
41 
42 // connectivity of the network (synapseConnType)
44 {
48 };
49 
50 // conductance type (synapseGType)
52 {
56 };
57 
58 #define NO_DELAY 0
59 
60 #define NOLEARNING 0
61 #define LEARNING 1
62 
63 #define EXITSYN 0
64 #define INHIBSYN 1
65 
66 #define CPU 0
67 #define GPU 1
68 
69 // Floating point precision to use for models
71 {
72  GENN_FLOAT,
73  GENN_DOUBLE,
75 };
76 
77 #define AUTODEVICE -1
78 
79 
80 /*===============================================================
82 //
83 ================================================================*/
84 
85 class NNmodel
86 {
87 public:
88 
89  // PUBLIC MODEL VARIABLES
90  //========================
91 
92  string name;
93  string ftype;
94  string RNtype;
95  double dt;
96  int final;
97  unsigned int needSt;
98  unsigned int needSynapseDelay;
99  bool timing;
100  unsigned int seed;
101  unsigned int resetKernel;
102 
103 
104  // PUBLIC NEURON VARIABLES
105  //========================
106 
107  unsigned int neuronGrpN;
108  vector<string> neuronName;
109  vector<unsigned int> neuronN;
110  vector<unsigned int> sumNeuronN;
111  vector<unsigned int> padSumNeuronN;
112  vector<unsigned int> neuronPostSyn;
113  vector<unsigned int> neuronType;
114  vector<vector<double> > neuronPara;
115  vector<vector<double> > dnp;
116  vector<vector<double> > neuronIni;
117  vector<vector<unsigned int> > inSyn;
118  vector<vector<unsigned int> > outSyn;
119  vector<bool> neuronNeedSt;
120  vector<bool> neuronNeedTrueSpk;
121  vector<bool> neuronNeedSpkEvnt;
122  vector<vector<bool> > neuronVarNeedQueue;
123  vector<set<pair<string, string>>> neuronSpkEvntCondition;
124  vector<unsigned int> neuronDelaySlots;
125  vector<int> neuronHostID;
126  vector<int> neuronDeviceID;
127 
128 
129  // PUBLIC SYNAPSE VARIABLES
130  //=========================
131 
132  unsigned int synapseGrpN;
133  vector<string> synapseName;
134  //vector<unsigned int>synapseNo; // !<numnber of synapses in a synapse group
135  vector<unsigned int> maxConn;
136  vector<unsigned int> padSumSynapseKrnl; //Combination of padSumSynapseTrgN and padSumMaxConn to support both sparse and all-to-all connectivity in a model
137  vector<unsigned int> synapseType;
138  vector<SynapseConnType> synapseConnType;
139  vector<SynapseGType> synapseGType;
140  vector<unsigned int> synapseSpanType;
141  vector<unsigned int> synapseSource;
142  vector<unsigned int> synapseTarget;
143  vector<unsigned int> synapseInSynNo;
144  vector<unsigned int> synapseOutSynNo;
145  vector<bool> synapseUsesTrueSpikes;
146  vector<bool> synapseUsesSpikeEvents;
147  vector<bool> synapseUsesPostLearning;
149  vector<bool> needEvntThresholdReTest;
150  vector<vector<double> > synapsePara;
151  vector<vector<double> > synapseIni;
152  vector<vector<double> > dsp_w;
153  vector<unsigned int> postSynapseType;
154  vector<vector<double> > postSynapsePara;
155  vector<vector<double> > postSynIni;
156  vector<vector<double> > dpsp;
157  unsigned int lrnGroups;
158  vector<unsigned int> padSumLearnN;
159  vector<unsigned int> lrnSynGrp;
160  vector<unsigned int> synapseDelay;
161  unsigned int synDynGroups;
162  vector<unsigned int> synDynGrp;
163  vector<unsigned int> padSumSynDynN;
164  vector<int> synapseHostID;
165  vector<int> synapseDeviceID;
166 
167 
168  // PUBLIC KERNEL PARAMETER VARIABLES
169  //==================================
170 
171  vector<string> neuronKernelParameters;
173  vector<string> synapseKernelParameters;
179 
180 private:
181 
182 
183  // PRIVATE NEURON FUNCTIONS
184  //=========================
185 
186  void setNeuronName(unsigned int, const string);
187  void setNeuronN(unsigned int, unsigned int);
188  void setNeuronType(unsigned int, unsigned int);
189  void setNeuronPara(unsigned int, double*);
190  void setNeuronIni(unsigned int, double*);
191  void initDerivedNeuronPara();
192 
193 
194  // PRIVATE SYNAPSE FUNCTIONS
195  //==========================
196 
197  void setSynapseName(unsigned int, const string);
198  void setSynapseType(unsigned int, unsigned int);
199  void setSynapseSource(unsigned int, unsigned int);
200  void setSynapseTarget(unsigned int, unsigned int);
201  void setSynapsePara(unsigned int, double*);
202  void setSynapseConnType(unsigned int, unsigned int);
203  void setSynapseGType(unsigned int, unsigned int);
204  void initDerivedSynapsePara();
205  void initDerivedPostSynapsePara();
206  void registerSynapsePopulation(unsigned int);
207 
208 public:
209 
210 
211  // PUBLIC MODEL FUNCTIONS
212  //=======================
213 
214  NNmodel();
215  ~NNmodel();
216  void setName(const string);
217  void setPrecision(FloatType);
218  void setDT(double);
219  void setTiming(bool);
220  void setSeed(unsigned int);
221  void checkSizes(unsigned int *, unsigned int *, unsigned int *); //< Check if the sizes of the initialized neuron and synapse groups are correct.
222 #ifndef CPU_ONLY
223  void setGPUDevice(int);
224 #endif
225  string scalarExpr(const double) const;
226  void setPopulationSums();
227  void finalize();
228 
229 
230  // PUBLIC NEURON FUNCTIONS
231  //========================
232 
233  void addNeuronPopulation(const string&, unsigned int, unsigned int, const double *, const double *);
234  void addNeuronPopulation(const string&, unsigned int, unsigned int, const vector<double>&, const vector<double>&);
235  void setNeuronClusterIndex(const string &neuronGroup, int hostID, int deviceID);
236  void activateDirectInput(const string&, unsigned int type);
237  void setConstInp(const string&, double);
238  unsigned int findNeuronGrp(const string&) const;
239 
240 
241  // PUBLIC SYNAPSE FUNCTIONS
242  //=========================
243 
244  void addSynapsePopulation(const string &name, unsigned int syntype, SynapseConnType conntype, SynapseGType gtype, const string& src, const string& trg, const double *p);
245  void addSynapsePopulation(const string&, unsigned int, SynapseConnType, SynapseGType, unsigned int, unsigned int, const string&, const string&, const double *, const double *, const double *);
246  void addSynapsePopulation(const string&, unsigned int, SynapseConnType, SynapseGType, unsigned int, unsigned int, const string&, const string&, const double *, const double *, const double *, const double *);
247  void addSynapsePopulation(const string&, unsigned int, SynapseConnType, SynapseGType, unsigned int, unsigned int, const string&, const string&,
248  const vector<double>&, const vector<double>&, const vector<double>&, const vector<double>&);
249  void setSynapseG(const string&, double);
250  void setMaxConn(const string&, unsigned int); //< Set maximum connections per neuron for the given group (needed for optimization by sparse connectivity)
251  void setSpanTypeToPre(const string&);
252  void setSynapseClusterIndex(const string &synapseGroup, int hostID, int deviceID);
253  void initLearnGrps();
254  unsigned int findSynapseGrp(const string&) const; //< Find the the ID number of a synapse group by its name
255 
256 };
257 
258 #endif
unsigned int synapseGrpN
Number of synapse groups.
Definition: modelSpec.h:132
Definition: modelSpec.h:53
vector< unsigned int > synapseOutSynNo
The target neurons&#39; outgoing synapse for each synapse group.
Definition: modelSpec.h:144
unsigned int resetKernel
The identity of the kernel in which the spike counters will be reset.
Definition: modelSpec.h:101
vector< unsigned int > maxConn
Padded summed maximum number of connections for a neuron in the neuron groups.
Definition: modelSpec.h:135
vector< vector< double > > neuronIni
Initial values of neurons.
Definition: modelSpec.h:116
vector< int > neuronHostID
The ID of the cluster node which the neuron groups are computed on.
Definition: modelSpec.h:125
vector< unsigned int > synapseSource
Presynaptic neuron groups.
Definition: modelSpec.h:141
double dt
The integration time step of the model.
Definition: modelSpec.h:95
vector< vector< unsigned int > > outSyn
The ids of the outgoing synapse groups.
Definition: modelSpec.h:118
vector< bool > neuronNeedSt
Whether last spike time needs to be saved for a group.
Definition: modelSpec.h:119
vector< bool > synapseUsesSynapseDynamics
Defines if there is any continuos synapse dynamics defined.
Definition: modelSpec.h:148
Definition: modelSpec.h:45
bool timing
Definition: modelSpec.h:99
vector< unsigned int > synDynGrp
Enumeration of the IDs of synapse groups that have synapse Dynamics.
Definition: modelSpec.h:162
vector< unsigned int > padSumLearnN
Padded summed neuron numbers of learn group source populations.
Definition: modelSpec.h:158
vector< unsigned int > neuronN
Number of neurons in group.
Definition: modelSpec.h:109
Definition: modelSpec.h:85
vector< vector< unsigned int > > inSyn
The ids of the incoming synapse groups.
Definition: modelSpec.h:117
vector< bool > neuronNeedTrueSpk
Whether spike-like events from a group are required.
Definition: modelSpec.h:120
Definition: modelSpec.h:54
vector< set< pair< string, string > > > neuronSpkEvntCondition
Will contain the spike event condition code when spike events are used.
Definition: modelSpec.h:123
unsigned int needSynapseDelay
Whether delayed synapse conductance is required in the network.
Definition: modelSpec.h:98
vector< vector< double > > synapsePara
parameters of synapses
Definition: modelSpec.h:150
vector< unsigned int > lrnSynGrp
Enumeration of the IDs of synapse groups that learn.
Definition: modelSpec.h:159
vector< string > synapseKernelParameterTypes
Definition: modelSpec.h:174
vector< string > synapseKernelParameters
Definition: modelSpec.h:173
Definition: modelSpec.h:46
vector< string > neuronKernelParameterTypes
Definition: modelSpec.h:172
vector< unsigned int > padSumNeuronN
Padded summed neuron numbers.
Definition: modelSpec.h:111
vector< unsigned int > neuronType
Postsynaptic methods to the neuron.
Definition: modelSpec.h:113
vector< bool > synapseUsesPostLearning
Defines if anything is done in case of postsynaptic neuron spiking before presynaptic neuron (punishm...
Definition: modelSpec.h:147
vector< bool > synapseUsesTrueSpikes
Defines if synapse update is done after detection of real spikes (only one point after threshold) ...
Definition: modelSpec.h:145
Definition: modelSpec.h:55
vector< string > neuronKernelParameters
Definition: modelSpec.h:171
vector< int > neuronDeviceID
The ID of the CUDA device which the neuron groups are comnputed on.
Definition: modelSpec.h:126
vector< vector< double > > dsp_w
Derived synapse parameters (weightUpdateModel only)
Definition: modelSpec.h:152
vector< string > synapseDynamicsKernelParameters
Definition: modelSpec.h:177
vector< string > simLearnPostKernelParameterTypes
Definition: modelSpec.h:176
vector< int > synapseDeviceID
The ID of the CUDA device which the synapse groups are comnputed on.
Definition: modelSpec.h:165
vector< SynapseGType > synapseGType
Type of specification method for synaptic conductance.
Definition: modelSpec.h:139
vector< unsigned int > synapseTarget
Postsynaptic neuron groups.
Definition: modelSpec.h:142
vector< unsigned int > synapseInSynNo
IDs of the target neurons&#39; incoming synapse variables for each synapse group.
Definition: modelSpec.h:143
unsigned int needSt
Whether last spike times are needed at all in this network model (related to STDP) ...
Definition: modelSpec.h:97
vector< string > synapseDynamicsKernelParameterTypes
Definition: modelSpec.h:178
vector< string > neuronName
Names of neuron groups.
Definition: modelSpec.h:108
vector< unsigned int > neuronDelaySlots
The number of slots needed in the synapse delay queues of a neuron group.
Definition: modelSpec.h:124
vector< bool > synapseUsesSpikeEvents
Defines if synapse update is done after detection of spike events (every point above threshold) ...
Definition: modelSpec.h:146
vector< vector< double > > postSynapsePara
parameters of postsynapses
Definition: modelSpec.h:154
vector< unsigned int > sumNeuronN
Summed neuron numbers.
Definition: modelSpec.h:110
unsigned int lrnGroups
Number of synapse groups with learning.
Definition: modelSpec.h:157
vector< bool > neuronNeedSpkEvnt
Whether spike-like events from a group are required.
Definition: modelSpec.h:121
unsigned int seed
Definition: modelSpec.h:100
vector< vector< double > > dpsp
Derived postsynapse parameters.
Definition: modelSpec.h:156
vector< vector< double > > postSynIni
Initial values of postsynaptic variables.
Definition: modelSpec.h:155
SynapseGType
Definition: modelSpec.h:51
string RNtype
Underlying type for random number generation (default: long)
Definition: modelSpec.h:94
string ftype
Type of floating point variables (float, double, ...; default: float)
Definition: modelSpec.h:93
vector< SynapseConnType > synapseConnType
Connectivity type of synapses.
Definition: modelSpec.h:138
vector< string > synapseName
Names of synapse groups.
Definition: modelSpec.h:133
vector< int > synapseHostID
The ID of the cluster node which the synapse groups are computed on.
Definition: modelSpec.h:164
string name
Name of the neuronal newtwork model.
Definition: modelSpec.h:92
SynapseConnType
Definition: modelSpec.h:43
vector< vector< double > > dnp
Derived neuron parameters.
Definition: modelSpec.h:115
vector< unsigned int > padSumSynDynN
Padded summed neuron numbers of synapse dynamics group source populations.
Definition: modelSpec.h:163
vector< unsigned int > neuronPostSyn
Definition: modelSpec.h:112
vector< string > simLearnPostKernelParameters
Definition: modelSpec.h:175
vector< vector< bool > > neuronVarNeedQueue
Whether a neuron variable needs queueing for syn code.
Definition: modelSpec.h:122
FloatType
Definition: modelSpec.h:70
vector< vector< double > > neuronPara
Parameters of neurons.
Definition: modelSpec.h:114
void initGeNN()
Method for GeNN initialisation (by preparing standard models)
Definition: src/modelSpec.cc:35
vector< unsigned int > postSynapseType
Types of post-synaptic model.
Definition: modelSpec.h:153
Definition: modelSpec.h:47
vector< unsigned int > synapseType
Types of synapses.
Definition: modelSpec.h:137
vector< bool > needEvntThresholdReTest
Defines whether the Evnt Threshold needs to be retested in the synapse kernel due to multiple non-ide...
Definition: modelSpec.h:149
Definition: modelSpec.h:74
vector< unsigned int > padSumSynapseKrnl
Definition: modelSpec.h:136
vector< vector< double > > synapseIni
Initial values of synapse variables.
Definition: modelSpec.h:151
vector< unsigned int > synapseSpanType
Execution order of synapses in the kernel. It determines whether synapses are executed in parallel fo...
Definition: modelSpec.h:140
vector< unsigned int > synapseDelay
Global synaptic conductance delay for the group (in time steps)
Definition: modelSpec.h:160
unsigned int synDynGroups
Number of synapse groups that define continuous synapse dynamics.
Definition: modelSpec.h:161
unsigned int neuronGrpN
Number of neuron groups.
Definition: modelSpec.h:107
unsigned int GeNNReady
Definition: src/modelSpec.cc:30