GeNN  1.1
GPU enhanced Neuronal Networks (GeNN)
 All Classes Files Functions Variables Typedefs Macros Pages
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 #ifndef _MODELSPEC_H_
17 #define _MODELSPEC_H_
18 
19 //--------------------------------------------------------------------------
24 //--------------------------------------------------------------------------
25 
26 #include <vector>
27 #include "global.h"
28 
29 
30 //neuronType
31 #define MAPNEURON 0
32 #define POISSONNEURON 1
33 #define TRAUBMILES 2
34 #define IZHIKEVICH 3
35 #define IZHIKEVICH_V 4
36 #define MAXNRN 5 // maximum number of neuron types: SpineML needs to know this
37 
38 #define SYNTYPENO 4
39 
40 //synapseType
41 #define NSYNAPSE 0
42 #define NGRADSYNAPSE 1
43 #define LEARN1SYNAPSE 2
44 #define USERDEFSYNAPSE 3
45 
46 //input type
47 #define NOINP 0
48 #define CONSTINP 1
49 #define MATINP 2
50 #define INPRULE 3
51 #define RANDNINP 4
52 
53 unsigned int SYNPNO[SYNTYPENO]= {
54  3, // NSYNAPSE_PNO
55  4, // NGRADSYNAPSE_PNO
56  13, // LEARN1SYNAPSE_PNO
57  1 // USERDEFSYNAPSE_PNO
58 };
59 
60 //connectivity of the network (synapseConnType)
61 #define ALLTOALL 0
62 #define DENSE 1
63 #define SPARSE 2
64 
65 //conductance type (synapseGType)
66 #define INDIVIDUALG 0
67 #define GLOBALG 1
68 #define INDIVIDUALID 2
69 
70 #define NO_DELAY 1
71 
72 #define NOLEARNING 0
73 #define LEARNING 1
74 
75 #define EXITSYN 0
76 #define INHIBSYN 1
77 
78 #define TRUE 1
79 #define FALSE 0
80 
81 #define CPU 0
82 #define GPU 1
83 
84 #define FLOAT 0
85 #define DOUBLE 1
86 
87 #define AUTODEVICE -1
88 
89 // for purposes of STDP
90 #define SPK_THRESH_STDP 0.0f
91 //#define MAXSPKCNT 50000
92 
93 //postsynaptic parameters
94 #define EXPDECAY 0 //default - how it is in the original version
95 #define IZHIKEVICH_PS 1 //empty postsynaptic rule for the Izhikevich model.
96 // currently values >1 will be defined by code generation.
97 #define MAXPOSTSYN 2 // maximum number of postsynaptic integration: SpineML needs to know this
98 
99 class dpclass {
100 public:
101  dpclass() {}
102  virtual float calculateDerivedParameter(int index, vector < float > pars, float dt = 1.0) {return -1;}
103 };
104 
105 
108 {
109  string simCode;
113  string resetCode;
114  vector<string> varNames;
115  vector<string> tmpVarNames;
116  vector<string> varTypes;
117  vector<string> tmpVarTypes;
118  vector<string> pNames;
119  vector<string> dpNames;
124 
127 };
128 
129 
131 {
133  string postSynDecay;
134  vector<string> varNames;
135  vector<string> varTypes;
136  vector<string> pNames;
137  vector<string> dpNames;
139 };
140 
141 
142 /*===============================================================
144 //
145 ================================================================*/
146 
147 class NNmodel
148 {
149 
150 public:
151 
152  // PUBLIC MODEL VARIABLES
153  //========================
154 
155  string name;
156  string ftype;
157  int valid;
158  unsigned int needSt;
159  unsigned int needSynapseDelay;
161 
162  // PUBLIC NEURON VARIABLES
163  //========================
164 
165  vector<string> neuronName;
166  unsigned int neuronGrpN;
167  vector<unsigned int> neuronN;
168  vector<unsigned int> sumNeuronN;
169  vector<unsigned int> padSumNeuronN;
170  vector<unsigned int> neuronPostSyn;
171  vector<unsigned int> neuronType;
172  vector<vector<float> > neuronPara;
173  vector<vector<float> > dnp;
174  vector<vector<float> > neuronIni;
175  vector<vector<unsigned int> > inSyn;
176  vector<int> receivesInputCurrent;
177  vector<unsigned int> neuronNeedSt;
178  vector<unsigned int> neuronDelaySlots;
179  vector<int> neuronHostID;
180  vector<int> neuronDeviceID;
181 
183  //NB: This is not directly user controlled, but is decided by, for example,
184  //the pre-spike threshold set for outgoing synapses
185  vector<float> nSpkEvntThreshold;
186 
187 
188  // PUBLIC SYNAPSE VARIABLES
189  //=========================
190 
191  vector<string> synapseName;
192  unsigned int synapseGrpN;
193  //vector<unsigned int>synapseNo; // !<numnber of synapses in a synapse group
194  vector<unsigned int> sumSynapseTrgN;
195  vector<unsigned int> padSumSynapseTrgN;
196  vector<unsigned int> maxConn;
197  vector<unsigned int> padSumSynapseKrnl; //Combination of padSumSynapseTrgN and padSumMaxConn to support both sparse and all-to-all connectivity in a model
198  vector<unsigned int> synapseType;
199  vector<unsigned int> synapseConnType;
200  vector<unsigned int> synapseGType;
201  vector<unsigned int> synapseSource;
202  vector<unsigned int> synapseTarget;
203  vector<unsigned int> synapseInSynNo;
204  vector<vector<float> > synapsePara;
205  vector<vector<float> > dsp;
206  vector<unsigned int> postSynapseType;
207  vector<vector<float> > postSynapsePara;
208  vector<vector<float> > postSynIni;
209  vector<vector<float> > dpsp;
210  vector<float> g0;
211  vector<float> globalInp;
212  unsigned int lrnGroups;
213  vector<unsigned int> padSumLearnN;
214  vector<unsigned int> lrnSynGrp;
215  vector<unsigned int> synapseDelay;
216  vector<int> synapseHostID;
217  vector<int> synapseDeviceID;
218 
219 
220 private:
221 
222  // PRIVATE NEURON FUNCTIONS
223  //=========================
224 
225  void setNeuronName(unsigned int, const string);
226  void setNeuronN(unsigned int, unsigned int);
227  void setNeuronType(unsigned int, unsigned int);
228  void setNeuronPara(unsigned int, float*);
229  void setNeuronIni(unsigned int, float*);
230  unsigned int findNeuronGrp(const string);
231  void initDerivedNeuronPara(unsigned int);
232  void initNeuronSpecs(unsigned int);
233 
234 
235  // PRIVATE SYNAPSE FUNCTIONS
236  //==========================
237 
238  void setSynapseName(unsigned int, const string);
239  void setSynapseType(unsigned int, unsigned int);
240  void setSynapseSource(unsigned int, unsigned int);
241  void setSynapseTarget(unsigned int, unsigned int);
242  void setSynapsePara(unsigned int, float*);
243  void setSynapseConnType(unsigned int, unsigned int);
244  void setSynapseGType(unsigned int, unsigned int);
245  unsigned int findSynapseGrp(const string); //< Find the the ID number of a synapse group by its name
246  void initDerivedSynapsePara(unsigned int);
247  void initDerivedPostSynapsePara(unsigned int);
248 
249 
250 public:
251 
252  // PUBLIC MODEL FUNCTIONS
253  //=======================
254 
255  NNmodel();
256  ~NNmodel();
257  void setName(const string);
258 
259  void setPrecision(unsigned int);//< Set numerical precision for floating point
260 
261  void checkSizes(unsigned int *, unsigned int *, unsigned int *); //< Check if the sizes of the initialized neuron and synapse groups are correct.
262 
263  void resetPaddedSums();
264 
265  void setGPUDevice(int);
266 
267  // PUBLIC NEURON FUNCTIONS
268  //========================
269 
270  void addNeuronPopulation(const char *, unsigned int, unsigned int, float *, float *);
271 
272  void addNeuronPopulation(const string, unsigned int, unsigned int, float *, float *);
273  //void activateDirectInput(const char *, unsigned int);
274  //void addPostSyntoNeuron(const string,unsigned int); //!< Method for defining postsynaptic dynamics
275 
276  void activateDirectInput(const string, unsigned int);
277 
278  void setConstInp(const string, float);
279 
280  void setNeuronClusterIndex(const string neuronGroup, int hostID, int deviceID);
281 
282 
283  // PUBLIC SYNAPSE FUNCTIONS
284  //=========================
285 
286  void addSynapsePopulation(const string name, unsigned int syntype, unsigned int conntype, unsigned int gtype, const string src, const string trg, float *p) __attribute__ ((deprecated));
287 
288  void addSynapsePopulation(const char *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, const char *, const char *, float *, float *, float *);
289 
290  void addSynapsePopulation(const string, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, const string, const string, float *, float *, float *);
291 
292  void setSynapseG(const string, float);
293  //void setSynapseNo(unsigned int,unsigned int); // !< Sets the number of connections for sparse matrices
294 
295  void setMaxConn(const string, unsigned int); //< Set maximum connections per neuron for the given group (needed for optimization by sparse connectivity)
296 
297  void setSynapseClusterIndex(const string synapseGroup, int hostID, int deviceID);
298 
299 };
300 
301 #endif
int chooseGPUDevice
Definition: modelSpec.h:160
unsigned int synapseGrpN
Number of synapse groups.
Definition: modelSpec.h:192
void setSynapseG(const string, float)
Method for setting the conductance (g) value for a synapse population with "GLOBALG" charactertistic...
Definition: modelSpec.cc:453
vector< string > varNames
Names of the variables in the postsynaptic model.
Definition: modelSpec.h:134
vector< unsigned int > maxConn
Padded summed maximum number of connections for a neuron in the neuron groups.
Definition: modelSpec.h:196
vector< int > neuronHostID
The ID of the cluster node which the neuron groups are computed on.
Definition: modelSpec.h:179
vector< unsigned int > synapseSource
Presynaptic neuron groups.
Definition: modelSpec.h:201
void setName(const string)
Method to set the neuronal network model name.
Definition: modelSpec.cc:40
vector< string > pNames
Names of (independent) parameters of the model. These are assumed to be always of type "float"...
Definition: modelSpec.h:118
vector< unsigned int > synapseConnType
Connectivity type of synapses.
Definition: modelSpec.h:199
vector< string > extraGlobalNeuronKernelParameters
Additional parameter in the neuron kernel; it is translated to a population specific name but otherwi...
Definition: modelSpec.h:123
#define SYNTYPENO
Definition: modelSpec.h:38
void addSynapsePopulation(const string name, unsigned int syntype, unsigned int conntype, unsigned int gtype, const string src, const string trg, float *p) __attribute__((deprecated))
Overload of method for backwards compatibility.
Definition: modelSpec.cc:339
vector< unsigned int > padSumLearnN
Padded summed neuron numbers of learn group source populations.
Definition: modelSpec.h:213
vector< unsigned int > neuronN
Number of neurons in group.
Definition: modelSpec.h:167
Definition: modelSpec.h:147
vector< vector< unsigned int > > inSyn
The ids of the incoming synapse groups.
Definition: modelSpec.h:175
void setMaxConn(const string, unsigned int)
This function defines the maximum number of connections for a neuron in the population.
Definition: modelSpec.cc:525
void checkSizes(unsigned int *, unsigned int *, unsigned int *)
This function checks if the number of parameters and variables that are defined by the user are of co...
Definition: modelSpec.cc:300
vector< unsigned int > padSumSynapseTrgN
"Padded" summed target neuron numbers
Definition: modelSpec.h:195
unsigned int needSynapseDelay
Whether delayed synapse conductance is required in the network.
Definition: modelSpec.h:159
vector< unsigned int > lrnSynGrp
Enumeration of the IDs of synapse groups that learn.
Definition: modelSpec.h:214
vector< string > pNames
Names of (independent) parameters of the model. These are assumed to be always of type "float"...
Definition: modelSpec.h:136
vector< vector< float > > dsp
Derived synapse parameters.
Definition: modelSpec.h:205
vector< vector< float > > postSynapsePara
parameters of postsynapses
Definition: modelSpec.h:207
vector< int > receivesInputCurrent
flags whether neurons of a population receive explicit input currents
Definition: modelSpec.h:176
void setGPUDevice(int)
Method to choose the GPU to be used for the model. If "AUTODEVICE' (-1), GeNN will choose the device ...
Definition: modelSpec.cc:576
vector< unsigned int > padSumNeuronN
Padded summed neuron numbers.
Definition: modelSpec.h:169
string simCode
Code that defines the execution of one timestep of integration of the neuron model.
Definition: modelSpec.h:109
void addNeuronPopulation(const char *, unsigned int, unsigned int, float *, float *)
Method for adding a neuron population to a neuronal network model, using C style character array for ...
Definition: modelSpec.cc:244
vector< unsigned int > neuronType
Postsynaptic methods to the neuron.
Definition: modelSpec.h:171
Global header file containing a few global variables. Part of the code generation section...
vector< float > g0
Global synapse conductance if GLOBALG is chosen.
Definition: modelSpec.h:210
vector< string > tmpVarTypes
never used
Definition: modelSpec.h:117
vector< string > extraGlobalNeuronKernelParameterTypes
Additional parameters in the neuron kernel; they are translated to a population specific name but oth...
Definition: modelSpec.h:125
vector< unsigned int > sumSynapseTrgN
Summed naumber of target neurons.
Definition: modelSpec.h:194
vector< int > neuronDeviceID
The ID of the CUDA device which the neuron groups are comnputed on.
Definition: modelSpec.h:180
void setSynapseClusterIndex(const string synapseGroup, int hostID, int deviceID)
Function for setting which host and which device a synapse group will be simulated on...
Definition: modelSpec.cc:229
vector< string > dpNames
Names of dependent parameters of the model. These are assumed to be always of type "float"...
Definition: modelSpec.h:137
vector< string > tmpVarNames
never used
Definition: modelSpec.h:115
vector< int > synapseDeviceID
The ID of the CUDA device which the synapse groups are comnputed on.
Definition: modelSpec.h:217
vector< unsigned int > synapseTarget
Postsynaptic neuron groups.
Definition: modelSpec.h:202
dpclass()
Definition: modelSpec.h:101
void setNeuronClusterIndex(const string neuronGroup, int hostID, int deviceID)
Function for setting which host and which device a neuron group will be simulated on...
Definition: modelSpec.cc:197
vector< unsigned int > synapseInSynNo
IDs of the target neurons' incoming synapse variables for each synapse group.
Definition: modelSpec.h:203
unsigned int needSt
Whether last spike times are needed at all in this network model (related to STDP) ...
Definition: modelSpec.h:158
vector< string > neuronName
Names of neuron groups.
Definition: modelSpec.h:165
vector< unsigned int > neuronDelaySlots
The number of slots needed in the synapse delay queues of a neuron group.
Definition: modelSpec.h:178
string thresholdConditionCode
Code evaluating to a bool (e.g. "V > 20") that defines the condition for a true spike in the describe...
Definition: modelSpec.h:112
vector< unsigned int > sumNeuronN
Summed neuron numbers.
Definition: modelSpec.h:168
vector< float > nSpkEvntThreshold
Definition: modelSpec.h:185
Definition: modelSpec.h:99
unsigned int lrnGroups
Number of synapse groups with learning.
Definition: modelSpec.h:212
vector< string > varTypes
Types of the variable named above, e.g. "float". Names and types are matched by their order of occurr...
Definition: modelSpec.h:116
string postSyntoCurrent
Definition: modelSpec.h:132
Definition: modelSpec.h:130
string postSynDecay
Definition: modelSpec.h:133
string ftype
Numerical precision of the floating point variables.
Definition: modelSpec.h:156
vector< vector< float > > dnp
Derived neuron parameters.
Definition: modelSpec.h:173
vector< vector< float > > neuronIni
Initial values of neurons.
Definition: modelSpec.h:174
vector< vector< float > > neuronPara
Parameters of neurons.
Definition: modelSpec.h:172
virtual float calculateDerivedParameter(int index, vector< float > pars, float dt=1.0)
Definition: modelSpec.h:102
~NNmodel()
Definition: modelSpec.cc:36
void setPrecision(unsigned int)
This function sets the numerical precision of floating type variables. By default, it is float.
Definition: modelSpec.cc:502
vector< string > synapseName
Names of synapse groups.
Definition: modelSpec.h:191
vector< int > synapseHostID
The ID of the cluster node which the synapse groups are computed on.
Definition: modelSpec.h:216
string name
Name of the neuronal newtwork model.
Definition: modelSpec.h:155
dpclass * dps
Definition: modelSpec.h:138
vector< unsigned int > neuronPostSyn
Definition: modelSpec.h:170
void setConstInp(const string, float)
Method for setting the global input value for a neuron population if CONSTINP.
Definition: modelSpec.cc:467
vector< vector< float > > synapsePara
parameters of synapses
Definition: modelSpec.h:204
vector< unsigned int > neuronNeedSt
Whether last spike time needs to be saved for each indivual neuron type.
Definition: modelSpec.h:177
vector< vector< float > > dpsp
Derived postsynapse parameters.
Definition: modelSpec.h:209
vector< string > varTypes
Types of the variable named above, e.g. "float". Names and types are matched by their order of occurr...
Definition: modelSpec.h:135
vector< unsigned int > synapseGType
Type of specification method for synaptic conductance.
Definition: modelSpec.h:200
vector< vector< float > > postSynIni
Initial values of postsynaptic variables.
Definition: modelSpec.h:208
class (struct) for specifying a neuron model.
Definition: modelSpec.h:107
vector< unsigned int > postSynapseType
Types of synapses.
Definition: modelSpec.h:206
vector< unsigned int > synapseType
Types of synapses.
Definition: modelSpec.h:198
vector< unsigned int > padSumSynapseKrnl
Definition: modelSpec.h:197
NNmodel()
Definition: modelSpec.cc:24
vector< unsigned int > synapseDelay
Global synaptic conductance delay for the group (in time steps)
Definition: modelSpec.h:215
unsigned int SYNPNO[SYNTYPENO]
Global constant integer array containing the number of parameters of each of the predefined synapse t...
Definition: modelSpec.h:53
string resetCode
Code that defines the reset action taken after a spike occurred. This can be empty.
Definition: modelSpec.h:113
int valid
Flag for whether the model has been validated (unused?)
Definition: modelSpec.h:157
void resetPaddedSums()
Re-calculates the block-size-padded sum of threads needed to compute the groups of neurons and synaps...
Definition: modelSpec.cc:484
vector< string > varNames
Names of the variables in the neuron model.
Definition: modelSpec.h:114
void activateDirectInput(const string, unsigned int)
This function defines the type of the explicit input to the neuron model. Current options are common ...
Definition: modelSpec.cc:327
vector< float > globalInp
Global explicit input if CONSTINP is chosen.
Definition: modelSpec.h:211
unsigned int neuronGrpN
Number of neuron groups.
Definition: modelSpec.h:166
vector< string > dpNames
Names of dependent parameters of the model. These are assumed to be always of type "float"...
Definition: modelSpec.h:119
dpclass * dps
Definition: modelSpec.h:126