GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
neuronUpdateGroupMerged.h
Go to the documentation of this file.
1 #pragma once
2 
3 // GeNN code generator includes
5 
6 //----------------------------------------------------------------------------
7 // CodeGenerator::NeuronUpdateGroupMerged
8 //----------------------------------------------------------------------------
9 namespace CodeGenerator
10 {
12 {
13 public:
14  NeuronUpdateGroupMerged(size_t index, const std::string &precision, const std::string &timePrecision, const BackendBase &backend,
15  const std::vector<std::reference_wrapper<const NeuronGroupInternal>> &groups);
16 
17  //------------------------------------------------------------------------
18  // Public API
19  //------------------------------------------------------------------------
21  bool isInSynWUMParamHeterogeneous(size_t childIndex, size_t paramIndex) const;
22 
24  bool isInSynWUMDerivedParamHeterogeneous(size_t childIndex, size_t paramIndex) const;
25 
27  bool isOutSynWUMParamHeterogeneous(size_t childIndex, size_t paramIndex) const;
28 
30  bool isOutSynWUMDerivedParamHeterogeneous(size_t childIndex, size_t paramIndex) const;
31 
33  const std::vector<SynapseGroupInternal*> &getSortedArchetypeInSynWithPostCode() const { return m_SortedInSynWithPostCode.front(); }
34 
36  const std::vector<SynapseGroupInternal*> &getSortedArchetypeOutSynWithPreCode() const { return m_SortedOutSynWithPreCode.front(); }
37 
39  boost::uuids::detail::sha1::digest_type getHashDigest() const;
40 
41  void generateRunner(const BackendBase &backend, CodeStream &definitionsInternal,
42  CodeStream &definitionsInternalFunc, CodeStream &definitionsInternalVar,
43  CodeStream &runnerVarDecl, CodeStream &runnerMergedStructAlloc) const
44  {
45  generateRunnerBase(backend, definitionsInternal, definitionsInternalFunc, definitionsInternalVar,
46  runnerVarDecl, runnerMergedStructAlloc, name);
47  }
48 
49  void generateNeuronUpdate(const BackendBase &backend, CodeStream &os, const ModelSpecMerged &modelMerged, Substitutions &popSubs,
51  BackendBase::GroupHandler<NeuronUpdateGroupMerged> genEmitSpikeLikeEvent) const;
52 
53  void generateWUVarUpdate(const BackendBase &backend, CodeStream &os, const ModelSpecMerged &modelMerged, Substitutions &popSubs) const;
54 
55  std::string getVarIndex(unsigned int batchSize, VarAccessDuplication varDuplication, const std::string &index) const;
56  std::string getReadVarIndex(bool delay, unsigned int batchSize, VarAccessDuplication varDuplication, const std::string &index) const;
57  std::string getWriteVarIndex(bool delay, unsigned int batchSize, VarAccessDuplication varDuplication, const std::string &index) const;
58 
59  //----------------------------------------------------------------------------
60  // Static constants
61  //----------------------------------------------------------------------------
62  static const std::string name;
63 
64 private:
65  //------------------------------------------------------------------------
66  // Private methods
67  //------------------------------------------------------------------------
69  void generateWUVar(const BackendBase &backend, const std::string &fieldPrefixStem,
70  const std::vector<std::vector<SynapseGroupInternal*>> &sortedSyn,
71  Models::Base::VarVec(WeightUpdateModels::Base::*getVars)(void) const,
72  bool(NeuronUpdateGroupMerged::*isParamHeterogeneous)(size_t, size_t) const,
73  bool(NeuronUpdateGroupMerged::*isDerivedParamHeterogeneous)(size_t, size_t) const,
74  const std::string&(SynapseGroupInternal::*getFusedVarSuffix)(void) const);
75 
77  bool isInSynWUMParamReferenced(size_t childIndex, size_t paramIndex) const;
78 
80  bool isInSynWUMDerivedParamReferenced(size_t childIndex, size_t paramIndex) const;
81 
83  bool isOutSynWUMParamReferenced(size_t childIndex, size_t paramIndex) const;
84 
86  bool isOutSynWUMDerivedParamReferenced(size_t childIndex, size_t paramIndex) const;
87 
88  void addNeuronModelSubstitutions(Substitutions &substitution, const std::string &sourceSuffix = "", const std::string &destSuffix = "") const;
89 
90  void generateWUVarUpdate(CodeStream &os, const Substitutions &popSubs,
91  const std::string &fieldPrefixStem, const std::string &precision, const std::string &sourceSuffix,
92  bool useLocalNeuronVars, unsigned int batchSize,
93  const std::vector<SynapseGroupInternal*> &archetypeSyn,
94  unsigned int(SynapseGroupInternal::*getDelaySteps)(void) const,
95  Models::Base::VarVec(WeightUpdateModels::Base::*getVars)(void) const,
96  std::string(WeightUpdateModels::Base::*getCode)(void) const,
97  bool(NeuronUpdateGroupMerged::*isParamHeterogeneous)(size_t, size_t) const,
98  bool(NeuronUpdateGroupMerged::*isDerivedParamHeterogeneous)(size_t, size_t) const) const;
99 
100  //------------------------------------------------------------------------
101  // Members
102  //------------------------------------------------------------------------
103  std::vector<std::vector<SynapseGroupInternal *>> m_SortedInSynWithPostCode;
104  std::vector<std::vector<SynapseGroupInternal *>> m_SortedOutSynWithPreCode;
105 };
106 } // namespace CodeGenerator
static const std::string name
Definition: neuronUpdateGroupMerged.h:62
std::vector< Var > VarVec
Definition: models.h:115
#define GENN_EXPORT
Definition: gennExport.h:13
const std::vector< SynapseGroupInternal * > & getSortedArchetypeOutSynWithPreCode() const
Get sorted vectors of outgoing synapse groups with presynaptic code belonging to archetype group...
Definition: neuronUpdateGroupMerged.h:36
Definition: modelSpecMerged.h:31
Helper class for generating code - automatically inserts brackets, indents etc.
Definition: backendBase.h:30
Definition: synapseGroupInternal.h:9
Definition: codeStream.h:21
Definition: substitutions.h:21
Base class for all weight update models.
Definition: weightUpdateModels.h:46
Definition: backendBase.h:176
GENN_EXPORT void generateNeuronUpdate(const filesystem::path &outputPath, const ModelSpecMerged &modelMerged, const BackendBase &backend, const std::string &suffix="")
Definition: generateModules.cc:177
void generateRunner(const BackendBase &backend, CodeStream &definitionsInternal, CodeStream &definitionsInternalFunc, CodeStream &definitionsInternalVar, CodeStream &runnerVarDecl, CodeStream &runnerMergedStructAlloc) const
Definition: neuronUpdateGroupMerged.h:41
Definition: groupMerged.h:583
Definition: neuronUpdateGroupMerged.h:11
const std::vector< SynapseGroupInternal * > & getSortedArchetypeInSynWithPostCode() const
Get sorted vectors of incoming synapse groups with postsynaptic code belonging to archetype group...
Definition: neuronUpdateGroupMerged.h:33
VarAccessDuplication
Flags defining how variables should be duplicated across multiple batches.
Definition: varAccess.h:28
std::function< void(CodeStream &, const T &, Substitutions &)> GroupHandler
Definition: backendBase.h:187