26 namespace SingleThreadedCPU
67 virtual void genVariableDefinition(
CodeStream &definitions,
CodeStream &definitionsInternal,
const std::string &type,
const std::string &name,
VarLocation loc)
const override;
68 virtual void genVariableImplementation(
CodeStream &os,
const std::string &type,
const std::string &name,
VarLocation loc)
const override;
69 virtual void genVariableAllocation(
CodeStream &os,
const std::string &type,
const std::string &name,
VarLocation loc,
size_t count,
MemAlloc &memAlloc)
const override;
70 virtual void genVariableFree(
CodeStream &os,
const std::string &name,
VarLocation loc)
const override;
72 virtual void genExtraGlobalParamDefinition(
CodeStream &definitions,
CodeStream &definitionsInternal,
const std::string &type,
const std::string &name,
VarLocation loc)
const override;
73 virtual void genExtraGlobalParamImplementation(
CodeStream &os,
const std::string &type,
const std::string &name,
VarLocation loc)
const override;
74 virtual void genExtraGlobalParamAllocation(
CodeStream &os,
const std::string &type,
const std::string &name,
75 VarLocation loc,
const std::string &countVarName =
"count",
const std::string &prefix =
"")
const override;
76 virtual void genExtraGlobalParamPush(
CodeStream &os,
const std::string &type,
const std::string &name,
77 VarLocation loc,
const std::string &countVarName =
"count",
const std::string &prefix =
"")
const override;
78 virtual void genExtraGlobalParamPull(
CodeStream &os,
const std::string &type,
const std::string &name,
79 VarLocation loc,
const std::string &countVarName =
"count",
const std::string &prefix =
"")
const override;
82 virtual void genMergedExtraGlobalParamPush(
CodeStream &os,
const std::string &suffix,
size_t mergedGroupIdx,
83 const std::string &groupIdx,
const std::string &fieldName,
84 const std::string &egpName)
const override;
87 virtual std::string getMergedGroupFieldHostType(
const std::string &type)
const override;
90 virtual std::string getMergedGroupSimRNGType()
const override;
93 virtual void genVariableInit(
CodeStream &os,
const std::string &count,
const std::string &indexVarName,
100 virtual void genVariablePush(
CodeStream &os,
const std::string &type,
const std::string &name,
VarLocation loc,
bool autoInitialized,
size_t count)
const override;
101 virtual void genVariablePull(
CodeStream &os,
const std::string &type,
const std::string &name,
VarLocation loc,
size_t count)
const override;
103 const std::string &name,
VarLocation loc,
unsigned int batchSize)
const override;
105 const std::string &name,
VarLocation loc,
unsigned int batchSize)
const override;
116 const std::string &name,
size_t count,
MemAlloc &memAlloc)
const override;
118 CodeStream &stepTimeFinalise,
const std::string &name,
bool updateInStepTime)
const override;
121 virtual void genReturnFreeDeviceMemoryBytes(
CodeStream &os)
const override;
123 virtual void genMakefilePreamble(std::ostream &os)
const override;
124 virtual void genMakefileLinkRule(std::ostream &os)
const override;
125 virtual void genMakefileCompileRule(std::ostream &os)
const override;
127 virtual void genMSBuildConfigProperties(std::ostream &os)
const override;
128 virtual void genMSBuildImportProps(std::ostream &os)
const override;
129 virtual void genMSBuildItemDefinitions(std::ostream &os)
const override;
130 virtual void genMSBuildCompileModule(
const std::string &moduleName, std::ostream &os)
const override;
131 virtual void genMSBuildImportTarget(std::ostream &os)
const override;
138 virtual bool isGlobalHostRNGRequired(
const ModelSpecMerged &modelMerged)
const override;
139 virtual bool isGlobalDeviceRNGRequired(
const ModelSpecMerged &modelMerged)
const override;
161 virtual boost::uuids::detail::sha1::digest_type getHashDigest()
const override;
172 void genMergedStructArrayPush(
CodeStream &os,
const std::vector<T> &groups)
const 175 for(
const auto &g : groups) {
177 assert(g.getMemorySpace().empty());
180 os <<
"static Merged" << T::name <<
"Group" << g.getIndex() <<
" merged" << T::name <<
"Group" << g.getIndex() <<
"[" << g.getGroups().size() <<
"];" << std::endl;
183 os <<
"void pushMerged" << T::name <<
"Group" << g.getIndex() <<
"ToDevice(unsigned int idx, ";
184 g.generateStructFieldArgumentDefinitions(os, *
this);
190 const auto sortedFields = g.getSortedFields(*
this);
191 for(
const auto &f : sortedFields) {
192 os <<
"merged" << T::name <<
"Group" << g.getIndex() <<
"[idx]." << std::get<1>(f) <<
" = " << std::get<1>(f) <<
";" << std::endl;
206 template<
typename G,
typename R>
207 void genWriteBackReductions(
CodeStream &os,
const G &cg,
const std::string &idx, R getVarRefIndexFn)
const 209 const auto *cm = cg.getArchetype().getCustomUpdateModel();
210 for(
const auto &v : cm->getVars()) {
213 os <<
"group->" << v.name <<
"[" << cg.getVarIndex(
getVarAccessDuplication(v.access), idx) <<
"] = l" << v.name <<
";" << std::endl;
218 const auto modelVarRefs = cm->getVarRefs();
219 const auto &varRefs = cg.getArchetype().getVarReferences();
220 for (
size_t i = 0; i < varRefs.size(); i++) {
221 const auto varRef = varRefs.at(i);
222 const auto modelVarRef = modelVarRefs.at(i);
226 os <<
"group->" << modelVarRef.name <<
"[" << getVarRefIndexFn(varRef, idx) <<
"] = l" << modelVarRef.name <<
";" << std::endl;
Definition: neuronGroupInternal.h:9
VarLocation
< Flags defining which memory space variables should be allocated in
Definition: variableMode.h:10
Definition: customUpdateGroupMerged.h:12
Base class for backend preferences - can be accessed via a global in 'classic' C++ code generator...
Definition: backendBase.h:58
virtual std::string getDeviceVarPrefix() const override
Definition: single_threaded_cpu/backend.h:133
virtual bool isDeviceScalarRequired() const override
Should 'scalar' variables be implemented on device or can host variables be used directly?
Definition: single_threaded_cpu/backend.h:136
Definition: modelSpecMerged.h:31
Helper class for generating code - automatically inserts brackets, indents etc.
Definition: backendBase.h:30
std::vector< std::pair< std::string, size_t > > MemorySpaces
Vector of prefixes required to allocate in memory space and size of memory space. ...
Definition: backendBase.h:190
Definition: synapseGroupInternal.h:9
Definition: codeStream.h:21
#define BACKEND_EXPORT
Definition: backendExport.h:13
Definition: backendBase.h:107
Definition: substitutions.h:21
Definition: single_threaded_cpu/backend.h:28
virtual size_t getDeviceMemoryBytes() const override
How many bytes of memory does 'device' have.
Definition: single_threaded_cpu/backend.h:151
Definition: backendBase.h:176
virtual bool isPopulationRNGRequired() const override
Different backends use different RNGs for different things. Does this one require population RNGs...
Definition: single_threaded_cpu/backend.h:140
virtual bool supportsNamespace() const override
Does this backend support namespaces i.e. can C++ implementation of support functions be used...
Definition: single_threaded_cpu/backend.h:158
std::function< void(CodeStream &)> HostHandler
Definition: backendBase.h:182
Definition: initGroupMerged.h:329
virtual bool isPostsynapticRemapRequired() const override
Different backends may implement synaptic plasticity differently. Does this one require a postsynapti...
Definition: single_threaded_cpu/backend.h:145
Definition: single_threaded_cpu/backend.h:35
Definition: neuronUpdateGroupMerged.h:11
Definition: initGroupMerged.h:100
virtual bool isHostReductionRequired() const override
Backends which support batch-parallelism might require an additional host reduction phase after reduc...
Definition: single_threaded_cpu/backend.h:148
Definition: generateModules.h:16
Backend(const std::string &scalarType, const Preferences &preferences)
Definition: single_threaded_cpu/backend.h:38
VarAccessDuplication getVarAccessDuplication(VarAccess type)
Definition: varAccess.h:79
This variable is read-write.
virtual bool isPopulationRNGInitialisedOnDevice() const override
Different backends seed RNGs in different ways. Does this one initialise population RNGS on device...
Definition: single_threaded_cpu/backend.h:143
Definition: synapseUpdateGroupMerged.h:15
Definition: customUpdateGroupMerged.h:94
std::function< void(CodeStream &, Substitutions &)> Handler
Definition: backendBase.h:184
Definition: codeStream.h:94