GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
modelSpecMerged.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Standard C++ includes
4 #include <unordered_map>
5 #include <vector>
6 
7 // GeNN includes
8 #include "gennExport.h"
9 #include "gennUtils.h"
10 #include "modelSpecInternal.h"
11 
12 // GeNN code generator includes
19 
20 // Forward declarations
21 namespace CodeGenerator
22 {
23 class BackendBase;
24 }
25 
26 //--------------------------------------------------------------------------
27 // CodeGenerator::ModelSpecMerged
28 //--------------------------------------------------------------------------
29 namespace CodeGenerator
30 {
32 {
33 public:
34  ModelSpecMerged(const ModelSpecInternal &model, const BackendBase &backend);
35 
36  //--------------------------------------------------------------------------
37  // CodeGenerator::ModelSpecMerged::EGPField
38  //--------------------------------------------------------------------------
40  struct EGPField
41  {
42  EGPField(size_t m, const std::string &t, const std::string &f)
43  : mergedGroupIndex(m), type(t), fieldName(f) {}
44 
45  const size_t mergedGroupIndex;
46  const std::string type;
47  const std::string fieldName;
48 
51  bool operator < (const EGPField &other) const
52  {
53  if(other.mergedGroupIndex < mergedGroupIndex) {
54  return false;
55  }
56  else if(mergedGroupIndex < other.mergedGroupIndex) {
57  return true;
58  }
59 
60  if(other.type < type) {
61  return false;
62  }
63  else if(type < other.type) {
64  return true;
65  }
66 
67  if(other.fieldName < fieldName) {
68  return false;
69  }
70  else if(fieldName < other.fieldName) {
71  return true;
72  }
73 
74  return false;
75  }
76  };
77 
78  //--------------------------------------------------------------------------
79  // CodeGenerator::ModelSpecMerged::MergedEGP
80  //--------------------------------------------------------------------------
82  struct MergedEGP : public EGPField
83  {
84  MergedEGP(size_t m, size_t g, const std::string &t, const std::string &f)
85  : EGPField(m, t, f), groupIndex(g) {}
86 
87  const size_t groupIndex;
88  };
89 
90  //--------------------------------------------------------------------------
91  // Typedefines
92  //--------------------------------------------------------------------------
94  typedef std::unordered_multimap<std::string, MergedEGP> MergedEGPDestinations;
95  typedef std::map<std::string, MergedEGPDestinations> MergedEGPMap;
96 
97  //--------------------------------------------------------------------------
98  // Public API
99  //--------------------------------------------------------------------------
101  const ModelSpecInternal &getModel() const{ return m_Model; }
102 
104  const std::vector<NeuronUpdateGroupMerged> &getMergedNeuronUpdateGroups() const{ return m_MergedNeuronUpdateGroups; }
105 
107  const std::vector<PresynapticUpdateGroupMerged> &getMergedPresynapticUpdateGroups() const{ return m_MergedPresynapticUpdateGroups; }
108 
110  const std::vector<PostsynapticUpdateGroupMerged> &getMergedPostsynapticUpdateGroups() const{ return m_MergedPostsynapticUpdateGroups; }
111 
113  const std::vector<SynapseDynamicsGroupMerged> &getMergedSynapseDynamicsGroups() const{ return m_MergedSynapseDynamicsGroups; }
114 
116  const std::vector<NeuronInitGroupMerged> &getMergedNeuronInitGroups() const{ return m_MergedNeuronInitGroups; }
117 
119  const std::vector<CustomUpdateInitGroupMerged> &getMergedCustomUpdateInitGroups() const { return m_MergedCustomUpdateInitGroups; }
120 
122  const std::vector<CustomWUUpdateInitGroupMerged> &getMergedCustomWUUpdateInitGroups() const { return m_MergedCustomWUUpdateInitGroups; }
123 
125  const std::vector<SynapseInitGroupMerged> &getMergedSynapseInitGroups() const{ return m_MergedSynapseInitGroups; }
126 
128  const std::vector<SynapseConnectivityInitGroupMerged> &getMergedSynapseConnectivityInitGroups() const{ return m_MergedSynapseConnectivityInitGroups; }
129 
131  const std::vector<SynapseSparseInitGroupMerged> &getMergedSynapseSparseInitGroups() const{ return m_MergedSynapseSparseInitGroups; }
132 
134  const std::vector<CustomWUUpdateSparseInitGroupMerged> &getMergedCustomWUUpdateSparseInitGroups() const { return m_MergedCustomWUUpdateSparseInitGroups; }
135 
137  const std::vector<NeuronSpikeQueueUpdateGroupMerged> &getMergedNeuronSpikeQueueUpdateGroups() const { return m_MergedNeuronSpikeQueueUpdateGroups; }
138 
140  const std::vector<NeuronPrevSpikeTimeUpdateGroupMerged> &getMergedNeuronPrevSpikeTimeUpdateGroups() const{ return m_MergedNeuronPrevSpikeTimeUpdateGroups; }
141 
143  const std::vector<SynapseDendriticDelayUpdateGroupMerged> &getMergedSynapseDendriticDelayUpdateGroups() const { return m_MergedSynapseDendriticDelayUpdateGroups; }
144 
146  const std::vector<SynapseConnectivityHostInitGroupMerged> &getMergedSynapseConnectivityHostInitGroups() const{ return m_MergedSynapseConnectivityHostInitGroups; }
147 
149  const std::vector<CustomUpdateGroupMerged> &getMergedCustomUpdateGroups() const { return m_MergedCustomUpdateGroups; }
150 
152  const std::vector<CustomUpdateWUGroupMerged> &getMergedCustomUpdateWUGroups() const { return m_MergedCustomUpdateWUGroups; }
153 
155  const std::vector<CustomUpdateTransposeWUGroupMerged> &getMergedCustomUpdateTransposeWUGroups() const { return m_MergedCustomUpdateTransposeWUGroups; }
156 
158  const std::vector<CustomUpdateHostReductionGroupMerged> &getMergedCustomUpdateHostReductionGroups() const { return m_MergedCustomUpdateHostReductionGroups; }
159 
161  const std::vector<CustomWUUpdateHostReductionGroupMerged> &getMergedCustomWUUpdateHostReductionGroups() const { return m_MergedCustomWUUpdateHostReductionGroups; }
162 
163  void genMergedNeuronUpdateGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedNeuronUpdateGroups); }
164  void genMergedPresynapticUpdateGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedPresynapticUpdateGroups); }
165  void genMergedPostsynapticUpdateGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedPostsynapticUpdateGroups); }
166  void genMergedSynapseDynamicsGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedSynapseDynamicsGroups); }
167  void genMergedNeuronInitGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedNeuronInitGroups); }
168  void genMergedCustomUpdateInitGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedCustomUpdateInitGroups); }
169  void genMergedCustomWUUpdateInitGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedCustomWUUpdateInitGroups); }
170  void genMergedSynapseInitGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedSynapseInitGroups); }
171  void genMergedSynapseConnectivityInitGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedSynapseConnectivityInitGroups); }
172  void genMergedSynapseSparseInitGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedSynapseSparseInitGroups); }
173  void genMergedCustomWUUpdateSparseInitGroupStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedCustomWUUpdateSparseInitGroups); }
174  void genMergedNeuronSpikeQueueUpdateStructs(CodeStream &os, const BackendBase &backend) const{ genMergedStructures(os, backend, m_MergedNeuronSpikeQueueUpdateGroups); }
175  void genMergedNeuronPrevSpikeTimeUpdateStructs(CodeStream &os, const BackendBase &backend) const{ genMergedStructures(os, backend, m_MergedNeuronPrevSpikeTimeUpdateGroups); }
176  void genMergedSynapseDendriticDelayUpdateStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedSynapseDendriticDelayUpdateGroups); }
177  void genMergedSynapseConnectivityHostInitStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedSynapseConnectivityHostInitGroups); }
178  void genMergedCustomUpdateStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedCustomUpdateGroups); }
179  void genMergedCustomUpdateWUStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedCustomUpdateWUGroups); }
180  void genMergedCustomUpdateTransposeWUStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedCustomUpdateTransposeWUGroups); }
181  void genMergedCustomUpdateHostReductionStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedCustomUpdateHostReductionGroups); }
182  void genMergedCustomWUUpdateHostReductionStructs(CodeStream &os, const BackendBase &backend) const { genMergedStructures(os, backend, m_MergedCustomWUUpdateHostReductionGroups); }
183 
184  void genNeuronUpdateGroupSupportCode(CodeStream &os, bool supportsNamespace = true) const{ m_NeuronUpdateSupportCode.gen(os, getModel().getPrecision(), supportsNamespace); }
185  void genPostsynapticDynamicsSupportCode(CodeStream &os, bool supportsNamespace = true) const{ m_PostsynapticDynamicsSupportCode.gen(os, getModel().getPrecision(), supportsNamespace); }
186  void genPresynapticUpdateSupportCode(CodeStream &os, bool supportsNamespace = true) const{ m_PresynapticUpdateSupportCode.gen(os, getModel().getPrecision(), supportsNamespace); }
187  void genPostsynapticUpdateSupportCode(CodeStream &os, bool supportsNamespace = true) const{ m_PostsynapticUpdateSupportCode.gen(os, getModel().getPrecision(), supportsNamespace); }
188  void genSynapseDynamicsSupportCode(CodeStream &os, bool supportsNamespace = true) const{ m_SynapseDynamicsSupportCode.gen(os, getModel().getPrecision(), supportsNamespace); }
189 
190  const std::string &getNeuronUpdateSupportCodeNamespace(const std::string &code) const{ return m_NeuronUpdateSupportCode.getSupportCodeNamespace(code); }
191  const std::string &getPostsynapticDynamicsSupportCodeNamespace(const std::string &code) const{ return m_PostsynapticDynamicsSupportCode.getSupportCodeNamespace(code); }
192  const std::string &getPresynapticUpdateSupportCodeNamespace(const std::string &code) const{ return m_PresynapticUpdateSupportCode.getSupportCodeNamespace(code); }
193  const std::string &getPostsynapticUpdateSupportCodeNamespace(const std::string &code) const{ return m_PostsynapticUpdateSupportCode.getSupportCodeNamespace(code); }
194  const std::string &getSynapseDynamicsSupportCodeNamespace(const std::string &code) const{ return m_SynapseDynamicsSupportCode.getSupportCodeNamespace(code); }
195 
197  boost::uuids::detail::sha1::digest_type getHashDigest(const BackendBase &backend) const;
198 
200  boost::uuids::detail::sha1::digest_type getNeuronUpdateArchetypeHashDigest() const;
201 
203  boost::uuids::detail::sha1::digest_type getSynapseUpdateArchetypeHashDigest() const;
204 
206  boost::uuids::detail::sha1::digest_type getCustomUpdateArchetypeHashDigest() const;
207 
209  boost::uuids::detail::sha1::digest_type getInitArchetypeHashDigest() const;
210 
212  bool anyPointerEGPs() const;
213 
215  const MergedEGPDestinations &getMergedEGPDestinations(const std::string &name, const BackendBase &backend) const
216  {
217  return m_MergedEGPs.at(backend.getDeviceVarPrefix() + name);
218  }
219 
221  template<typename T>
222  void genScalarEGPPush(CodeStream &os, const BackendBase &backend) const
223  {
224  // Loop through all merged EGPs
225  for(const auto &e : m_MergedEGPs) {
226  // Loop through all destination structures with this suffix
227  const auto groupEGPs = e.second.equal_range(T::name);
228  for(auto g = groupEGPs.first; g != groupEGPs.second; ++g) {
229  // If EGP is scalar, generate code to copy
230  if(!Utils::isTypePointer(g->second.type)) {
231  backend.genMergedExtraGlobalParamPush(os, T::name, g->second.mergedGroupIndex,
232  std::to_string(g->second.groupIndex),
233  g->second.fieldName, e.first);
234  }
235 
236  }
237  }
238  }
239 
240  // Get set of unique fields referenced in a merged group
241  template<typename T>
242  std::set<EGPField> getMergedGroupFields() const
243  {
244  // Loop through all EGPs
245  std::set<EGPField> mergedGroupFields;
246  for(const auto &e : m_MergedEGPs) {
247  // Get all destinations in this type of group
248  const auto groupEGPs = e.second.equal_range(T::name);
249 
250  // Copy them all into set
251  std::transform(groupEGPs.first, groupEGPs.second, std::inserter(mergedGroupFields, mergedGroupFields.end()),
252  [](const MergedEGPMap::value_type::second_type::value_type &g)
253  {
254  return EGPField{g.second.mergedGroupIndex, g.second.type, g.second.fieldName};
255  });
256  }
257 
258  // Return set
259  return mergedGroupFields;
260  }
261 
262  template<typename T>
263  void genMergedGroupPush(CodeStream &os, const std::vector<T> &groups, const BackendBase &backend) const
264  {
265 
266  if(!groups.empty()) {
267  // Get set of unique fields referenced in a merged group
268  const auto mergedGroupFields = getMergedGroupFields<T>();
269 
270  os << "// ------------------------------------------------------------------------" << std::endl;
271  os << "// merged extra global parameter functions" << std::endl;
272  os << "// ------------------------------------------------------------------------" << std::endl;
273  // Loop through resultant fields and generate push function for pointer extra global parameters
274  for(auto f : mergedGroupFields) {
275  // If EGP is a pointer
276  // **NOTE** this is common to all references!
277  if(Utils::isTypePointer(f.type)) {
278  os << "void pushMerged" << T::name << f.mergedGroupIndex << f.fieldName << "ToDevice(unsigned int idx, " << backend.getMergedGroupFieldHostType(f.type) << " value)";
279  {
280  CodeStream::Scope b(os);
281  backend.genMergedExtraGlobalParamPush(os, T::name, f.mergedGroupIndex, "idx", f.fieldName, "value");
282  }
283  os << std::endl;
284  }
285  }
286  }
287  }
288 
289 private:
290  //--------------------------------------------------------------------------
291  // Private methods
292  //--------------------------------------------------------------------------
293  template<typename T>
294  void genMergedStructures(CodeStream &os, const BackendBase &backend, const std::vector<T> &mergedGroups) const
295  {
296  // Loop through all merged groups and generate struct
297  for(const auto &g : mergedGroups) {
298  g.generateStruct(os, backend, T::name);
299  }
300  }
301 
302  template<typename Group, typename MergedGroup, typename D>
303  void createMergedGroupsHash(const ModelSpecInternal &model, const BackendBase &backend,
304  const std::vector<std::reference_wrapper<const Group>> &unmergedGroups,
305  std::vector<MergedGroup> &mergedGroups, D getHashDigest)
306  {
307  // Create a hash map to group together groups with the same SHA1 digest
308  std::unordered_map<boost::uuids::detail::sha1::digest_type,
309  std::vector<std::reference_wrapper<const Group>>,
310  Utils::SHA1Hash> protoMergedGroups;
311 
312  // Add unmerged groups to correct vector
313  for(const auto &g : unmergedGroups) {
314  protoMergedGroups[(g.get().*getHashDigest)()].push_back(g);
315  }
316 
317  // Reserve final merged groups vector
318  mergedGroups.reserve(protoMergedGroups.size());
319 
320  // Loop through resultant merged groups
321  size_t i = 0;
322  for(const auto &p : protoMergedGroups) {
323  // Add group to vector
324  mergedGroups.emplace_back(i, model.getPrecision(), model.getTimePrecision(), backend, p.second);
325 
326  // Loop through fields
327  for(const auto &f : mergedGroups.back().getFields()) {
328  // If field is an EGP, add record to merged EGPS
329  if(std::get<3>(f) == MergedGroup::FieldType::PointerEGP || std::get<3>(f) == MergedGroup::FieldType::ScalarEGP)
330  {
331  // Loop through groups within newly-created merged group
332  for(size_t groupIndex = 0; groupIndex < mergedGroups.back().getGroups().size(); groupIndex++) {
333  const auto &g = mergedGroups.back().getGroups()[groupIndex];
334 
335  // Add reference to this group's variable to data structure
336  // **NOTE** this works fine with EGP references because the function to
337  // get their value will just return the name of the referenced EGP
338  m_MergedEGPs[std::get<2>(f)(g, groupIndex)].emplace(
339  std::piecewise_construct,
340  std::forward_as_tuple(MergedGroup::name),
341  std::forward_as_tuple(i, groupIndex, std::get<0>(f), std::get<1>(f)));
342  }
343  }
344  }
345 
346  i++;
347  }
348  }
349 
350  template<typename Group, typename MergedGroup, typename F, typename U>
351  void createMergedGroupsHash(const ModelSpecInternal &model, const BackendBase &backend,
352  const std::map<std::string, Group> &groups, std::vector<MergedGroup> &mergedGroups,
353  F filter, U updateHash)
354  {
355  // Build temporary vector of references to groups that pass filter
356  std::vector<std::reference_wrapper<const Group>> unmergedGroups;
357  for(const auto &g : groups) {
358  if(filter(g.second)) {
359  unmergedGroups.emplace_back(std::cref(g.second));
360  }
361  }
362 
363  // Merge filtered vector
364  createMergedGroupsHash(model, backend, unmergedGroups, mergedGroups, updateHash);
365  }
366 
367  //--------------------------------------------------------------------------
368  // Members
369  //--------------------------------------------------------------------------
371  const ModelSpecInternal &m_Model;
372 
374  std::vector<NeuronUpdateGroupMerged> m_MergedNeuronUpdateGroups;
375 
377  std::vector<PresynapticUpdateGroupMerged> m_MergedPresynapticUpdateGroups;
378 
380  std::vector<PostsynapticUpdateGroupMerged> m_MergedPostsynapticUpdateGroups;
381 
383  std::vector<SynapseDynamicsGroupMerged> m_MergedSynapseDynamicsGroups;
384 
386  std::vector<NeuronInitGroupMerged> m_MergedNeuronInitGroups;
387 
389  std::vector<CustomUpdateInitGroupMerged> m_MergedCustomUpdateInitGroups;
390 
392  std::vector<CustomWUUpdateInitGroupMerged> m_MergedCustomWUUpdateInitGroups;
393 
395  std::vector<SynapseInitGroupMerged> m_MergedSynapseInitGroups;
396 
398  std::vector<SynapseConnectivityInitGroupMerged> m_MergedSynapseConnectivityInitGroups;
399 
401  std::vector<SynapseSparseInitGroupMerged> m_MergedSynapseSparseInitGroups;
402 
404  std::vector<CustomWUUpdateSparseInitGroupMerged> m_MergedCustomWUUpdateSparseInitGroups;
405 
407  std::vector<NeuronSpikeQueueUpdateGroupMerged> m_MergedNeuronSpikeQueueUpdateGroups;
408 
410  std::vector<NeuronPrevSpikeTimeUpdateGroupMerged> m_MergedNeuronPrevSpikeTimeUpdateGroups;
411 
413  std::vector<SynapseDendriticDelayUpdateGroupMerged> m_MergedSynapseDendriticDelayUpdateGroups;
414 
416  std::vector<SynapseConnectivityHostInitGroupMerged> m_MergedSynapseConnectivityHostInitGroups;
417 
419  std::vector<CustomUpdateGroupMerged> m_MergedCustomUpdateGroups;
420 
422  std::vector<CustomUpdateWUGroupMerged> m_MergedCustomUpdateWUGroups;
423 
425  std::vector<CustomUpdateTransposeWUGroupMerged> m_MergedCustomUpdateTransposeWUGroups;
426 
428  std::vector<CustomUpdateHostReductionGroupMerged> m_MergedCustomUpdateHostReductionGroups;
429 
431  std::vector<CustomWUUpdateHostReductionGroupMerged> m_MergedCustomWUUpdateHostReductionGroups;
432 
434  SupportCodeMerged m_NeuronUpdateSupportCode;
435 
437  SupportCodeMerged m_PostsynapticDynamicsSupportCode;
438 
440  SupportCodeMerged m_PresynapticUpdateSupportCode;
441 
443  SupportCodeMerged m_PostsynapticUpdateSupportCode;
444 
446  SupportCodeMerged m_SynapseDynamicsSupportCode;
447 
448  // Map containing mapping of original extra global param names to their locations within merged groups
449  MergedEGPMap m_MergedEGPs;
450 
451 };
452 } // namespace CodeGenerator
const std::string & getNeuronUpdateSupportCodeNamespace(const std::string &code) const
Definition: modelSpecMerged.h:190
const std::string & getPostsynapticDynamicsSupportCodeNamespace(const std::string &code) const
Definition: modelSpecMerged.h:191
void genPostsynapticDynamicsSupportCode(CodeStream &os, bool supportsNamespace=true) const
Definition: modelSpecMerged.h:185
void genMergedSynapseInitGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:170
const std::string fieldName
Definition: modelSpecMerged.h:47
void genSynapseDynamicsSupportCode(CodeStream &os, bool supportsNamespace=true) const
Definition: modelSpecMerged.h:188
const std::vector< SynapseConnectivityHostInitGroupMerged > & getMergedSynapseConnectivityHostInitGroups() const
Get merged synapse groups which require host code to initialise their synaptic connectivity.
Definition: modelSpecMerged.h:146
void genMergedCustomWUUpdateSparseInitGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:173
void genPresynapticUpdateSupportCode(CodeStream &os, bool supportsNamespace=true) const
Definition: modelSpecMerged.h:186
void genPostsynapticUpdateSupportCode(CodeStream &os, bool supportsNamespace=true) const
Definition: modelSpecMerged.h:187
const std::vector< SynapseInitGroupMerged > & getMergedSynapseInitGroups() const
Get merged synapse groups with dense connectivity which require initialisation.
Definition: modelSpecMerged.h:125
const std::vector< CustomUpdateHostReductionGroupMerged > & getMergedCustomUpdateHostReductionGroups() const
Get merged custom update groups where host reduction needs to be performed.
Definition: modelSpecMerged.h:158
void genMergedSynapseSparseInitGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:172
const std::vector< NeuronSpikeQueueUpdateGroupMerged > & getMergedNeuronSpikeQueueUpdateGroups() const
Get merged neuron groups which require their spike queues updating.
Definition: modelSpecMerged.h:137
const std::vector< NeuronUpdateGroupMerged > & getMergedNeuronUpdateGroups() const
Get merged neuron groups which require updating.
Definition: modelSpecMerged.h:104
void genMergedNeuronUpdateGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:163
const std::vector< NeuronInitGroupMerged > & getMergedNeuronInitGroups() const
Get merged neuron groups which require initialisation.
Definition: modelSpecMerged.h:116
void genMergedSynapseDynamicsGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:166
const std::vector< SynapseDynamicsGroupMerged > & getMergedSynapseDynamicsGroups() const
Get merged synapse groups which require synapse dynamics.
Definition: modelSpecMerged.h:113
#define GENN_EXPORT
Definition: gennExport.h:13
std::set< EGPField > getMergedGroupFields() const
Definition: modelSpecMerged.h:242
EGPField(size_t m, const std::string &t, const std::string &f)
Definition: modelSpecMerged.h:42
void genMergedNeuronInitGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:167
const std::vector< SynapseConnectivityInitGroupMerged > & getMergedSynapseConnectivityInitGroups() const
Get merged synapse groups which require connectivity initialisation.
Definition: modelSpecMerged.h:128
const std::vector< SynapseDendriticDelayUpdateGroupMerged > & getMergedSynapseDendriticDelayUpdateGroups() const
Get merged synapse groups which require their dendritic delay updating.
Definition: modelSpecMerged.h:143
void genMergedGroupPush(CodeStream &os, const std::vector< T > &groups, const BackendBase &backend) const
Definition: modelSpecMerged.h:263
const std::vector< NeuronPrevSpikeTimeUpdateGroupMerged > & getMergedNeuronPrevSpikeTimeUpdateGroups() const
Get merged neuron groups which require their previous spike times updating.
Definition: modelSpecMerged.h:140
void genMergedCustomWUUpdateInitGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:169
void genMergedSynapseConnectivityInitGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:171
const std::string type
Definition: modelSpecMerged.h:46
Definition: modelSpecMerged.h:31
Helper class for generating code - automatically inserts brackets, indents etc.
Definition: backendBase.h:30
void genMergedCustomUpdateInitGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:168
const size_t mergedGroupIndex
Definition: modelSpecMerged.h:45
Immutable structure for tracking where an extra global variable ends up after merging.
Definition: modelSpecMerged.h:82
void genMergedCustomUpdateHostReductionStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:181
void genMergedCustomWUUpdateHostReductionStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:182
const std::vector< CustomUpdateGroupMerged > & getMergedCustomUpdateGroups() const
Get merged custom updates of variables.
Definition: modelSpecMerged.h:149
void genMergedCustomUpdateTransposeWUStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:180
void genMergedCustomUpdateStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:178
Definition: codeStream.h:21
const MergedEGPDestinations & getMergedEGPDestinations(const std::string &name, const BackendBase &backend) const
Get the map of destinations within the merged data structures for a particular extra global parameter...
Definition: modelSpecMerged.h:215
const std::string & getSynapseDynamicsSupportCodeNamespace(const std::string &code) const
Definition: modelSpecMerged.h:194
std::unordered_multimap< std::string, MergedEGP > MergedEGPDestinations
Map of original extra global param names to their locations within merged structures.
Definition: modelSpecMerged.h:94
const size_t groupIndex
Definition: modelSpecMerged.h:87
std::map< std::string, MergedEGPDestinations > MergedEGPMap
Definition: modelSpecMerged.h:95
void updateHash(const T &value, boost::uuids::detail::sha1 &hash)
Hash arithmetic types and enums.
Definition: gennUtils.h:128
void genScalarEGPPush(CodeStream &os, const BackendBase &backend) const
Generate calls to update all target merged groups.
Definition: modelSpecMerged.h:222
const std::vector< CustomUpdateInitGroupMerged > & getMergedCustomUpdateInitGroups() const
Get merged custom update groups which require initialisation.
Definition: modelSpecMerged.h:119
Definition: backendBase.h:176
Functor for generating a hash suitable for use in std::unordered_map etc (i.e. size_t size) from a SH...
Definition: gennUtils.h:170
GENN_EXPORT bool isTypePointer(const std::string &type)
Function to determine whether a string containing a type is a pointer.
Definition: gennUtils.cc:75
const ModelSpecInternal & getModel() const
Get underlying, unmerged model.
Definition: modelSpecMerged.h:101
const std::string & getPostsynapticUpdateSupportCodeNamespace(const std::string &code) const
Definition: modelSpecMerged.h:193
void genMergedNeuronSpikeQueueUpdateStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:174
std::string getTimePrecision() const
Gets the floating point numerical precision used to represent time.
Definition: modelSpec.cc:50
const std::vector< PresynapticUpdateGroupMerged > & getMergedPresynapticUpdateGroups() const
Get merged synapse groups which require presynaptic updates.
Definition: modelSpecMerged.h:107
virtual void genMergedExtraGlobalParamPush(CodeStream &os, const std::string &suffix, size_t mergedGroupIdx, const std::string &groupIdx, const std::string &fieldName, const std::string &egpName) const =0
Generate code for pushing an updated EGP value into the merged group structure on &#39;device&#39;...
const std::vector< SynapseSparseInitGroupMerged > & getMergedSynapseSparseInitGroups() const
Get merged synapse groups with sparse connectivity which require initialisation.
Definition: modelSpecMerged.h:131
const std::vector< CustomUpdateWUGroupMerged > & getMergedCustomUpdateWUGroups() const
Get merged custom updates of weight update model variables.
Definition: modelSpecMerged.h:152
Immutable structure for tracking fields of merged group structure containing EGPs.
Definition: modelSpecMerged.h:40
const std::vector< CustomWUUpdateInitGroupMerged > & getMergedCustomWUUpdateInitGroups() const
Get merged custom updategroups with dense connectivity which require initialisation.
Definition: modelSpecMerged.h:122
Definition: modelSpecInternal.h:10
void genMergedCustomUpdateWUStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:179
void genMergedPresynapticUpdateGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:164
virtual std::string getMergedGroupFieldHostType(const std::string &type) const =0
When generating function calls to push to merged groups, backend without equivalent of Unified Virtua...
void genNeuronUpdateGroupSupportCode(CodeStream &os, bool supportsNamespace=true) const
Definition: modelSpecMerged.h:184
void genMergedPostsynapticUpdateGroupStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:165
const std::vector< CustomWUUpdateHostReductionGroupMerged > & getMergedCustomWUUpdateHostReductionGroups() const
Get merged custom weight update groups where host reduction needs to be performed.
Definition: modelSpecMerged.h:161
MergedEGP(size_t m, size_t g, const std::string &t, const std::string &f)
Definition: modelSpecMerged.h:84
const std::string & getPrecision() const
Gets the floating point numerical precision.
Definition: modelSpec.h:291
const std::vector< CustomUpdateTransposeWUGroupMerged > & getMergedCustomUpdateTransposeWUGroups() const
Get merged custom weight update groups where transpose needs to be calculated.
Definition: modelSpecMerged.h:155
virtual std::string getDeviceVarPrefix() const
Definition: backendBase.h:362
Definition: supportCodeMerged.h:15
const std::vector< CustomWUUpdateSparseInitGroupMerged > & getMergedCustomWUUpdateSparseInitGroups() const
Get merged custom update groups with sparse connectivity which require initialisation.
Definition: modelSpecMerged.h:134
const std::vector< PostsynapticUpdateGroupMerged > & getMergedPostsynapticUpdateGroups() const
Get merged synapse groups which require postsynaptic updates.
Definition: modelSpecMerged.h:110
m
Definition: genn_model.py:117
const std::string & getPresynapticUpdateSupportCodeNamespace(const std::string &code) const
Definition: modelSpecMerged.h:192
void genMergedSynapseDendriticDelayUpdateStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:176
Definition: codeStream.h:94
void genMergedNeuronPrevSpikeTimeUpdateStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:175
void genMergedSynapseConnectivityHostInitStructs(CodeStream &os, const BackendBase &backend) const
Definition: modelSpecMerged.h:177