GeNN
4.9.0
GPU enhanced Neuronal Networks (GeNN)
|
Helper class for generating code - automatically inserts brackets, indents etc. More...
Namespaces | |
CUDA | |
OpenCL | |
PresynapticUpdateStrategySIMT | |
SingleThreadedCPU | |
Typedefs | |
using | KernelBlockSize = std::array< size_t, KernelMax > |
Array of block sizes for each kernel. More... | |
Enumerations | |
enum | Kernel { KernelNeuronUpdate, KernelPresynapticUpdate, KernelPostsynapticUpdate, KernelSynapseDynamicsUpdate, KernelInitialize, KernelInitializeSparse, KernelNeuronSpikeQueueUpdate, KernelNeuronPrevSpikeTimeUpdate, KernelSynapseDendriticDelayUpdate, KernelCustomUpdate, KernelCustomTransposeUpdate, KernelMax } |
Kernels generated by SIMT backends. More... | |
Functions | |
std::ostream & | operator<< (std::ostream &out, const MemAlloc &m) |
std::istream & | operator>> (std::istream &in, MemAlloc &m) |
GENN_EXPORT void | substitute (std::string &s, const std::string &trg, const std::string &rep) |
Tool for substituting strings in the neuron code strings or other templates. More... | |
GENN_EXPORT bool | regexVarSubstitute (std::string &s, const std::string &trg, const std::string &rep) |
Tool for substituting variable names in the neuron code strings or other templates using regular expressions. More... | |
GENN_EXPORT bool | regexFuncSubstitute (std::string &s, const std::string &trg, const std::string &rep) |
Tool for substituting function names in the neuron code strings or other templates using regular expressions. More... | |
GENN_EXPORT void | functionSubstitute (std::string &code, const std::string &funcName, unsigned int numParams, const std::string &replaceFuncTemplate) |
This function substitutes function calls in the form: More... | |
size_t | ceilDivide (size_t numerator, size_t denominator) |
Divide two integers, rounding up i.e. effectively taking ceil. More... | |
size_t | padSize (size_t size, size_t blockSize) |
Pad an integer to a multiple of another. More... | |
GENN_EXPORT void | genTypeRange (CodeStream &os, const std::string &precision, const std::string &prefix) |
GENN_EXPORT std::string | ensureFtype (const std::string &oldcode, const std::string &type) |
This function implements a parser that converts any floating point constant in a code snippet to a floating point constant with an explicit precision (by appending "f" or removing it). More... | |
GENN_EXPORT std::string | getReductionInitialValue (const BackendBase &backend, VarAccessMode access, const std::string &type) |
Get the initial value to start reduction operations from. More... | |
GENN_EXPORT std::string | getReductionOperation (const std::string &reduction, const std::string &value, VarAccessMode access, const std::string &type) |
Generate a reduction operation to reduce value into reduction. More... | |
GENN_EXPORT void | checkUnreplacedVariables (const std::string &code, const std::string &codeName) |
This function checks for unknown variable definitions and returns a gennError if any are found. More... | |
GENN_EXPORT std::string | disambiguateNamespaceFunction (const std::string supportCode, const std::string code, std::string namespaceName) |
This function substitutes function names in a code with namespace as prefix of the function name for backends that do not support namespaces by checking that the function indeed exists in the support code and returns the substituted code. More... | |
template<typename P , typename D , typename V , typename S > | |
void | neuronSubstitutionsInSynapticCode (CodeGenerator::Substitutions &substitutions, const NeuronGroupInternal *archetypeNG, const std::string &delayOffset, const std::string &sourceSuffix, const std::string &destSuffix, const std::string &varPrefix, const std::string &varSuffix, bool useLocalNeuronVars, P isParamHeterogeneousFn, D isDerivedParamHeterogeneousFn, V getVarIndexFn, S getPrevSpikeTimeIndexFn) |
Function for performing the code and value substitutions necessary to insert neuron related variables, parameters, and extraGlobal parameters into synaptic code. More... | |
template<typename G , typename K > | |
bool | isKernelSizeHeterogeneous (const G *group, size_t dimensionIndex, K getKernelSizeFn) |
template<typename G , typename K > | |
std::string | getKernelSize (const G *group, size_t dimensionIndex, K getKernelSizeFn) |
template<typename G , typename K > | |
void | genKernelIndex (const G *group, std::ostream &os, const CodeGenerator::Substitutions &subs, K getKernelSizeFn) |
GENN_EXPORT std::ostream & | operator<< (std::ostream &s, const CodeStream::OB &ob) |
GENN_EXPORT std::ostream & | operator<< (std::ostream &s, const CodeStream::CB &cb) |
GENN_EXPORT void | generateMakefile (std::ostream &os, const BackendBase &backend, const std::vector< std::string > &moduleNames) |
GENN_EXPORT std::pair< std::vector< std::string >, MemAlloc > | generateAll (const ModelSpecInternal &model, const BackendBase &backend, const filesystem::path &sharePath, const filesystem::path &outputPath, bool forceRebuild=false) |
GENN_EXPORT void | generateNeuronUpdate (const filesystem::path &outputPath, const ModelSpecMerged &modelMerged, const BackendBase &backend, const std::string &suffix="") |
GENN_EXPORT void | generateCustomUpdate (const filesystem::path &outputPath, const ModelSpecMerged &modelMerged, const BackendBase &backend, const std::string &suffix="") |
GENN_EXPORT void | generateSynapseUpdate (const filesystem::path &outputPath, const ModelSpecMerged &modelMerged, const BackendBase &backend, const std::string &suffix="") |
GENN_EXPORT void | generateInit (const filesystem::path &outputPath, const ModelSpecMerged &modelMerged, const BackendBase &backend, const std::string &suffix="") |
GENN_EXPORT void | generateMSBuild (std::ostream &os, const ModelSpecInternal &model, const BackendBase &backend, const std::string &projectGUID, const std::vector< std::string > &moduleNames) |
GENN_EXPORT MemAlloc | generateRunner (const filesystem::path &outputPath, const ModelSpecMerged &modelMerged, const BackendBase &backend, const std::string &suffix="") |
GENN_EXPORT void | generateSupportCode (const filesystem::path &outputPath, const ModelSpecMerged &modelMerged, const std::string &suffix="") |
Helper class for generating code - automatically inserts brackets, indents etc.
Very thin wrapper around a number of groups which have been merged together.
Based heavily on: https://stackoverflow.com/questions/15053753/writing-a-manipulator-for-a-custom-stream-class
using CodeGenerator::KernelBlockSize = typedef std::array<size_t, KernelMax> |
Array of block sizes for each kernel.
Kernels generated by SIMT backends.
|
inline |
Divide two integers, rounding up i.e. effectively taking ceil.
void CodeGenerator::checkUnreplacedVariables | ( | const std::string & | code, |
const std::string & | codeName | ||
) |
This function checks for unknown variable definitions and returns a gennError if any are found.
std::string CodeGenerator::disambiguateNamespaceFunction | ( | const std::string | supportCode, |
const std::string | code, | ||
std::string | namespaceName | ||
) |
This function substitutes function names in a code with namespace as prefix of the function name for backends that do not support namespaces by checking that the function indeed exists in the support code and returns the substituted code.
std::string CodeGenerator::ensureFtype | ( | const std::string & | oldcode, |
const std::string & | type | ||
) |
This function implements a parser that converts any floating point constant in a code snippet to a floating point constant with an explicit precision (by appending "f" or removing it).
void CodeGenerator::functionSubstitute | ( | std::string & | code, |
const std::string & | funcName, | ||
unsigned int | numParams, | ||
const std::string & | replaceFuncTemplate | ||
) |
This function substitutes function calls in the form:
$(functionName, parameter1, param2Function(0.12, "string"))
with replacement templates in the form:
actualFunction(CONSTANT, $(0), $(1))
std::pair< std::vector< std::string >, MemAlloc > CodeGenerator::generateAll | ( | const ModelSpecInternal & | model, |
const BackendBase & | backend, | ||
const filesystem::path & | sharePath, | ||
const filesystem::path & | outputPath, | ||
bool | forceRebuild = false |
||
) |
void CodeGenerator::generateCustomUpdate | ( | const filesystem::path & | outputPath, |
const ModelSpecMerged & | modelMerged, | ||
const BackendBase & | backend, | ||
const std::string & | suffix = "" |
||
) |
void CodeGenerator::generateInit | ( | const filesystem::path & | outputPath, |
const ModelSpecMerged & | modelMerged, | ||
const BackendBase & | backend, | ||
const std::string & | suffix = "" |
||
) |
void CodeGenerator::generateMakefile | ( | std::ostream & | os, |
const BackendBase & | backend, | ||
const std::vector< std::string > & | moduleNames | ||
) |
void CodeGenerator::generateMSBuild | ( | std::ostream & | os, |
const ModelSpecInternal & | model, | ||
const BackendBase & | backend, | ||
const std::string & | projectGUID, | ||
const std::vector< std::string > & | moduleNames | ||
) |
void CodeGenerator::generateNeuronUpdate | ( | const filesystem::path & | outputPath, |
const ModelSpecMerged & | modelMerged, | ||
const BackendBase & | backend, | ||
const std::string & | suffix = "" |
||
) |
MemAlloc CodeGenerator::generateRunner | ( | const filesystem::path & | outputPath, |
const ModelSpecMerged & | modelMerged, | ||
const BackendBase & | backend, | ||
const std::string & | suffix = "" |
||
) |
void CodeGenerator::generateSupportCode | ( | const filesystem::path & | outputPath, |
const ModelSpecMerged & | modelMerged, | ||
const std::string & | suffix = "" |
||
) |
void CodeGenerator::generateSynapseUpdate | ( | const filesystem::path & | outputPath, |
const ModelSpecMerged & | modelMerged, | ||
const BackendBase & | backend, | ||
const std::string & | suffix = "" |
||
) |
void CodeGenerator::genKernelIndex | ( | const G * | group, |
std::ostream & | os, | ||
const CodeGenerator::Substitutions & | subs, | ||
K | getKernelSizeFn | ||
) |
void CodeGenerator::genTypeRange | ( | CodeStream & | os, |
const std::string & | precision, | ||
const std::string & | prefix | ||
) |
std::string CodeGenerator::getKernelSize | ( | const G * | group, |
size_t | dimensionIndex, | ||
K | getKernelSizeFn | ||
) |
std::string CodeGenerator::getReductionInitialValue | ( | const BackendBase & | backend, |
VarAccessMode | access, | ||
const std::string & | type | ||
) |
Get the initial value to start reduction operations from.
std::string CodeGenerator::getReductionOperation | ( | const std::string & | reduction, |
const std::string & | value, | ||
VarAccessMode | access, | ||
const std::string & | type | ||
) |
Generate a reduction operation to reduce value into reduction.
bool CodeGenerator::isKernelSizeHeterogeneous | ( | const G * | group, |
size_t | dimensionIndex, | ||
K | getKernelSizeFn | ||
) |
void CodeGenerator::neuronSubstitutionsInSynapticCode | ( | CodeGenerator::Substitutions & | substitutions, |
const NeuronGroupInternal * | archetypeNG, | ||
const std::string & | delayOffset, | ||
const std::string & | sourceSuffix, | ||
const std::string & | destSuffix, | ||
const std::string & | varPrefix, | ||
const std::string & | varSuffix, | ||
bool | useLocalNeuronVars, | ||
P | isParamHeterogeneousFn, | ||
D | isDerivedParamHeterogeneousFn, | ||
V | getVarIndexFn, | ||
S | getPrevSpikeTimeIndexFn | ||
) |
Function for performing the code and value substitutions necessary to insert neuron related variables, parameters, and extraGlobal parameters into synaptic code.
|
inline |
std::ostream & CodeGenerator::operator<< | ( | std::ostream & | s, |
const CodeStream::OB & | ob | ||
) |
std::ostream & CodeGenerator::operator<< | ( | std::ostream & | s, |
const CodeStream::CB & | cb | ||
) |
|
inline |
|
inline |
Pad an integer to a multiple of another.
bool CodeGenerator::regexFuncSubstitute | ( | std::string & | s, |
const std::string & | trg, | ||
const std::string & | rep | ||
) |
Tool for substituting function names in the neuron code strings or other templates using regular expressions.
bool CodeGenerator::regexVarSubstitute | ( | std::string & | s, |
const std::string & | trg, | ||
const std::string & | rep | ||
) |
Tool for substituting variable names in the neuron code strings or other templates using regular expressions.
void CodeGenerator::substitute | ( | std::string & | s, |
const std::string & | trg, | ||
const std::string & | rep | ||
) |
Tool for substituting strings in the neuron code strings or other templates.