GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
CodeGenerator::BackendSIMT Class Referenceabstract

Base class for Single Instruction Multiple Thread style backends. More...

#include <backendSIMT.h>

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

Public Types

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...
 

Public Member Functions

 BackendSIMT (const KernelBlockSize &kernelBlockSizes, const PreferencesBase &preferences, const std::string &scalarType)
 
virtual bool areSharedMemAtomicsSlow () const =0
 On some older devices, shared memory atomics are actually slower than global memory atomics so should be avoided. More...
 
virtual std::string getSharedPrefix () const =0
 Get the prefix to use for shared memory variables. More...
 
virtual std::string getThreadID (unsigned int axis=0) const =0
 Get the ID of the current thread within the threadblock. More...
 
virtual std::string getBlockID (unsigned int axis=0) const =0
 Get the ID of the current thread block. More...
 
virtual std::string getCLZ () const =0
 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 =0
 Get name of atomic operation. More...
 
virtual void genSharedMemBarrier (CodeStream &os) const =0
 Generate a shared memory barrier. More...
 
virtual void genPopulationRNGInit (CodeStream &os, const std::string &globalRNG, const std::string &seed, const std::string &sequence) const =0
 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 =0
 Generate a preamble to add substitution name for population RNG. More...
 
virtual void genPopulationRNGPostamble (CodeStream &os, const std::string &globalRNG) const =0
 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 =0
 Generate code to skip ahead local copy of global RNG. More...
 
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 void genNeuronUpdate (CodeStream &os, const ModelSpecMerged &modelMerged, HostHandler preambleHandler, HostHandler pushEGPHandler) const =0
 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 =0
 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 =0
 Generate platform-specific functions to perform custom updates. More...
 
virtual void genInit (CodeStream &os, const ModelSpecMerged &modelMerged, HostHandler preambleHandler, HostHandler initPushEGPHandler, HostHandler initSparsePushEGPHandler) const =0
 Generate platform-specific function to initialise model. More...
 
virtual void genDefinitionsPreamble (CodeStream &os, const ModelSpecMerged &modelMerged) const =0
 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 =0
 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 =0
 
virtual void genAllocateMemPreamble (CodeStream &os, const ModelSpecMerged &modelMerged, const MemAlloc &memAlloc) const =0
 
virtual void genFreeMemPreamble (CodeStream &os, const ModelSpecMerged &modelMerged) const =0
 
virtual void genStepTimeFinalisePreamble (CodeStream &os, const ModelSpecMerged &modelMerged) const =0
 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 =0
 
virtual void genVariableImplementation (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc) const =0
 
virtual void genVariableAllocation (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc, size_t count, MemAlloc &memAlloc) const =0
 
virtual void genVariableFree (CodeStream &os, const std::string &name, VarLocation loc) const =0
 
virtual void genExtraGlobalParamDefinition (CodeStream &definitions, CodeStream &definitionsInternal, const std::string &type, const std::string &name, VarLocation loc) const =0
 
virtual void genExtraGlobalParamImplementation (CodeStream &os, const std::string &type, const std::string &name, VarLocation loc) const =0
 
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 =0
 
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 =0
 
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 =0
 
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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 
virtual void genReturnFreeDeviceMemoryBytes (CodeStream &os) const =0
 Generate code to return amount of free 'device' memory in bytes. More...
 
virtual void genMakefilePreamble (std::ostream &os) const =0
 This function can be used to generate a preamble for the GNU makefile used to build. More...
 
virtual void genMakefileLinkRule (std::ostream &os) const =0
 
virtual void genMakefileCompileRule (std::ostream &os) const =0
 
virtual void genMSBuildConfigProperties (std::ostream &os) const =0
 
virtual void genMSBuildImportProps (std::ostream &os) const =0
 
virtual void genMSBuildItemDefinitions (std::ostream &os) const =0
 
virtual void genMSBuildCompileModule (const std::string &moduleName, std::ostream &os) const =0
 
virtual void genMSBuildImportTarget (std::ostream &os) const =0
 
virtual std::string getAllocateMemParams (const ModelSpecMerged &) const
 Get backend-specific allocate memory parameters. More...
 
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...
 
virtual bool isPopulationRNGInitialisedOnDevice () const =0
 Different backends seed RNGs in different ways. Does this one initialise population RNGS on device? More...
 
virtual bool isHostReductionRequired () const =0
 Backends which support batch-parallelism might require an additional host reduction phase after reduction kernels. More...
 
virtual size_t getDeviceMemoryBytes () const =0
 How many bytes of memory does 'device' have. More...
 
virtual MemorySpaces getMergedGroupMemorySpaces (const ModelSpecMerged &modelMerged) const =0
 
virtual bool supportsNamespace () const =0
 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 =0
 Get hash digest of this backends identification and the preferences it has been configured with. 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
 

Static Public Member Functions

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

static const char * KernelNames [KernelMax]
 

Protected Member Functions

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
 

Detailed Description

Base class for Single Instruction Multiple Thread style backends.

CUDA terminology is used throughout i.e. thread blocks and shared memory

Member Enumeration Documentation

◆ AtomicMemSpace

What memory space atomic operation is required.

Enumerator
GLOBAL 
SHARED 

◆ AtomicOperation

What atomic operation is required.

Enumerator
ADD 
OR 

Constructor & Destructor Documentation

◆ BackendSIMT()

CodeGenerator::BackendSIMT::BackendSIMT ( const KernelBlockSize kernelBlockSizes,
const PreferencesBase preferences,
const std::string &  scalarType 
)
inline

Member Function Documentation

◆ addDeviceType()

void CodeGenerator::BackendSIMT::addDeviceType ( const std::string &  type,
size_t  size,
const std::string &  maxValue = "" 
)
protected

Adds a type - both to backend base's list of sized types but also to device types set.

◆ addPresynapticUpdateStrategy()

void CodeGenerator::BackendSIMT::addPresynapticUpdateStrategy ( PresynapticUpdateStrategySIMT::Base strategy)
static

Register a new presynaptic update strategy.

This function should be called with strategies in ascending order of preference

◆ areSharedMemAtomicsSlow()

virtual bool CodeGenerator::BackendSIMT::areSharedMemAtomicsSlow ( ) const
pure virtual

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

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ genCustomTransposeUpdateWUKernel()

void CodeGenerator::BackendSIMT::genCustomTransposeUpdateWUKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
const std::string &  updateGroup,
size_t &  idStart 
) const
protected

◆ genCustomUpdateKernel()

void CodeGenerator::BackendSIMT::genCustomUpdateKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
const std::string &  updateGroup,
size_t &  idStart 
) const
protected

◆ genCustomUpdateWUKernel()

void CodeGenerator::BackendSIMT::genCustomUpdateWUKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
const std::string &  updateGroup,
size_t &  idStart 
) const
protected

◆ genDenseSynapseVariableRowInit()

virtual void CodeGenerator::BackendSIMT::genDenseSynapseVariableRowInit ( CodeStream os,
const Substitutions kernelSubs,
Handler  handler 
) const
inlinefinalvirtual

◆ genGlobalRNGSkipAhead()

virtual void CodeGenerator::BackendSIMT::genGlobalRNGSkipAhead ( CodeStream os,
Substitutions subs,
const std::string &  sequence,
const std::string &  name = "rng" 
) const
pure virtual

Generate code to skip ahead local copy of global RNG.

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ genInitializeKernel()

void CodeGenerator::BackendSIMT::genInitializeKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
size_t &  idStart 
) const
protected

◆ genInitializeSparseKernel()

void CodeGenerator::BackendSIMT::genInitializeSparseKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
size_t  numInitializeThreads,
size_t &  idStart 
) const
protected

◆ genKernelCustomUpdateVariableInit()

void CodeGenerator::BackendSIMT::genKernelCustomUpdateVariableInit ( CodeStream os,
const CustomWUUpdateInitGroupMerged cu,
const Substitutions kernelSubs,
Handler  handler 
) const
finalvirtual

◆ genKernelSynapseVariableInit()

void CodeGenerator::BackendSIMT::genKernelSynapseVariableInit ( CodeStream os,
const SynapseInitGroupMerged sg,
const Substitutions kernelSubs,
Handler  handler 
) const
finalvirtual

◆ genNeuronPrevSpikeTimeUpdateKernel()

void CodeGenerator::BackendSIMT::genNeuronPrevSpikeTimeUpdateKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
size_t &  idStart 
) const
protected

◆ genNeuronSpikeQueueUpdateKernel()

void CodeGenerator::BackendSIMT::genNeuronSpikeQueueUpdateKernel ( CodeStream os,
const ModelSpecMerged modelMerged,
size_t &  idStart 
) const
protected

◆ genNeuronUpdateKernel()

void CodeGenerator::BackendSIMT::genNeuronUpdateKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
size_t &  idStart 
) const
protected

◆ genPopulationRNGInit()

virtual void CodeGenerator::BackendSIMT::genPopulationRNGInit ( CodeStream os,
const std::string &  globalRNG,
const std::string &  seed,
const std::string &  sequence 
) const
pure virtual

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

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ genPopulationRNGPostamble()

virtual void CodeGenerator::BackendSIMT::genPopulationRNGPostamble ( CodeStream os,
const std::string &  globalRNG 
) const
pure virtual

If required, generate a postamble for population RNG.

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

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ genPopulationRNGPreamble()

virtual void CodeGenerator::BackendSIMT::genPopulationRNGPreamble ( CodeStream os,
Substitutions subs,
const std::string &  globalRNG,
const std::string &  name = "rng" 
) const
pure virtual

Generate a preamble to add substitution name for population RNG.

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ genPopVariableInit()

void CodeGenerator::BackendSIMT::genPopVariableInit ( CodeStream os,
const Substitutions kernelSubs,
Handler  handler 
) const
finalvirtual

◆ genPostsynapticUpdateKernel()

void CodeGenerator::BackendSIMT::genPostsynapticUpdateKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
size_t &  idStart 
) const
protected

◆ genPresynapticUpdateKernel()

void CodeGenerator::BackendSIMT::genPresynapticUpdateKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
size_t &  idStart 
) const
protected

◆ genSharedMemBarrier()

virtual void CodeGenerator::BackendSIMT::genSharedMemBarrier ( CodeStream os) const
pure virtual

Generate a shared memory barrier.

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ genSparseSynapseVariableRowInit()

virtual void CodeGenerator::BackendSIMT::genSparseSynapseVariableRowInit ( CodeStream os,
const Substitutions kernelSubs,
Handler  handler 
) const
inlinefinalvirtual

◆ genSynapseDendriticDelayUpdateKernel()

void CodeGenerator::BackendSIMT::genSynapseDendriticDelayUpdateKernel ( CodeStream os,
const ModelSpecMerged modelMerged,
size_t &  idStart 
) const
protected

◆ genSynapseDynamicsKernel()

void CodeGenerator::BackendSIMT::genSynapseDynamicsKernel ( CodeStream os,
const Substitutions kernelSubs,
const ModelSpecMerged modelMerged,
size_t &  idStart 
) const
protected

◆ genVariableInit()

void CodeGenerator::BackendSIMT::genVariableInit ( CodeStream os,
const std::string &  count,
const std::string &  indexVarName,
const Substitutions kernelSubs,
Handler  handler 
) const
finalvirtual

◆ getAtomic()

virtual std::string CodeGenerator::BackendSIMT::getAtomic ( const std::string &  type,
AtomicOperation  op = AtomicOperation::ADD,
AtomicMemSpace  memSpace = AtomicMemSpace::GLOBAL 
) const
pure virtual

Get name of atomic operation.

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ getBlockID()

virtual std::string CodeGenerator::BackendSIMT::getBlockID ( unsigned int  axis = 0) const
pure virtual

Get the ID of the current thread block.

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ getCLZ()

virtual std::string CodeGenerator::BackendSIMT::getCLZ ( ) const
pure virtual

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

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ getDeviceVarPrefix()

virtual std::string CodeGenerator::BackendSIMT::getDeviceVarPrefix ( ) const
inlinefinalvirtual

When backends require separate 'device' and 'host' versions of variables, they are identified with a prefix. This function returns the device prefix so it can be used in otherwise platform-independent code.

Reimplemented from CodeGenerator::BackendBase.

◆ getKernelBlockSize() [1/2]

size_t CodeGenerator::BackendSIMT::getKernelBlockSize ( Kernel  kernel) const
inline

◆ getKernelBlockSize() [2/2]

const KernelBlockSize& CodeGenerator::BackendSIMT::getKernelBlockSize ( ) const
inlineprotected

Get kernel block size.

◆ getNumConnectivityInitThreads()

size_t CodeGenerator::BackendSIMT::getNumConnectivityInitThreads ( const SynapseGroupInternal sg)
static

◆ getNumInitialisationRNGStreams()

size_t CodeGenerator::BackendSIMT::getNumInitialisationRNGStreams ( const ModelSpecMerged modelMerged) const

Get total number of RNG streams potentially used to initialise model.

NOTE because RNG supports 2^64 streams, we are overly conservative

◆ getNumInitThreads() [1/2]

size_t CodeGenerator::BackendSIMT::getNumInitThreads ( const SynapseGroupInternal sg)
static

◆ getNumInitThreads() [2/2]

size_t CodeGenerator::BackendSIMT::getNumInitThreads ( const CustomUpdateWUInternal cg)
static

◆ getNumPostsynapticUpdateThreads()

size_t CodeGenerator::BackendSIMT::getNumPostsynapticUpdateThreads ( const SynapseGroupInternal sg)
static

◆ getNumPresynapticUpdateThreads()

size_t CodeGenerator::BackendSIMT::getNumPresynapticUpdateThreads ( const SynapseGroupInternal sg,
const PreferencesBase preferences 
)
static

◆ getNumSynapseDynamicsThreads()

size_t CodeGenerator::BackendSIMT::getNumSynapseDynamicsThreads ( const SynapseGroupInternal sg)
static

◆ getPaddedNumCustomUpdateThreads()

size_t CodeGenerator::BackendSIMT::getPaddedNumCustomUpdateThreads ( const CustomUpdateInternal cg,
unsigned int  batchSize 
) const

◆ getPaddedNumCustomUpdateTransposeWUThreads()

size_t CodeGenerator::BackendSIMT::getPaddedNumCustomUpdateTransposeWUThreads ( const CustomUpdateWUInternal cg,
unsigned int  batchSize 
) const

◆ getPaddedNumCustomUpdateWUThreads()

size_t CodeGenerator::BackendSIMT::getPaddedNumCustomUpdateWUThreads ( const CustomUpdateWUInternal cg,
unsigned int  batchSize 
) const

◆ getSharedPrefix()

virtual std::string CodeGenerator::BackendSIMT::getSharedPrefix ( ) const
pure virtual

Get the prefix to use for shared memory variables.

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ getSynapticMatrixRowStride()

size_t CodeGenerator::BackendSIMT::getSynapticMatrixRowStride ( const SynapseGroupInternal sg) const
finalvirtual

Gets the stride used to access synaptic matrix rows, taking into account sparse data structure, padding etc.

Implements CodeGenerator::BackendBase.

◆ getThreadID()

virtual std::string CodeGenerator::BackendSIMT::getThreadID ( unsigned int  axis = 0) const
pure virtual

Get the ID of the current thread within the threadblock.

Implemented in CodeGenerator::CUDA::Backend, and CodeGenerator::OpenCL::Backend.

◆ isDeviceScalarRequired()

virtual bool CodeGenerator::BackendSIMT::isDeviceScalarRequired ( ) const
inlinefinalvirtual

Should 'scalar' variables be implemented on device or can host variables be used directly?

Implements CodeGenerator::BackendBase.

◆ isDeviceType()

bool CodeGenerator::BackendSIMT::isDeviceType ( const std::string &  type) const
protected

Is type a a device only type?

◆ isGlobalDeviceRNGRequired()

bool CodeGenerator::BackendSIMT::isGlobalDeviceRNGRequired ( const ModelSpecMerged modelMerged) const
finalvirtual

Different backends use different RNGs for different things. Does this one require a global device RNG for the specified model?

Implements CodeGenerator::BackendBase.

◆ isGlobalHostRNGRequired()

bool CodeGenerator::BackendSIMT::isGlobalHostRNGRequired ( const ModelSpecMerged modelMerged) const
finalvirtual

Different backends use different RNGs for different things. Does this one require a global host RNG for the specified model?

Implements CodeGenerator::BackendBase.

◆ isPopulationRNGRequired()

virtual bool CodeGenerator::BackendSIMT::isPopulationRNGRequired ( ) const
inlinefinalvirtual

Different backends use different RNGs for different things. Does this one require population RNGs?

Implements CodeGenerator::BackendBase.

◆ isPostsynapticRemapRequired()

virtual bool CodeGenerator::BackendSIMT::isPostsynapticRemapRequired ( ) const
inlinefinalvirtual

Different backends may implement synaptic plasticity differently. Does this one require a postsynaptic remapping data structure?

Implements CodeGenerator::BackendBase.

◆ padKernelSize()

size_t CodeGenerator::BackendSIMT::padKernelSize ( size_t  size,
Kernel  kernel 
) const
protected

Helper wrapper around padSize to pad size to a kernel size.

Member Data Documentation

◆ KernelNames

const char * CodeGenerator::BackendSIMT::KernelNames
static
Initial value:
= {
"updateNeuronsKernel",
"updatePresynapticKernel",
"updatePostsynapticKernel",
"updateSynapseDynamicsKernel",
"initializeKernel",
"initializeSparseKernel",
"neuronSpikeQueueUpdateKernel",
"neuronPrevSpikeTimeUpdateKernel",
"synapseDendriticDelayUpdateKernel",
"customUpdate",
"customTransposeUpdate"}

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