GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
CodeGenerator::CUDA::Backend Class Reference

#include <backend.h>

Inheritance diagram for CodeGenerator::CUDA::Backend:
CodeGenerator::BackendSIMT CodeGenerator::BackendBase

Public Member Functions

 Backend (const KernelBlockSize &kernelBlockSizes, const Preferences &preferences, const std::string &scalarType, int device)
 
virtual bool areSharedMemAtomicsSlow () const override
 On some older devices, shared memory atomics are actually slower than global memory atomics so should be avoided. More...
 
virtual std::string getSharedPrefix () const override
 Get the prefix to use for shared memory variables. More...
 
virtual std::string getThreadID (unsigned int axis=0) const override
 Get the ID of the current thread within the threadblock. More...
 
virtual std::string getBlockID (unsigned int axis=0) const override
 Get the ID of the current thread block. More...
 
virtual std::string getCLZ () const override
 Get the name of the count-leading-zeros function. More...
 
virtual std::string getAtomic (const std::string &type, AtomicOperation op=AtomicOperation::ADD, AtomicMemSpace memSpace=AtomicMemSpace::GLOBAL) const override
 Get name of atomic operation. More...
 
virtual void genSharedMemBarrier (CodeStream &os) const override
 Generate a shared memory barrier. More...
 
virtual void genPopulationRNGInit (CodeStream &os, const std::string &globalRNG, const std::string &seed, const std::string &sequence) const override
 For SIMT backends which initialize RNGs on device, initialize population RNG with specified seed and sequence. More...
 
virtual void genPopulationRNGPreamble (CodeStream &os, Substitutions &subs, const std::string &globalRNG, const std::string &name="rng") const override
 Generate a preamble to add substitution name for population RNG. More...
 
virtual void genPopulationRNGPostamble (CodeStream &os, const std::string &globalRNG) const override
 If required, generate a postamble for population RNG. More...
 
virtual void genGlobalRNGSkipAhead (CodeStream &os, Substitutions &subs, const std::string &sequence, const std::string &name="rng") const override
 Generate code to skip ahead local copy of global RNG. More...
 
virtual void genNeuronUpdate (CodeStream &os, const ModelSpecMerged &modelMerged, HostHandler preambleHandler, HostHandler pushEGPHandler) const override
 Generate platform-specific function to update the state of all neurons. More...
 
virtual void genSynapseUpdate (CodeStream &os, const ModelSpecMerged &modelMerged, HostHandler preambleHandler, HostHandler pushEGPHandler) const override
 Generate platform-specific function to update the state of all synapses. More...
 
virtual void genCustomUpdate (CodeStream &os, const ModelSpecMerged &modelMerged, HostHandler preambleHandler, HostHandler pushEGPHandler) const override
 Generate platform-specific functions to perform custom updates. More...
 
virtual void genInit (CodeStream &os, const ModelSpecMerged &modelMerged, HostHandler preambleHandler, HostHandler initPushEGPHandler, HostHandler initSparsePushEGPHandler) const override
 Generate platform-specific function to initialise model. More...
 
virtual void genDefinitionsPreamble (CodeStream &os, const ModelSpecMerged &modelMerged) const override
 Definitions is the usercode-facing header file for the generated code. This function generates a 'preamble' to this header file. More...
 
virtual void genDefinitionsInternalPreamble (CodeStream &os, const ModelSpecMerged &modelMerged) const override
 Definitions internal is the internal header file for the generated code. This function generates a 'preamble' to this header file. More...
 
virtual void genRunnerPreamble (CodeStream &os, const ModelSpecMerged &modelMerged, const MemAlloc &memAlloc) const override
 
virtual void genAllocateMemPreamble (CodeStream &os, const ModelSpecMerged &modelMerged, const MemAlloc &memAlloc) const override
 
virtual void genFreeMemPreamble (CodeStream &os, const ModelSpecMerged &modelMerged) const override
 
virtual void genStepTimeFinalisePreamble (CodeStream &os, const ModelSpecMerged &modelMerged) const override
 After all timestep logic is complete. More...
 
virtual void genVariableDefinition (CodeStream &definitions, CodeStream &definitionsInternal, const std::string &type, const std::string &name, VarLocation loc) const override
 
virtual void genVariableImplementation (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc) const override
 
virtual void genVariableAllocation (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, size_t count, MemAlloc &memAlloc) const override
 
virtual void genVariableFree (CodeStream &os, const std::string &name, VarLocation loc) const override
 
virtual void genExtraGlobalParamDefinition (CodeStream &definitions, CodeStream &definitionsInternal, const std::string &type, const std::string &name, VarLocation loc) const override
 
virtual void genExtraGlobalParamImplementation (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc) const override
 
virtual void genExtraGlobalParamAllocation (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, const std::string &countVarName="count", const std::string &prefix="") const override
 
virtual void genExtraGlobalParamPush (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, const std::string &countVarName="count", const std::string &prefix="") const override
 
virtual void genExtraGlobalParamPull (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, const std::string &countVarName="count", const std::string &prefix="") const override
 
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 override
 Generate code for pushing an updated EGP value into the merged group structure on 'device'. More...
 
virtual std::string getMergedGroupFieldHostType (const std::string &type) const override
 When generating function calls to push to merged groups, backend without equivalent of Unified Virtual Addressing e.g. OpenCL 1.2 may use different types on host. More...
 
virtual std::string getMergedGroupSimRNGType () const override
 When generating merged structures what type to use for simulation RNGs. More...
 
virtual void genVariablePush (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, bool autoInitialized, size_t count) const override
 Generate code for pushing a variable to the 'device'. More...
 
virtual void genVariablePull (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, size_t count) const override
 Generate code for pulling a variable from the 'device'. More...
 
virtual void genCurrentVariablePush (CodeStream &os, const NeuronGroupInternal &ng, const std::string &type, const std::string &name, VarLocation loc, unsigned int batchSize) const override
 Generate code for pushing a variable's value in the current timestep to the 'device'. More...
 
virtual void genCurrentVariablePull (CodeStream &os, const NeuronGroupInternal &ng, const std::string &type, const std::string &name, VarLocation loc, unsigned int batchSize) const override
 Generate code for pulling a variable's value in the current timestep from the 'device'. More...
 
virtual void genCurrentTrueSpikePush (CodeStream &os, const NeuronGroupInternal &ng, unsigned int batchSize) const override
 Generate code for pushing true spikes emitted by a neuron group in the current timestep to the 'device'. More...
 
virtual void genCurrentTrueSpikePull (CodeStream &os, const NeuronGroupInternal &ng, unsigned int batchSize) const override
 Generate code for pulling true spikes emitted by a neuron group in the current timestep from the 'device'. More...
 
virtual void genCurrentSpikeLikeEventPush (CodeStream &os, const NeuronGroupInternal &ng, unsigned int batchSize) const override
 Generate code for pushing spike-like events emitted by a neuron group in the current timestep to the 'device'. More...
 
virtual void genCurrentSpikeLikeEventPull (CodeStream &os, const NeuronGroupInternal &ng, unsigned int batchSize) const override
 Generate code for pulling spike-like events emitted by a neuron group in the current timestep from the 'device'. More...
 
virtual void genGlobalDeviceRNG (CodeStream &definitions, CodeStream &definitionsInternal, CodeStream &runner, CodeStream &allocations, CodeStream &free, MemAlloc &memAlloc) const override
 Generate a single RNG instance. More...
 
virtual void genPopulationRNG (CodeStream &definitions, CodeStream &definitionsInternal, CodeStream &runner, CodeStream &allocations, CodeStream &free, const std::string &name, size_t count, MemAlloc &memAlloc) const override
 Generate an RNG with a state per population member. More...
 
virtual void genTimer (CodeStream &definitions, CodeStream &definitionsInternal, CodeStream &runner, CodeStream &allocations, CodeStream &free, CodeStream &stepTimeFinalise, const std::string &name, bool updateInStepTime) const override
 
virtual void genReturnFreeDeviceMemoryBytes (CodeStream &os) const override
 Generate code to return amount of free 'device' memory in bytes. More...
 
virtual void genMakefilePreamble (std::ostream &os) const override
 This function can be used to generate a preamble for the GNU makefile used to build. More...
 
virtual void genMakefileLinkRule (std::ostream &os) const override
 
virtual void genMakefileCompileRule (std::ostream &os) const override
 
virtual void genMSBuildConfigProperties (std::ostream &os) const override
 
virtual void genMSBuildImportProps (std::ostream &os) const override
 
virtual void genMSBuildItemDefinitions (std::ostream &os) const override
 
virtual void genMSBuildCompileModule (const std::string &moduleName, std::ostream &os) const override
 
virtual void genMSBuildImportTarget (std::ostream &os) const override
 
virtual std::string getAllocateMemParams (const ModelSpecMerged &) const override
 Get backend-specific allocate memory parameters. More...
 
virtual bool isPopulationRNGInitialisedOnDevice () const override
 Different backends seed RNGs in different ways. Does this one initialise population RNGS on device? More...
 
virtual bool isHostReductionRequired () const override
 Backends which support batch-parallelism might require an additional host reduction phase after reduction kernels. More...
 
virtual size_t getDeviceMemoryBytes () const override
 How many bytes of memory does 'device' have. More...
 
virtual MemorySpaces getMergedGroupMemorySpaces (const ModelSpecMerged &modelMerged) const override
 
virtual bool supportsNamespace () const override
 Does this backend support namespaces i.e. can C++ implementation of support functions be used. More...
 
virtual boost::uuids::detail::sha1::digest_type getHashDigest () const override
 Get hash digest of this backends identification and the preferences it has been configured with. More...
 
const cudaDeviceProp & getChosenCUDADevice () const
 
int getChosenDeviceID () const
 
int getRuntimeVersion () const
 
std::string getNVCCFlags () const
 
- Public Member Functions inherited from CodeGenerator::BackendSIMT
 BackendSIMT (const KernelBlockSize &kernelBlockSizes, const PreferencesBase &preferences, const std::string &scalarType)
 
virtual size_t getSynapticMatrixRowStride (const SynapseGroupInternal &sg) const final
 Gets the stride used to access synaptic matrix rows, taking into account sparse data structure, padding etc. More...
 
virtual std::string getDeviceVarPrefix () const final
 
virtual void genPopVariableInit (CodeStream &os, const Substitutions &kernelSubs, Handler handler) const final
 
virtual void genVariableInit (CodeStream &os, const std::string &count, const std::string &indexVarName, const Substitutions &kernelSubs, Handler handler) const final
 
virtual void genSparseSynapseVariableRowInit (CodeStream &os, const Substitutions &kernelSubs, Handler handler) const final
 
virtual void genDenseSynapseVariableRowInit (CodeStream &os, const Substitutions &kernelSubs, Handler handler) const final
 
virtual void genKernelSynapseVariableInit (CodeStream &os, const SynapseInitGroupMerged &sg, const Substitutions &kernelSubs, Handler handler) const final
 
virtual void genKernelCustomUpdateVariableInit (CodeStream &os, const CustomWUUpdateInitGroupMerged &cu, const Substitutions &kernelSubs, Handler handler) const final
 
virtual bool isDeviceScalarRequired () const final
 Should 'scalar' variables be implemented on device or can host variables be used directly? More...
 
virtual bool isGlobalHostRNGRequired (const ModelSpecMerged &modelMerged) const final
 Different backends use different RNGs for different things. Does this one require a global host RNG for the specified model? More...
 
virtual bool isGlobalDeviceRNGRequired (const ModelSpecMerged &modelMerged) const final
 Different backends use different RNGs for different things. Does this one require a global device RNG for the specified model? More...
 
virtual bool isPopulationRNGRequired () const final
 Different backends use different RNGs for different things. Does this one require population RNGs? More...
 
virtual bool isPostsynapticRemapRequired () const final
 Different backends may implement synaptic plasticity differently. Does this one require a postsynaptic remapping data structure? More...
 
size_t getNumInitialisationRNGStreams (const ModelSpecMerged &modelMerged) const
 Get total number of RNG streams potentially used to initialise model. More...
 
size_t getKernelBlockSize (Kernel kernel) const
 
size_t getPaddedNumCustomUpdateThreads (const CustomUpdateInternal &cg, unsigned int batchSize) const
 
size_t getPaddedNumCustomUpdateWUThreads (const CustomUpdateWUInternal &cg, unsigned int batchSize) const
 
size_t getPaddedNumCustomUpdateTransposeWUThreads (const CustomUpdateWUInternal &cg, unsigned int batchSize) const
 
- Public Member Functions inherited from CodeGenerator::BackendBase
 BackendBase (const std::string &scalarType, const PreferencesBase &preferences)
 
virtual ~BackendBase ()
 
virtual std::vector< filesystem::path > getFilesToCopy (const ModelSpecMerged &) const
 Get list of files to copy into generated code. More...
 
virtual std::string getHostVarPrefix () const
 
virtual std::string getPointerPrefix () const
 Different backends may have different or no pointer prefix (e.g. __global for OpenCL) More...
 
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. More...
 
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. More...
 
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. More...
 
size_t getSize (const std::string &type) const
 Get the size of the type. More...
 
std::string getLowestValue (const std::string &type) const
 Get the lowest value of a type. More...
 
std::string getScalarAddressPrefix () const
 Get the prefix for accessing the address of 'scalar' variables. More...
 
bool areSixtyFourBitSynapseIndicesRequired (const SynapseGroupMergedBase &sg) const
 
const PreferencesBasegetPreferences () const
 
template<typename T >
const T & getPreferences () const
 

Additional Inherited Members

- Public Types inherited from CodeGenerator::BackendSIMT
enum  AtomicOperation { AtomicOperation::ADD, AtomicOperation::OR }
 What atomic operation is required. More...
 
enum  AtomicMemSpace { AtomicMemSpace::GLOBAL, AtomicMemSpace::SHARED }
 What memory space atomic operation is required. More...
 
- Public Types inherited from CodeGenerator::BackendBase
typedef std::function< void(CodeStream &)> HostHandler
 
typedef std::function< void(CodeStream &, Substitutions &)> Handler
 
template<typename T >
using GroupHandler = std::function< void(CodeStream &, const T &, Substitutions &)>
 
typedef std::vector< std::pair< std::string, size_t > > MemorySpaces
 Vector of prefixes required to allocate in memory space and size of memory space. More...
 
- Static Public Member Functions inherited from CodeGenerator::BackendSIMT
static size_t getNumPresynapticUpdateThreads (const SynapseGroupInternal &sg, const PreferencesBase &preferences)
 
static size_t getNumPostsynapticUpdateThreads (const SynapseGroupInternal &sg)
 
static size_t getNumSynapseDynamicsThreads (const SynapseGroupInternal &sg)
 
static size_t getNumConnectivityInitThreads (const SynapseGroupInternal &sg)
 
static size_t getNumInitThreads (const SynapseGroupInternal &sg)
 
static size_t getNumInitThreads (const CustomUpdateWUInternal &cg)
 
static void addPresynapticUpdateStrategy (PresynapticUpdateStrategySIMT::Base *strategy)
 Register a new presynaptic update strategy. More...
 
- Static Public Attributes inherited from CodeGenerator::BackendSIMT
static const char * KernelNames [KernelMax]
 
- Protected Member Functions inherited from CodeGenerator::BackendSIMT
void genNeuronPrevSpikeTimeUpdateKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, size_t &idStart) const
 
void genNeuronSpikeQueueUpdateKernel (CodeStream &os, const ModelSpecMerged &modelMerged, size_t &idStart) const
 
void genNeuronUpdateKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, size_t &idStart) const
 
void genSynapseDendriticDelayUpdateKernel (CodeStream &os, const ModelSpecMerged &modelMerged, size_t &idStart) const
 
void genPresynapticUpdateKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, size_t &idStart) const
 
void genPostsynapticUpdateKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, size_t &idStart) const
 
void genSynapseDynamicsKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, size_t &idStart) const
 
void genCustomUpdateKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, const std::string &updateGroup, size_t &idStart) const
 
void genCustomUpdateWUKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, const std::string &updateGroup, size_t &idStart) const
 
void genCustomTransposeUpdateWUKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, const std::string &updateGroup, size_t &idStart) const
 
void genInitializeKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, size_t &idStart) const
 
void genInitializeSparseKernel (CodeStream &os, const Substitutions &kernelSubs, const ModelSpecMerged &modelMerged, size_t numInitializeThreads, size_t &idStart) const
 
void addDeviceType (const std::string &type, size_t size, const std::string &maxValue="")
 Adds a type - both to backend base's list of sized types but also to device types set. More...
 
bool isDeviceType (const std::string &type) const
 Is type a a device only type? More...
 
size_t padKernelSize (size_t size, Kernel kernel) const
 Helper wrapper around padSize to pad size to a kernel size. More...
 
const KernelBlockSizegetKernelBlockSize () const
 Get kernel block size. More...
 
- Protected Member Functions inherited from CodeGenerator::BackendBase
void addType (const std::string &type, size_t size, const std::string &lowestValue="")
 
void setPointerBytes (size_t pointerBytes)
 
void genNeuronIndexCalculation (CodeStream &os, const NeuronUpdateGroupMerged &ng, unsigned int batchSize) const
 
void genSynapseIndexCalculation (CodeStream &os, const SynapseGroupMergedBase &sg, unsigned int batchSize) const
 
void genCustomUpdateIndexCalculation (CodeStream &os, const CustomUpdateGroupMerged &cu) const
 
std::vector< ReductionTargetgenInitReductionTargets (CodeStream &os, const CustomUpdateGroupMerged &cg, const std::string &idx="") const
 
std::vector< ReductionTargetgenInitReductionTargets (CodeStream &os, const CustomUpdateWUGroupMerged &cg, const std::string &idx="") const
 

Constructor & Destructor Documentation

◆ Backend()

CodeGenerator::CUDA::Backend::Backend ( const KernelBlockSize kernelBlockSizes,
const Preferences preferences,
const std::string &  scalarType,
int  device 
)

Member Function Documentation

◆ areSharedMemAtomicsSlow()

bool CodeGenerator::CUDA::Backend::areSharedMemAtomicsSlow ( ) const
overridevirtual

On some older devices, shared memory atomics are actually slower than global memory atomics so should be avoided.

Implements CodeGenerator::BackendSIMT.

◆ genAllocateMemPreamble()

void CodeGenerator::CUDA::Backend::genAllocateMemPreamble ( CodeStream os,
const ModelSpecMerged modelMerged,
const MemAlloc memAlloc 
) const
overridevirtual

Allocate memory is the first function in GeNN generated code called by usercode and it should only ever be called once. Therefore it's a good place for any global initialisation. This function generates a 'preamble' to this function.

Implements CodeGenerator::BackendBase.

◆ genCurrentSpikeLikeEventPull()

virtual void CodeGenerator::CUDA::Backend::genCurrentSpikeLikeEventPull ( CodeStream os,
const NeuronGroupInternal ng,
unsigned int  batchSize 
) const
inlineoverridevirtual

Generate code for pulling spike-like events emitted by a neuron group in the current timestep from the 'device'.

Implements CodeGenerator::BackendBase.

◆ genCurrentSpikeLikeEventPush()

virtual void CodeGenerator::CUDA::Backend::genCurrentSpikeLikeEventPush ( CodeStream os,
const NeuronGroupInternal ng,
unsigned int  batchSize 
) const
inlineoverridevirtual

Generate code for pushing spike-like events emitted by a neuron group in the current timestep to the 'device'.

Implements CodeGenerator::BackendBase.

◆ genCurrentTrueSpikePull()

virtual void CodeGenerator::CUDA::Backend::genCurrentTrueSpikePull ( CodeStream os,
const NeuronGroupInternal ng,
unsigned int  batchSize 
) const
inlineoverridevirtual

Generate code for pulling true spikes emitted by a neuron group in the current timestep from the 'device'.

Implements CodeGenerator::BackendBase.

◆ genCurrentTrueSpikePush()

virtual void CodeGenerator::CUDA::Backend::genCurrentTrueSpikePush ( CodeStream os,
const NeuronGroupInternal ng,
unsigned int  batchSize 
) const
inlineoverridevirtual

Generate code for pushing true spikes emitted by a neuron group in the current timestep to the 'device'.

Implements CodeGenerator::BackendBase.

◆ genCurrentVariablePull()

void CodeGenerator::CUDA::Backend::genCurrentVariablePull ( CodeStream os,
const NeuronGroupInternal ng,
const std::string &  type,
const std::string &  name,
VarLocation  loc,
unsigned int  batchSize 
) const
overridevirtual

Generate code for pulling a variable's value in the current timestep from the 'device'.

Implements CodeGenerator::BackendBase.

◆ genCurrentVariablePush()

void CodeGenerator::CUDA::Backend::genCurrentVariablePush ( CodeStream os,
const NeuronGroupInternal ng,
const std::string &  type,
const std::string &  name,
VarLocation  loc,
unsigned int  batchSize 
) const
overridevirtual

Generate code for pushing a variable's value in the current timestep to the 'device'.

Implements CodeGenerator::BackendBase.

◆ genCustomUpdate()

void CodeGenerator::CUDA::Backend::genCustomUpdate ( CodeStream os,
const ModelSpecMerged modelMerged,
HostHandler  preambleHandler,
HostHandler  pushEGPHandler 
) const
overridevirtual

Generate platform-specific functions to perform custom updates.

Parameters
osCodeStream to write function to
modelMergedmerged model to generate code for
preambleHandlercallback to write functions for pushing extra-global parameters
pushEGPHandlercallback to write required extra-global parameter pushing code to start of customUpdate function

Implements CodeGenerator::BackendBase.

◆ genDefinitionsInternalPreamble()

void CodeGenerator::CUDA::Backend::genDefinitionsInternalPreamble ( CodeStream os,
const ModelSpecMerged modelMerged 
) const
overridevirtual

Definitions internal is the internal header file for the generated code. This function generates a 'preamble' to this header file.

This will only be included by the platform-specific compiler used to build this backend so can include platform-specific types or headers

Implements CodeGenerator::BackendBase.

◆ genDefinitionsPreamble()

void CodeGenerator::CUDA::Backend::genDefinitionsPreamble ( CodeStream os,
const ModelSpecMerged modelMerged 
) const
overridevirtual

Definitions is the usercode-facing header file for the generated code. This function generates a 'preamble' to this header file.

This will be included from a standard C++ compiler so shouldn't include any platform-specific types or headers

Implements CodeGenerator::BackendBase.

◆ genExtraGlobalParamAllocation()

void CodeGenerator::CUDA::Backend::genExtraGlobalParamAllocation ( CodeStream os,
const std::string &  type,
const std::string &  name,
VarLocation  loc,
const std::string &  countVarName = "count",
const std::string &  prefix = "" 
) const
overridevirtual

◆ genExtraGlobalParamDefinition()

void CodeGenerator::CUDA::Backend::genExtraGlobalParamDefinition ( CodeStream definitions,
CodeStream definitionsInternal,
const std::string &  type,
const std::string &  name,
VarLocation  loc 
) const
overridevirtual

◆ genExtraGlobalParamImplementation()

void CodeGenerator::CUDA::Backend::genExtraGlobalParamImplementation ( CodeStream os,
const std::string &  type,
const std::string &  name,
VarLocation  loc 
) const
overridevirtual

◆ genExtraGlobalParamPull()

void CodeGenerator::CUDA::Backend::genExtraGlobalParamPull ( CodeStream os,
const std::string &  type,
const std::string &  name,
VarLocation  loc,
const std::string &  countVarName = "count",
const std::string &  prefix = "" 
) const
overridevirtual

◆ genExtraGlobalParamPush()

void CodeGenerator::CUDA::Backend::genExtraGlobalParamPush ( CodeStream os,
const std::string &  type,
const std::string &  name,
VarLocation  loc,
const std::string &  countVarName = "count",
const std::string &  prefix = "" 
) const
overridevirtual

◆ genFreeMemPreamble()

void CodeGenerator::CUDA::Backend::genFreeMemPreamble ( CodeStream os,
const ModelSpecMerged modelMerged 
) const
overridevirtual

Free memory is called by usercode to free all memory allocatd by GeNN and should only ever be called once. This function generates a 'preamble' to this function, for example to free backend-specific objects

Implements CodeGenerator::BackendBase.

◆ genGlobalDeviceRNG()

void CodeGenerator::CUDA::Backend::genGlobalDeviceRNG ( CodeStream definitions,
CodeStream definitionsInternal,
CodeStream runner,
CodeStream allocations,
CodeStream free,
MemAlloc memAlloc 
) const
overridevirtual

Generate a single RNG instance.

On single-threaded platforms this can be a standard RNG like M.T. but, on parallel platforms, it is likely to be a counter-based RNG

Implements CodeGenerator::BackendBase.

◆ genGlobalRNGSkipAhead()

void CodeGenerator::CUDA::Backend::genGlobalRNGSkipAhead ( CodeStream os,
Substitutions subs,
const std::string &  sequence,
const std::string &  name = "rng" 
) const
overridevirtual

Generate code to skip ahead local copy of global RNG.

Implements CodeGenerator::BackendSIMT.

◆ genInit()

void CodeGenerator::CUDA::Backend::genInit ( CodeStream os,
const ModelSpecMerged modelMerged,
HostHandler  preambleHandler,
HostHandler  initPushEGPHandler,
HostHandler  initSparsePushEGPHandler 
) const
overridevirtual

Generate platform-specific function to initialise model.

Parameters
osCodeStream to write function to
modelMergedmerged model to generate code for
preambleHandlercallback to write functions for pushing extra-global parameters
initPushEGPHandlercallback to write required extra-global parameter pushing code to start of initialize function
initSparsePushEGPHandlercallback to write required extra-global parameter pushing code to start of initializeSparse function

Implements CodeGenerator::BackendBase.

◆ genMakefileCompileRule()

void CodeGenerator::CUDA::Backend::genMakefileCompileRule ( std::ostream &  os) const
overridevirtual

The GNU make build system uses 'pattern rules' (https://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html) to build backend modules into objects. This function should generate a GNU make pattern rule capable of building each module (i.e. compiling .cc file $< into .o file $@).

Implements CodeGenerator::BackendBase.

◆ genMakefileLinkRule()

void CodeGenerator::CUDA::Backend::genMakefileLinkRule ( std::ostream &  os) const
overridevirtual

The GNU make build system will populate a variable called with a list of objects to link. This function should generate a GNU make rule to build these objects into a shared library.

Implements CodeGenerator::BackendBase.

◆ genMakefilePreamble()

void CodeGenerator::CUDA::Backend::genMakefilePreamble ( std::ostream &  os) const
overridevirtual

This function can be used to generate a preamble for the GNU makefile used to build.

Implements CodeGenerator::BackendBase.

◆ genMergedExtraGlobalParamPush()

void CodeGenerator::CUDA::Backend::genMergedExtraGlobalParamPush ( CodeStream os,
const std::string &  suffix,
size_t  mergedGroupIdx,
const std::string &  groupIdx,
const std::string &  fieldName,
const std::string &  egpName 
) const
overridevirtual

Generate code for pushing an updated EGP value into the merged group structure on 'device'.

Implements CodeGenerator::BackendBase.

◆ genMSBuildCompileModule()

void CodeGenerator::CUDA::Backend::genMSBuildCompileModule ( const std::string &  moduleName,
std::ostream &  os 
) const
overridevirtual

◆ genMSBuildConfigProperties()

void CodeGenerator::CUDA::Backend::genMSBuildConfigProperties ( std::ostream &  os) const
overridevirtual

In MSBuild, 'properties' are used to configure global project settings e.g. whether the MSBuild project builds a static or dynamic library This function can be used to add additional XML properties to this section.

see https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-properties for more information.

Implements CodeGenerator::BackendBase.

◆ genMSBuildImportProps()

void CodeGenerator::CUDA::Backend::genMSBuildImportProps ( std::ostream &  os) const
overridevirtual

◆ genMSBuildImportTarget()

void CodeGenerator::CUDA::Backend::genMSBuildImportTarget ( std::ostream &  os) const
overridevirtual

◆ genMSBuildItemDefinitions()

void CodeGenerator::CUDA::Backend::genMSBuildItemDefinitions ( std::ostream &  os) const
overridevirtual

In MSBuild, the 'item definitions' are used to override the default properties of 'items' such as <ClCompile> or <Link>. This function should generate XML to correctly configure the 'items' required to build the generated code, taking into account etc.

see https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-items#item-definitions for more information.

Implements CodeGenerator::BackendBase.

◆ genNeuronUpdate()

void CodeGenerator::CUDA::Backend::genNeuronUpdate ( CodeStream os,
const ModelSpecMerged modelMerged,
HostHandler  preambleHandler,
HostHandler  pushEGPHandler 
) const
overridevirtual

Generate platform-specific function to update the state of all neurons.

Parameters
osCodeStream to write function to
modelMergedmerged model to generate code for
preambleHandlercallback to write functions for pushing extra-global parameters
pushEGPHandlercallback to write required extra-global parameter pushing code to start of neuronUpdate function

Implements CodeGenerator::BackendBase.

◆ genPopulationRNG()

void CodeGenerator::CUDA::Backend::genPopulationRNG ( CodeStream definitions,
CodeStream definitionsInternal,
CodeStream runner,
CodeStream allocations,
CodeStream free,
const std::string &  name,
size_t  count,
MemAlloc memAlloc 
) const
overridevirtual

Generate an RNG with a state per population member.

Implements CodeGenerator::BackendBase.

◆ genPopulationRNGInit()

void CodeGenerator::CUDA::Backend::genPopulationRNGInit ( CodeStream os,
const std::string &  globalRNG,
const std::string &  seed,
const std::string &  sequence 
) const
overridevirtual

For SIMT backends which initialize RNGs on device, initialize population RNG with specified seed and sequence.

Implements CodeGenerator::BackendSIMT.

◆ genPopulationRNGPostamble()

void CodeGenerator::CUDA::Backend::genPopulationRNGPostamble ( CodeStream os,
const std::string &  globalRNG 
) const
overridevirtual

If required, generate a postamble for population RNG.

For example, in OpenCL, this is used to write local RNG state back to global memory

Implements CodeGenerator::BackendSIMT.

◆ genPopulationRNGPreamble()

void CodeGenerator::CUDA::Backend::genPopulationRNGPreamble ( CodeStream os,
Substitutions subs,
const std::string &  globalRNG,
const std::string &  name = "rng" 
) const
overridevirtual

Generate a preamble to add substitution name for population RNG.

Implements CodeGenerator::BackendSIMT.

◆ genReturnFreeDeviceMemoryBytes()

void CodeGenerator::CUDA::Backend::genReturnFreeDeviceMemoryBytes ( CodeStream os) const
overridevirtual

Generate code to return amount of free 'device' memory in bytes.

Implements CodeGenerator::BackendBase.

◆ genRunnerPreamble()

void CodeGenerator::CUDA::Backend::genRunnerPreamble ( CodeStream os,
const ModelSpecMerged modelMerged,
const MemAlloc memAlloc 
) const
overridevirtual

◆ genSharedMemBarrier()

void CodeGenerator::CUDA::Backend::genSharedMemBarrier ( CodeStream os) const
overridevirtual

Generate a shared memory barrier.

Implements CodeGenerator::BackendSIMT.

◆ genStepTimeFinalisePreamble()

void CodeGenerator::CUDA::Backend::genStepTimeFinalisePreamble ( CodeStream os,
const ModelSpecMerged modelMerged 
) const
overridevirtual

After all timestep logic is complete.

Implements CodeGenerator::BackendBase.

◆ genSynapseUpdate()

void CodeGenerator::CUDA::Backend::genSynapseUpdate ( CodeStream os,
const ModelSpecMerged modelMerged,
HostHandler  preambleHandler,
HostHandler  pushEGPHandler 
) const
overridevirtual

Generate platform-specific function to update the state of all synapses.

Parameters
osCodeStream to write function to
modelMergedmerged model to generate code for
preambleHandlercallback to write functions for pushing extra-global parameters
pushEGPHandlercallback to write required extra-global parameter pushing code to start of synapseUpdate function

Implements CodeGenerator::BackendBase.

◆ genTimer()

void CodeGenerator::CUDA::Backend::genTimer ( CodeStream definitions,
CodeStream definitionsInternal,
CodeStream runner,
CodeStream allocations,
CodeStream free,
CodeStream stepTimeFinalise,
const std::string &  name,
bool  updateInStepTime 
) const
overridevirtual

◆ genVariableAllocation()

void CodeGenerator::CUDA::Backend::genVariableAllocation ( CodeStream os,
const std::string &  type,
const std::string &  name,
VarLocation  loc,
size_t  count,
MemAlloc memAlloc 
) const
overridevirtual

◆ genVariableDefinition()

void CodeGenerator::CUDA::Backend::genVariableDefinition ( CodeStream definitions,
CodeStream definitionsInternal,
const std::string &  type,
const std::string &  name,
VarLocation  loc 
) const
overridevirtual

◆ genVariableFree()

void CodeGenerator::CUDA::Backend::genVariableFree ( CodeStream os,
const std::string &  name,
VarLocation  loc 
) const
overridevirtual

◆ genVariableImplementation()

void CodeGenerator::CUDA::Backend::genVariableImplementation ( CodeStream os,
const std::string &  type,
const std::string &  name,
VarLocation  loc 
) const
overridevirtual

◆ genVariablePull()

void CodeGenerator::CUDA::Backend::genVariablePull ( CodeStream os,
const std::string &  type,
const std::string &  name,
VarLocation  loc,
size_t  count 
) const
overridevirtual

Generate code for pulling a variable from the 'device'.

Implements CodeGenerator::BackendBase.

◆ genVariablePush()

void CodeGenerator::CUDA::Backend::genVariablePush ( CodeStream os,
const std::string &  type,
const std::string &  name,
VarLocation  loc,
bool  autoInitialized,
size_t  count 
) const
overridevirtual

Generate code for pushing a variable to the 'device'.

Implements CodeGenerator::BackendBase.

◆ getAllocateMemParams()

std::string CodeGenerator::CUDA::Backend::getAllocateMemParams ( const ModelSpecMerged ) const
overridevirtual

Get backend-specific allocate memory parameters.

Reimplemented from CodeGenerator::BackendBase.

◆ getAtomic()

std::string CodeGenerator::CUDA::Backend::getAtomic ( const std::string &  type,
AtomicOperation  op = AtomicOperation::ADD,
AtomicMemSpace  memSpace = AtomicMemSpace::GLOBAL 
) const
overridevirtual

Get name of atomic operation.

Implements CodeGenerator::BackendSIMT.

◆ getBlockID()

std::string CodeGenerator::CUDA::Backend::getBlockID ( unsigned int  axis = 0) const
overridevirtual

Get the ID of the current thread block.

Implements CodeGenerator::BackendSIMT.

◆ getChosenCUDADevice()

const cudaDeviceProp& CodeGenerator::CUDA::Backend::getChosenCUDADevice ( ) const
inline

◆ getChosenDeviceID()

int CodeGenerator::CUDA::Backend::getChosenDeviceID ( ) const
inline

◆ getCLZ()

virtual std::string CodeGenerator::CUDA::Backend::getCLZ ( ) const
inlineoverridevirtual

Get the name of the count-leading-zeros function.

Implements CodeGenerator::BackendSIMT.

◆ getDeviceMemoryBytes()

virtual size_t CodeGenerator::CUDA::Backend::getDeviceMemoryBytes ( ) const
inlineoverridevirtual

How many bytes of memory does 'device' have.

Implements CodeGenerator::BackendBase.

◆ getHashDigest()

boost::uuids::detail::sha1::digest_type CodeGenerator::CUDA::Backend::getHashDigest ( ) const
overridevirtual

Get hash digest of this backends identification and the preferences it has been configured with.

Implements CodeGenerator::BackendBase.

◆ getMergedGroupFieldHostType()

std::string CodeGenerator::CUDA::Backend::getMergedGroupFieldHostType ( const std::string &  type) const
overridevirtual

When generating function calls to push to merged groups, backend without equivalent of Unified Virtual Addressing e.g. OpenCL 1.2 may use different types on host.

Implements CodeGenerator::BackendBase.

◆ getMergedGroupMemorySpaces()

Backend::MemorySpaces CodeGenerator::CUDA::Backend::getMergedGroupMemorySpaces ( const ModelSpecMerged modelMerged) const
overridevirtual

Some backends will have additional small, fast, memory spaces for read-only data which might Be well-suited to storing merged group structs. This method returns the prefix required to Place arrays in these and their size in preferential order

Implements CodeGenerator::BackendBase.

◆ getMergedGroupSimRNGType()

virtual std::string CodeGenerator::CUDA::Backend::getMergedGroupSimRNGType ( ) const
inlineoverridevirtual

When generating merged structures what type to use for simulation RNGs.

Implements CodeGenerator::BackendBase.

◆ getNVCCFlags()

std::string CodeGenerator::CUDA::Backend::getNVCCFlags ( ) const

◆ getRuntimeVersion()

int CodeGenerator::CUDA::Backend::getRuntimeVersion ( ) const
inline

◆ getSharedPrefix()

virtual std::string CodeGenerator::CUDA::Backend::getSharedPrefix ( ) const
inlineoverridevirtual

Get the prefix to use for shared memory variables.

Implements CodeGenerator::BackendSIMT.

◆ getThreadID()

std::string CodeGenerator::CUDA::Backend::getThreadID ( unsigned int  axis = 0) const
overridevirtual

Get the ID of the current thread within the threadblock.

Implements CodeGenerator::BackendSIMT.

◆ isHostReductionRequired()

virtual bool CodeGenerator::CUDA::Backend::isHostReductionRequired ( ) const
inlineoverridevirtual

Backends which support batch-parallelism might require an additional host reduction phase after reduction kernels.

Implements CodeGenerator::BackendBase.

◆ isPopulationRNGInitialisedOnDevice()

virtual bool CodeGenerator::CUDA::Backend::isPopulationRNGInitialisedOnDevice ( ) const
inlineoverridevirtual

Different backends seed RNGs in different ways. Does this one initialise population RNGS on device?

Implements CodeGenerator::BackendBase.

◆ supportsNamespace()

virtual bool CodeGenerator::CUDA::Backend::supportsNamespace ( ) const
inlineoverridevirtual

Does this backend support namespaces i.e. can C++ implementation of support functions be used.

Implements CodeGenerator::BackendBase.


The documentation for this class was generated from the following files: