GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
backendBase.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Standard C++ includes
4 #include <fstream>
5 #include <functional>
6 #include <map>
7 #include <string>
8 #include <unordered_map>
9 #include <vector>
10 
11 // Filesystem includes
12 #include "path.h"
13 
14 // PLOG includes
15 #include <plog/Severity.h>
16 
17 // GeNN includes
18 #include "codeStream.h"
19 #include "gennExport.h"
20 #include "gennUtils.h"
21 #include "varAccess.h"
22 #include "variableMode.h"
23 
24 // Forward declarations
29 
30 namespace CodeGenerator
31 {
32  class ModelSpecMerged;
34  class Substitutions;
49 
50 }
51 
52 //--------------------------------------------------------------------------
53 // CodeGenerator::PreferencesBase
54 //--------------------------------------------------------------------------
55 namespace CodeGenerator
56 {
59 {
61  bool optimizeCode = false;
62 
64  bool debugCode = false;
65 
69 
71  bool automaticCopy = false;
72 
75 
78 
81  bool includeModelNameInDLL = false;
82 
84  std::string userCxxFlagsGNU = "";
85 
87  std::string userNvccFlagsGNU = "";
88 
90  plog::Severity logLevel = plog::info;
91 
92  void updateHash(boost::uuids::detail::sha1 &hash) const
93  {
94  // **NOTE** optimizeCode, debugCode and various compiler flags only affect makefiles/msbuild
95 
97  Utils::updateHash(enableBitmaskOptimisations, hash);
98  Utils::updateHash(automaticCopy, hash);
99  Utils::updateHash(generateEmptyStatePushPull, hash);
100  Utils::updateHash(generateExtraGlobalParamPull, hash);
101  }
102 };
103 
104 //--------------------------------------------------------------------------
105 // CodeGenerator::MemAlloc
106 //--------------------------------------------------------------------------
107 class MemAlloc
108 {
109 public:
110  //--------------------------------------------------------------------------
111  // Public API
112  //--------------------------------------------------------------------------
113  size_t getHostBytes() const{ return m_HostBytes; }
114  size_t getDeviceBytes() const{ return m_DeviceBytes; }
115  size_t getZeroCopyBytes() const{ return m_ZeroCopyBytes; }
116  size_t getHostMBytes() const{ return m_HostBytes / (1024 * 1024); }
117  size_t getDeviceMBytes() const{ return m_DeviceBytes / (1024 * 1024); }
118  size_t getZeroCopyMBytes() const{ return m_ZeroCopyBytes / (1024 * 1024); }
119 
120  //--------------------------------------------------------------------------
121  // Operators
122  //--------------------------------------------------------------------------
124  m_HostBytes += rhs.m_HostBytes;
125  m_DeviceBytes += rhs.m_DeviceBytes;
126  m_ZeroCopyBytes += rhs.m_ZeroCopyBytes;
127  return *this;
128  }
129 
130  //--------------------------------------------------------------------------
131  // Static API
132  //--------------------------------------------------------------------------
133  static MemAlloc zero(){ return MemAlloc(0, 0, 0); }
134  static MemAlloc host(size_t hostBytes){ return MemAlloc(hostBytes, 0, 0); }
135  static MemAlloc hostDevice(size_t bytes) { return MemAlloc(bytes, bytes, 0); }
136  static MemAlloc device(size_t deviceBytes){ return MemAlloc(0, deviceBytes, 0); }
137  static MemAlloc zeroCopy(size_t zeroCopyBytes){ return MemAlloc(0, 0, zeroCopyBytes); }
138 
139 private:
140  MemAlloc(size_t hostBytes, size_t deviceBytes, size_t zeroCopyBytes)
141  : m_HostBytes(hostBytes), m_DeviceBytes(deviceBytes), m_ZeroCopyBytes(zeroCopyBytes)
142  {
143  }
144 
145  //--------------------------------------------------------------------------
146  // Members
147  //--------------------------------------------------------------------------
148  size_t m_HostBytes;
149  size_t m_DeviceBytes;
150  size_t m_ZeroCopyBytes;
151 
152  //--------------------------------------------------------------------------
153  // Friend operators
154  //--------------------------------------------------------------------------
155  friend std::ostream& operator << (std::ostream &out, const MemAlloc &m);
156  friend std::istream& operator >> (std::istream &in, MemAlloc &m);
157 };
158 
159 inline std::ostream & operator << (std::ostream &out, const MemAlloc &m)
160 {
161  out << m.m_HostBytes << " " << m.m_DeviceBytes << " " << m.m_ZeroCopyBytes;
162  return out;
163 }
164 
165 inline std::istream & operator >> (std::istream &in, MemAlloc &m)
166 {
167  in >> m.m_HostBytes;
168  in >> m.m_DeviceBytes;
169  in >> m.m_ZeroCopyBytes;
170  return in;
171 }
172 
173 //--------------------------------------------------------------------------
174 // CodeGenerator::BackendBase
175 //--------------------------------------------------------------------------
177 {
178 public:
179  //--------------------------------------------------------------------------
180  // Typedefines
181  //--------------------------------------------------------------------------
182  typedef std::function<void(CodeStream &)> HostHandler;
183 
184  typedef std::function<void(CodeStream &, Substitutions&)> Handler;
185 
186  template<typename T>
187  using GroupHandler = std::function <void(CodeStream &, const T &, Substitutions&)> ;
188 
190  typedef std::vector<std::pair<std::string, size_t>> MemorySpaces;
191 
192  BackendBase(const std::string &scalarType, const PreferencesBase &preferences);
193  virtual ~BackendBase(){}
194 
195  //--------------------------------------------------------------------------
196  // Declared virtuals
197  //--------------------------------------------------------------------------
199 
203  virtual void genNeuronUpdate(CodeStream &os, const ModelSpecMerged &modelMerged,
204  HostHandler preambleHandler, HostHandler pushEGPHandler) const = 0;
205 
207 
211  virtual void genSynapseUpdate(CodeStream &os, const ModelSpecMerged &modelMerged,
212  HostHandler preambleHandler, HostHandler pushEGPHandler) const = 0;
213 
215 
219  virtual void genCustomUpdate(CodeStream &os, const ModelSpecMerged &modelMerged,
220  HostHandler preambleHandler, HostHandler pushEGPHandler) const = 0;
221 
223 
228  virtual void genInit(CodeStream &os, const ModelSpecMerged &modelMerged,
229  HostHandler preambleHandler, HostHandler initPushEGPHandler, HostHandler initSparsePushEGPHandler) const = 0;
230 
232  virtual size_t getSynapticMatrixRowStride(const SynapseGroupInternal &sg) const = 0;
233 
235 
236  virtual void genDefinitionsPreamble(CodeStream &os, const ModelSpecMerged &modelMerged) const = 0;
237 
239 
240  virtual void genDefinitionsInternalPreamble(CodeStream &os, const ModelSpecMerged &modelMerged) const = 0;
241 
242  virtual void genRunnerPreamble(CodeStream &os, const ModelSpecMerged &modelMerged, const MemAlloc &memAlloc) const = 0;
243 
246  virtual void genAllocateMemPreamble(CodeStream &os, const ModelSpecMerged &modelMerged, const MemAlloc &memAlloc) const = 0;
247 
250  virtual void genFreeMemPreamble(CodeStream &os, const ModelSpecMerged &modelMerged) const = 0;
251 
253  virtual void genStepTimeFinalisePreamble(CodeStream &os, const ModelSpecMerged &modelMerged) const = 0;
254 
255  virtual void genVariableDefinition(CodeStream &definitions, CodeStream &definitionsInternal, const std::string &type, const std::string &name, VarLocation loc) const = 0;
256  virtual void genVariableImplementation(CodeStream &os, const std::string &type, const std::string &name, VarLocation loc) const = 0;
257  virtual void genVariableAllocation(CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, size_t count, MemAlloc &memAlloc) const = 0;
258  virtual void genVariableFree(CodeStream &os, const std::string &name, VarLocation loc) const = 0;
259 
260  virtual void genExtraGlobalParamDefinition(CodeStream &definitions, CodeStream &definitionsInternal, const std::string &type, const std::string &name, VarLocation loc) const = 0;
261  virtual void genExtraGlobalParamImplementation(CodeStream &os, const std::string &type, const std::string &name, VarLocation loc) const = 0;
262  virtual void genExtraGlobalParamAllocation(CodeStream &os, const std::string &type, const std::string &name,
263  VarLocation loc, const std::string &countVarName = "count", const std::string &prefix = "") const = 0;
264  virtual void genExtraGlobalParamPush(CodeStream &os, const std::string &type, const std::string &name,
265  VarLocation loc, const std::string &countVarName = "count", const std::string &prefix = "") const = 0;
266  virtual void genExtraGlobalParamPull(CodeStream &os, const std::string &type, const std::string &name,
267  VarLocation loc, const std::string &countVarName = "count", const std::string &prefix = "") const = 0;
268 
270  virtual void genMergedExtraGlobalParamPush(CodeStream &os, const std::string &suffix, size_t mergedGroupIdx,
271  const std::string &groupIdx, const std::string &fieldName,
272  const std::string &egpName) const = 0;
273 
275  virtual std::string getMergedGroupFieldHostType(const std::string &type) const = 0;
276 
278  virtual std::string getMergedGroupSimRNGType() const = 0;
279 
280  virtual void genPopVariableInit(CodeStream &os, const Substitutions &kernelSubs, Handler handler) const = 0;
281  virtual void genVariableInit(CodeStream &os, const std::string &count, const std::string &indexVarName,
282  const Substitutions &kernelSubs, Handler handler) const = 0;
283  virtual void genSparseSynapseVariableRowInit(CodeStream &os, const Substitutions &kernelSubs, Handler handler) const = 0;
284  virtual void genDenseSynapseVariableRowInit(CodeStream &os, const Substitutions &kernelSubs, Handler handler) const = 0;
285  virtual void genKernelSynapseVariableInit(CodeStream &os, const SynapseInitGroupMerged &sg, const Substitutions &kernelSubs, Handler handler) const = 0;
286  virtual void genKernelCustomUpdateVariableInit(CodeStream &os, const CustomWUUpdateInitGroupMerged &cu, const Substitutions &kernelSubs, Handler handler) const = 0;
287 
289  virtual void genVariablePush(CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, bool autoInitialized, size_t count) const = 0;
290 
292  virtual void genVariablePull(CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, size_t count) const = 0;
293 
295  virtual void genCurrentVariablePush(CodeStream &os, const NeuronGroupInternal &ng, const std::string &type,
296  const std::string &name, VarLocation loc, unsigned int batchSize) const = 0;
297 
299  virtual void genCurrentVariablePull(CodeStream &os, const NeuronGroupInternal &ng, const std::string &type,
300  const std::string &name, VarLocation loc, unsigned int batchSize) const = 0;
301 
303  virtual void genCurrentTrueSpikePush(CodeStream &os, const NeuronGroupInternal &ng, unsigned int batchSize) const = 0;
304 
306  virtual void genCurrentTrueSpikePull(CodeStream &os, const NeuronGroupInternal &ng, unsigned int batchSize) const = 0;
307 
309  virtual void genCurrentSpikeLikeEventPush(CodeStream &os, const NeuronGroupInternal &ng, unsigned int batchSize) const = 0;
310 
312  virtual void genCurrentSpikeLikeEventPull(CodeStream &os, const NeuronGroupInternal &ng, unsigned int batchSize) const = 0;
313 
315 
316  virtual void genGlobalDeviceRNG(CodeStream &definitions, CodeStream &definitionsInternal, CodeStream &runner,
317  CodeStream &allocations, CodeStream &free, MemAlloc &memAlloc) const = 0;
318 
320  virtual void genPopulationRNG(CodeStream &definitions, CodeStream &definitionsInternal, CodeStream &runner, CodeStream &allocations,
321  CodeStream &free, const std::string &name, size_t count, MemAlloc &memAlloc) const = 0;
322 
323  virtual void genTimer(CodeStream &definitions, CodeStream &definitionsInternal, CodeStream &runner, CodeStream &allocations, CodeStream &free,
324  CodeStream &stepTimeFinalise, const std::string &name, bool updateInStepTime) const = 0;
325 
327  virtual void genReturnFreeDeviceMemoryBytes(CodeStream &os) const = 0;
328 
330  virtual void genMakefilePreamble(std::ostream &os) const = 0;
331 
334  virtual void genMakefileLinkRule(std::ostream &os) const = 0;
335 
338  virtual void genMakefileCompileRule(std::ostream &os) const = 0;
339 
342 
343  virtual void genMSBuildConfigProperties(std::ostream &os) const = 0;
344  virtual void genMSBuildImportProps(std::ostream &os) const = 0;
345 
348 
349  virtual void genMSBuildItemDefinitions(std::ostream &os) const = 0;
350  virtual void genMSBuildCompileModule(const std::string &moduleName, std::ostream &os) const = 0;
351  virtual void genMSBuildImportTarget(std::ostream &os) const = 0;
352 
354  virtual std::string getAllocateMemParams(const ModelSpecMerged &) const { return ""; }
355 
357 
358  virtual std::vector<filesystem::path> getFilesToCopy(const ModelSpecMerged&) const{ return {}; }
359 
362  virtual std::string getDeviceVarPrefix() const{ return ""; }
363 
366  virtual std::string getHostVarPrefix() const { return ""; }
367 
369  virtual std::string getPointerPrefix() const { return ""; }
370 
372  virtual bool isDeviceScalarRequired() const = 0;
373 
375  virtual bool isGlobalHostRNGRequired(const ModelSpecMerged &modelMerged) const = 0;
376 
378  virtual bool isGlobalDeviceRNGRequired(const ModelSpecMerged &modelMerged) const = 0;
379 
381  virtual bool isPopulationRNGRequired() const = 0;
382 
384  virtual bool isPopulationRNGInitialisedOnDevice() const = 0;
385 
387  virtual bool isPostsynapticRemapRequired() const = 0;
388 
390  virtual bool isHostReductionRequired() const = 0;
391 
393  virtual size_t getDeviceMemoryBytes() const = 0;
394 
398  virtual MemorySpaces getMergedGroupMemorySpaces(const ModelSpecMerged &modelMerged) const = 0;
399 
401  virtual bool supportsNamespace() const = 0;
402 
404  virtual boost::uuids::detail::sha1::digest_type getHashDigest() const = 0;
405 
406  //--------------------------------------------------------------------------
407  // Public API
408  //--------------------------------------------------------------------------
411  const std::string &type, const std::string &name, VarLocation loc, bool autoInitialized, size_t count) const
412  {
413  genVariablePush(push, type, name, loc, autoInitialized, count);
414  genVariablePull(pull, type, name, loc, count);
415  }
416 
418  void genCurrentVariablePushPull(CodeStream &push, CodeStream &pull, const NeuronGroupInternal &ng, const std::string &type,
419  const std::string &name, VarLocation loc, unsigned int batchSize) const
420  {
421  genCurrentVariablePush(push, ng, type, name, loc, batchSize);
422  genCurrentVariablePull(pull, ng, type, name, loc, batchSize);
423  }
424 
426  void genArray(CodeStream &definitions, CodeStream &definitionsInternal, CodeStream &runner, CodeStream &allocations, CodeStream &free,
427  const std::string &type, const std::string &name, VarLocation loc, size_t count, MemAlloc &memAlloc) const
428  {
429  genVariableDefinition(definitions, definitionsInternal, type + "*", name, loc);
430  genVariableImplementation(runner, type + "*", name, loc);
431  genVariableFree(free, name, loc);
432  genVariableAllocation(allocations, type, name, loc, count, memAlloc);
433  }
434 
436  size_t getSize(const std::string &type) const;
437 
439  std::string getLowestValue(const std::string &type) const;
440 
442  std::string getScalarAddressPrefix() const
443  {
444  return isDeviceScalarRequired() ? getDeviceVarPrefix() : ("&" + getDeviceVarPrefix());
445  }
446 
447  bool areSixtyFourBitSynapseIndicesRequired(const SynapseGroupMergedBase &sg) const;
448 
449  const PreferencesBase &getPreferences() const { return m_Preferences; }
450 
451  template<typename T>
452  const T &getPreferences() const { return static_cast<const T &>(m_Preferences); }
453 
454 protected:
455  //--------------------------------------------------------------------------
456  // ReductionTarget
457  //--------------------------------------------------------------------------
460  {
461  ReductionTarget(const std::string &n, const std::string &t, VarAccessMode a, const std::string &i)
462  : name(n), type(t), access(a), index(i)
463  {
464  }
465 
466  const std::string name;
467  const std::string type;
469  const std::string index;
470  };
471 
472  //--------------------------------------------------------------------------
473  // Protected API
474  //--------------------------------------------------------------------------
475  void addType(const std::string &type, size_t size, const std::string &lowestValue = "")
476  {
477  m_Types.emplace(std::piecewise_construct, std::forward_as_tuple(type),
478  std::forward_as_tuple(size, lowestValue));
479  }
480 
481  void setPointerBytes(size_t pointerBytes)
482  {
483  m_PointerBytes = pointerBytes;
484  }
485 
486  void genNeuronIndexCalculation(CodeStream &os, const NeuronUpdateGroupMerged &ng, unsigned int batchSize) const;
487 
488  void genSynapseIndexCalculation(CodeStream &os, const SynapseGroupMergedBase &sg, unsigned int batchSize) const;
489 
490  void genCustomUpdateIndexCalculation(CodeStream &os, const CustomUpdateGroupMerged &cu) const;
491 
494  std::vector<ReductionTarget> genInitReductionTargets(CodeStream &os, const CustomUpdateGroupMerged &cg, const std::string &idx = "") const;
495 
498  std::vector<ReductionTarget> genInitReductionTargets(CodeStream &os, const CustomUpdateWUGroupMerged &cg, const std::string &idx = "") const;
499 
500 private:
501  //--------------------------------------------------------------------------
502  // Private API
503  //--------------------------------------------------------------------------
504  template<typename G, typename R>
505  std::vector<ReductionTarget> genInitReductionTargets(CodeStream &os, const G &cg, const std::string &idx, R getVarRefIndexFn) const
506  {
507  // Loop through variables
508  std::vector<ReductionTarget> reductionTargets;
509  const auto *cm = cg.getArchetype().getCustomUpdateModel();
510  for (const auto &v : cm->getVars()) {
511  // If variable is a reduction target, define variable initialised to correct initial value for reduction
512  if (v.access & VarAccessModeAttribute::REDUCE) {
513  os << v.type << " lr" << v.name << " = " << getReductionInitialValue(*this, getVarAccessMode(v.access), v.type) << ";" << std::endl;
514  reductionTargets.emplace_back(v.name, v.type, getVarAccessMode(v.access),
515  cg.getVarIndex(getVarAccessDuplication(v.access), idx));
516  }
517  }
518 
519  // Loop through variable references
520  const auto modelVarRefs = cm->getVarRefs();
521  const auto &varRefs = cg.getArchetype().getVarReferences();
522  for (size_t i = 0; i < varRefs.size(); i++) {
523  const auto varRef = varRefs.at(i);
524  const auto modelVarRef = modelVarRefs.at(i);
525 
526  // If variable reference is a reduction target, define variable initialised to correct initial value for reduction
527  if (modelVarRef.access & VarAccessModeAttribute::REDUCE) {
528  os << modelVarRef.type << " lr" << modelVarRef.name << " = " << getReductionInitialValue(*this, modelVarRef.access, modelVarRef.type) << ";" << std::endl;
529  reductionTargets.emplace_back(modelVarRef.name, modelVarRef.type, modelVarRef.access,
530  getVarRefIndexFn(varRef, idx));
531  }
532  }
533  return reductionTargets;
534  }
535 
536 
537  //--------------------------------------------------------------------------
538  // Members
539  //--------------------------------------------------------------------------
541  size_t m_PointerBytes;
542 
545  std::unordered_map<std::string, std::pair<size_t, std::string>> m_Types;
546 
548  const PreferencesBase &m_Preferences;
549 };
550 } // namespace CodeGenerator
Definition: neuronGroupInternal.h:9
std::string getScalarAddressPrefix() const
Get the prefix for accessing the address of &#39;scalar&#39; variables.
Definition: backendBase.h:442
VarAccessMode
Supported combination of VarAccessModeAttribute.
Definition: varAccess.h:19
size_t getHostMBytes() const
Definition: backendBase.h:116
size_t getDeviceBytes() const
Definition: backendBase.h:114
VarLocation
< Flags defining which memory space variables should be allocated in
Definition: variableMode.h:10
Definition: initGroupMerged.h:298
Definition: customUpdateGroupMerged.h:12
Definition: groupMerged.h:1021
std::ostream & operator<<(std::ostream &out, const MemAlloc &m)
Definition: backendBase.h:159
void addType(const std::string &type, size_t size, const std::string &lowestValue="")
Definition: backendBase.h:475
const std::string index
Definition: backendBase.h:469
bool automaticCopy
If backend/device supports it, copy data automatically when required rather than requiring push and p...
Definition: backendBase.h:71
ReductionTarget(const std::string &n, const std::string &t, VarAccessMode a, const std::string &i)
Definition: backendBase.h:461
#define GENN_EXPORT
Definition: gennExport.h:13
Definition: synapseUpdateGroupMerged.h:85
size_t getDeviceMBytes() const
Definition: backendBase.h:117
Base class for backend preferences - can be accessed via a global in &#39;classic&#39; C++ code generator...
Definition: backendBase.h:58
static MemAlloc host(size_t hostBytes)
Definition: backendBase.h:134
bool generateExtraGlobalParamPull
Should GeNN generate pull functions for extra global parameters? These are very rarely used...
Definition: backendBase.h:77
Definition: modelSpecMerged.h:31
Helper class for generating code - automatically inserts brackets, indents etc.
Definition: backendBase.h:30
bool generateEmptyStatePushPull
Should GeNN generate empty state push and pull functions.
Definition: backendBase.h:74
size_t getZeroCopyBytes() const
Definition: backendBase.h:115
void genCurrentVariablePushPull(CodeStream &push, CodeStream &pull, const NeuronGroupInternal &ng, const std::string &type, const std::string &name, VarLocation loc, unsigned int batchSize) const
Helper function to generate matching push and pull functions for the current state of a variable...
Definition: backendBase.h:418
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
std::istream & operator>>(std::istream &in, MemAlloc &m)
Definition: backendBase.h:165
Definition: codeStream.h:21
bool enableBitmaskOptimisations
Definition: backendBase.h:68
Definition: backendBase.h:107
void genArray(CodeStream &definitions, CodeStream &definitionsInternal, CodeStream &runner, CodeStream &allocations, CodeStream &free, const std::string &type, const std::string &name, VarLocation loc, size_t count, MemAlloc &memAlloc) const
Helper function to generate matching definition, declaration, allocation and free code for an array...
Definition: backendBase.h:426
Definition: substitutions.h:21
VarAccessMode getVarAccessMode(VarAccess type)
Definition: varAccess.h:74
const T & getPreferences() const
Definition: backendBase.h:452
Definition: synapseUpdateGroupMerged.h:52
Definition: initGroupMerged.h:132
void updateHash(const T &value, boost::uuids::detail::sha1 &hash)
Hash arithmetic types and enums.
Definition: gennUtils.h:128
static MemAlloc zero()
Definition: backendBase.h:133
Definition: initGroupMerged.h:11
Definition: backendBase.h:176
static MemAlloc zeroCopy(size_t zeroCopyBytes)
Definition: backendBase.h:137
std::function< void(CodeStream &)> HostHandler
Definition: backendBase.h:182
bool debugCode
Generate code with debug symbols.
Definition: backendBase.h:64
Definition: initGroupMerged.h:329
std::string userCxxFlagsGNU
C++ compiler options to be used for building all host side code (used for unix based platforms) ...
Definition: backendBase.h:84
Simple struct to hold reduction targets.
Definition: backendBase.h:459
Definition: customUpdateInternal.h:41
virtual std::string getHostVarPrefix() const
Definition: backendBase.h:366
Definition: neuronUpdateGroupMerged.h:11
void updateHash(boost::uuids::detail::sha1 &hash) const
Definition: backendBase.h:92
Definition: initGroupMerged.h:164
static MemAlloc device(size_t deviceBytes)
Definition: backendBase.h:136
Definition: initGroupMerged.h:100
const VarAccessMode access
Definition: backendBase.h:468
Definition: customUpdateGroupMerged.h:125
void setPointerBytes(size_t pointerBytes)
Definition: backendBase.h:481
std::function< void(CodeStream &, const T &, Substitutions &)> GroupHandler
Definition: backendBase.h:187
size_t getZeroCopyMBytes() const
Definition: backendBase.h:118
virtual ~BackendBase()
Definition: backendBase.h:193
plog::Severity logLevel
Logging level to use for code generation.
Definition: backendBase.h:90
std::string userNvccFlagsGNU
NVCC compiler options they may want to use for all GPU code (used for unix based platforms) ...
Definition: backendBase.h:87
virtual std::string getPointerPrefix() const
Different backends may have different or no pointer prefix (e.g. __global for OpenCL) ...
Definition: backendBase.h:369
Definition: customUpdateInternal.h:9
MemAlloc & operator+=(const MemAlloc &rhs)
Definition: backendBase.h:123
bool includeModelNameInDLL
Definition: backendBase.h:81
const std::string name
Definition: backendBase.h:466
virtual std::string getAllocateMemParams(const ModelSpecMerged &) const
Get backend-specific allocate memory parameters.
Definition: backendBase.h:354
void genVariablePushPull(CodeStream &push, CodeStream &pull, const std::string &type, const std::string &name, VarLocation loc, bool autoInitialized, size_t count) const
Helper function to generate matching push and pull functions for a variable.
Definition: backendBase.h:410
VarAccessDuplication getVarAccessDuplication(VarAccess type)
Definition: varAccess.h:79
This variable is read-write.
Definition: synapseUpdateGroupMerged.h:15
size_t getHostBytes() const
Definition: backendBase.h:113
const std::string type
Definition: backendBase.h:467
GENN_EXPORT std::string getReductionInitialValue(const BackendBase &backend, VarAccessMode access, const std::string &type)
Get the initial value to start reduction operations from.
Definition: codeGenUtils.cc:470
static MemAlloc hostDevice(size_t bytes)
Definition: backendBase.h:135
Definition: customUpdateGroupMerged.h:94
virtual std::string getDeviceVarPrefix() const
Definition: backendBase.h:362
virtual std::vector< filesystem::path > getFilesToCopy(const ModelSpecMerged &) const
Get list of files to copy into generated code.
Definition: backendBase.h:358
std::function< void(CodeStream &, Substitutions &)> Handler
Definition: backendBase.h:184
bool optimizeCode
Generate speed-optimized code, potentially at the expense of floating-point accuracy.
Definition: backendBase.h:61
m
Definition: genn_model.py:117
const PreferencesBase & getPreferences() const
Definition: backendBase.h:449