GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
customUpdateGroupMerged.h
Go to the documentation of this file.
1 #pragma once
2 
3 // GeNN code generator includes
6 
7 //----------------------------------------------------------------------------
8 // CodeGenerator::CustomUpdateGroupMerged
9 //----------------------------------------------------------------------------
10 namespace CodeGenerator
11 {
12 class GENN_EXPORT CustomUpdateGroupMerged : public GroupMerged<CustomUpdateInternal>
13 {
14 public:
15  CustomUpdateGroupMerged(size_t index, const std::string &precision, const std::string &, const BackendBase &backend,
16  const std::vector<std::reference_wrapper<const CustomUpdateInternal>> &groups);
17 
18  //----------------------------------------------------------------------------
19  // Public API
20  //----------------------------------------------------------------------------
21  bool isParamHeterogeneous(size_t index) const;
22  bool isDerivedParamHeterogeneous(size_t index) const;
23 
24  boost::uuids::detail::sha1::digest_type getHashDigest() const;
25 
26  void generateRunner(const BackendBase &backend, CodeStream &definitionsInternal,
27  CodeStream &definitionsInternalFunc, CodeStream &definitionsInternalVar,
28  CodeStream &runnerVarDecl, CodeStream &runnerMergedStructAlloc) const
29  {
30  generateRunnerBase(backend, definitionsInternal, definitionsInternalFunc, definitionsInternalVar,
31  runnerVarDecl, runnerMergedStructAlloc, name);
32  }
33 
34  void generateCustomUpdate(const BackendBase &backend, CodeStream &os, const ModelSpecMerged &modelMerged, Substitutions &popSubs) const;
35 
36  std::string getVarIndex(VarAccessDuplication varDuplication, const std::string &index) const;
37  std::string getVarRefIndex(bool delay, VarAccessDuplication varDuplication, const std::string &index) const;
38 
39  //----------------------------------------------------------------------------
40  // Static constants
41  //----------------------------------------------------------------------------
42  static const std::string name;
43 };
44 
45 // ----------------------------------------------------------------------------
46 // CodeGenerator::CustomUpdateWUGroupMergedBase
47 //----------------------------------------------------------------------------
48 class GENN_EXPORT CustomUpdateWUGroupMergedBase : public GroupMerged<CustomUpdateWUInternal>
49 {
50 public:
51  //----------------------------------------------------------------------------
52  // Public API
53  //----------------------------------------------------------------------------
54  bool isParamHeterogeneous(size_t index) const;
55  bool isDerivedParamHeterogeneous(size_t index) const;
56 
57  boost::uuids::detail::sha1::digest_type getHashDigest() const;
58 
59  std::string getVarIndex(VarAccessDuplication varDuplication, const std::string &index) const;
60  std::string getVarRefIndex(VarAccessDuplication varDuplication, const std::string &index) const;
61 
63  bool isKernelSizeHeterogeneous(size_t dimensionIndex) const
64  {
65  return CodeGenerator::isKernelSizeHeterogeneous(this, dimensionIndex, getGroupKernelSize);
66  }
67 
69  std::string getKernelSize(size_t dimensionIndex) const
70  {
71  return CodeGenerator::getKernelSize(this, dimensionIndex, getGroupKernelSize);
72  }
73 
75  void genKernelIndex(std::ostream& os, const CodeGenerator::Substitutions& subs) const
76  {
77  return CodeGenerator::genKernelIndex(this, os, subs, getGroupKernelSize);
78  }
79 
80 protected:
81  CustomUpdateWUGroupMergedBase(size_t index, const std::string &precision, const std::string &, const BackendBase &backend,
82  const std::vector<std::reference_wrapper<const CustomUpdateWUInternal>> &groups);
83 
84 private:
85  static const std::vector<unsigned int>& getGroupKernelSize(const CustomUpdateWUInternal& g)
86  {
87  return g.getSynapseGroup()->getKernelSize();
88  }
89 };
90 
91 // ----------------------------------------------------------------------------
92 // CodeGenerator::CustomUpdateWUGroupMerged
93 //----------------------------------------------------------------------------
95 {
96 public:
97  CustomUpdateWUGroupMerged(size_t index, const std::string &precision, const std::string &timePrecision, const BackendBase &backend,
98  const std::vector<std::reference_wrapper<const CustomUpdateWUInternal>> &groups)
99  : CustomUpdateWUGroupMergedBase(index, precision, timePrecision, backend, groups)
100  {
101  }
102 
103  //----------------------------------------------------------------------------
104  // Public API
105  //----------------------------------------------------------------------------
106  void generateRunner(const BackendBase &backend, CodeStream &definitionsInternal,
107  CodeStream &definitionsInternalFunc, CodeStream &definitionsInternalVar,
108  CodeStream &runnerVarDecl, CodeStream &runnerMergedStructAlloc) const
109  {
110  generateRunnerBase(backend, definitionsInternal, definitionsInternalFunc, definitionsInternalVar,
111  runnerVarDecl, runnerMergedStructAlloc, name);
112  }
113 
114  void generateCustomUpdate(const BackendBase &backend, CodeStream &os, const ModelSpecMerged &modelMerged, Substitutions &popSubs) const;
115 
116  //----------------------------------------------------------------------------
117  // Static constants
118  //----------------------------------------------------------------------------
119  static const std::string name;
120 };
121 
122 // ----------------------------------------------------------------------------
123 // CodeGenerator::CustomUpdateTransposeWUGroupMerged
124 //----------------------------------------------------------------------------
126 {
127 public:
128  CustomUpdateTransposeWUGroupMerged(size_t index, const std::string &precision, const std::string &timePrecision, const BackendBase &backend,
129  const std::vector<std::reference_wrapper<const CustomUpdateWUInternal>> &groups)
130  : CustomUpdateWUGroupMergedBase(index, precision, timePrecision, backend, groups)
131  {
132  }
133 
134  //----------------------------------------------------------------------------
135  // Public API
136  //----------------------------------------------------------------------------
137  void generateRunner(const BackendBase &backend, CodeStream &definitionsInternal,
138  CodeStream &definitionsInternalFunc, CodeStream &definitionsInternalVar,
139  CodeStream &runnerVarDecl, CodeStream &runnerMergedStructAlloc) const
140  {
141  generateRunnerBase(backend, definitionsInternal, definitionsInternalFunc, definitionsInternalVar,
142  runnerVarDecl, runnerMergedStructAlloc, name);
143  }
144 
145  void generateCustomUpdate(const BackendBase &backend, CodeStream &os, const ModelSpecMerged &modelMerged, Substitutions &popSubs) const;
146 
147  //----------------------------------------------------------------------------
148  // Static constants
149  //----------------------------------------------------------------------------
150  static const std::string name;
151 };
152 } // namespace CodeGenerator
Definition: customUpdateGroupMerged.h:12
void genKernelIndex(const G *group, std::ostream &os, const CodeGenerator::Substitutions &subs, K getKernelSizeFn)
Definition: codeGenUtils.h:180
#define GENN_EXPORT
Definition: gennExport.h:13
void generateRunner(const BackendBase &backend, CodeStream &definitionsInternal, CodeStream &definitionsInternalFunc, CodeStream &definitionsInternalVar, CodeStream &runnerVarDecl, CodeStream &runnerMergedStructAlloc) const
Definition: customUpdateGroupMerged.h:26
bool isKernelSizeHeterogeneous(size_t dimensionIndex) const
Is kernel size heterogeneous in this dimension?
Definition: customUpdateGroupMerged.h:63
Definition: modelSpecMerged.h:31
Helper class for generating code - automatically inserts brackets, indents etc.
Definition: backendBase.h:30
void generateRunner(const BackendBase &backend, CodeStream &definitionsInternal, CodeStream &definitionsInternalFunc, CodeStream &definitionsInternalVar, CodeStream &runnerVarDecl, CodeStream &runnerMergedStructAlloc) const
Definition: customUpdateGroupMerged.h:137
void generateRunner(const BackendBase &backend, CodeStream &definitionsInternal, CodeStream &definitionsInternalFunc, CodeStream &definitionsInternalVar, CodeStream &runnerVarDecl, CodeStream &runnerMergedStructAlloc) const
Definition: customUpdateGroupMerged.h:106
Definition: groupMerged.h:33
Definition: codeStream.h:21
const SynapseGroupInternal * getSynapseGroup() const
Definition: customUpdate.h:278
Definition: substitutions.h:21
Definition: customUpdateGroupMerged.h:48
CustomUpdateTransposeWUGroupMerged(size_t index, const std::string &precision, const std::string &timePrecision, const BackendBase &backend, const std::vector< std::reference_wrapper< const CustomUpdateWUInternal >> &groups)
Definition: customUpdateGroupMerged.h:128
const std::vector< unsigned int > & getKernelSize() const
Definition: synapseGroup.h:130
static const std::string name
Definition: customUpdateGroupMerged.h:42
Definition: backendBase.h:176
GENN_EXPORT void generateCustomUpdate(const filesystem::path &outputPath, const ModelSpecMerged &modelMerged, const BackendBase &backend, const std::string &suffix="")
Definition: generateModules.cc:206
bool isKernelSizeHeterogeneous(const G *group, size_t dimensionIndex, K getKernelSizeFn)
Definition: codeGenUtils.h:152
Definition: customUpdateInternal.h:41
static const std::string name
Definition: customUpdateGroupMerged.h:150
CustomUpdateWUGroupMerged(size_t index, const std::string &precision, const std::string &timePrecision, const BackendBase &backend, const std::vector< std::reference_wrapper< const CustomUpdateWUInternal >> &groups)
Definition: customUpdateGroupMerged.h:97
std::string getKernelSize(const G *group, size_t dimensionIndex, K getKernelSizeFn)
Definition: codeGenUtils.h:167
Definition: customUpdateGroupMerged.h:125
std::string getKernelSize(size_t dimensionIndex) const
Get expression for kernel size in dimension (may be literal or group->kernelSizeXXX) ...
Definition: customUpdateGroupMerged.h:69
VarAccessDuplication
Flags defining how variables should be duplicated across multiple batches.
Definition: varAccess.h:28
static const std::string name
Definition: customUpdateGroupMerged.h:119
Definition: customUpdateGroupMerged.h:94
void genKernelIndex(std::ostream &os, const CodeGenerator::Substitutions &subs) const
Generate an index into a kernel based on the id_kernel_XXX variables in subs.
Definition: customUpdateGroupMerged.h:75