![]() |
GeNN
4.0.0
GPU enhanced Neuronal Networks (GeNN)
|
Helper class for generating code - automatically inserts brackets, indents etc. More...
Namespaces | |
CUDA | |
SingleThreadedCPU | |
Classes | |
class | BackendBase |
class | CodeStream |
struct | FunctionTemplate |
struct | NameIterCtx |
struct | PreferencesBase |
Base class for backend preferences - can be accessed via a global in 'classic' C++ code generator. More... | |
class | StructNameConstIter |
Custom iterator for iterating through the containers of structs with 'name' members. More... | |
class | Substitutions |
class | TeeBuf |
class | TeeStream |
Typedefs | |
typedef NameIterCtx< Models::Base::VarVec > | VarNameIterCtx |
typedef NameIterCtx< Models::Base::DerivedParamVec > | DerivedParamNameIterCtx |
typedef NameIterCtx< Models::Base::VarVec > | ExtraGlobalParamNameIterCtx |
Functions | |
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... | |
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... | |
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... | |
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... | |
template<typename NameIter > | |
void | name_substitutions (std::string &code, const std::string &prefix, NameIter namesBegin, NameIter namesEnd, const std::string &postfix="", const std::string &ext="") |
This function performs a list of name substitutions for variables in code snippets. More... | |
void | name_substitutions (std::string &code, const std::string &prefix, const std::vector< std::string > &names, const std::string &postfix="", const std::string &ext="") |
This function performs a list of name substitutions for variables in code snippets. More... | |
template<class T , typename std::enable_if< std::is_floating_point< T >::value >::type * = nullptr> | |
void | writePreciseString (std::ostream &os, T value) |
This function writes a floating point value to a stream -setting the precision so no digits are lost. More... | |
template<class T , typename std::enable_if< std::is_floating_point< T >::value >::type * = nullptr> | |
std::string | writePreciseString (T value) |
This function writes a floating point value to a string - setting the precision so no digits are lost. More... | |
template<typename NameIter > | |
void | value_substitutions (std::string &code, NameIter namesBegin, NameIter namesEnd, const std::vector< double > &values, const std::string &ext="") |
This function performs a list of value substitutions for parameters in code snippets. More... | |
void | value_substitutions (std::string &code, const std::vector< std::string > &names, const std::vector< double > &values, const std::string &ext="") |
This function performs a list of value substitutions for parameters in code snippets. More... | |
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... | |
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... | |
void | preNeuronSubstitutionsInSynapticCode (std::string &wCode, const SynapseGroupInternal &sg, const std::string &offset, const std::string &axonalDelayOffset, const std::string &postIdx, const std::string &devPrefix, const std::string &preVarPrefix="", const std::string &preVarSuffix="") |
suffix to be used for presynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX) More... | |
void | postNeuronSubstitutionsInSynapticCode (std::string &wCode, const SynapseGroupInternal &sg, const std::string &offset, const std::string &backPropDelayOffset, const std::string &preIdx, const std::string &devPrefix, const std::string &postVarPrefix="", const std::string &postVarSuffix="") |
suffix to be used for postsynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX) More... | |
void | neuronSubstitutionsInSynapticCode (std::string &wCode, const SynapseGroupInternal &sg, const std::string &preIdx, const std::string &postIdx, const std::string &devPrefix, double dt, const std::string &preVarPrefix="", const std::string &preVarSuffix="", const std::string &postVarPrefix="", const std::string &postVarSuffix="") |
Function for performing the code and value substitutions necessary to insert neuron related variables, parameters, and extraGlobal parameters into synaptic code. More... | |
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 std::vector< std::string > | generateAll (const ModelSpecInternal &model, const BackendBase &backend, const filesystem::path &outputPath, bool standaloneModules=false) |
void | generateInit (CodeStream &os, const ModelSpecInternal &model, const BackendBase &backend, bool standaloneModules) |
void GENN_EXPORT | generateMakefile (std::ostream &os, const BackendBase &backend, const std::vector< std::string > &moduleNames) |
void GENN_EXPORT | generateMPI (CodeStream &os, const ModelSpecInternal &model, const BackendBase &backend, bool standaloneModules) |
A function that generates predominantly MPI infrastructure code. More... | |
void GENN_EXPORT | generateMSBuild (std::ostream &os, const BackendBase &backend, const std::string &projectGUID, const std::vector< std::string > &moduleNames) |
void | generateNeuronUpdate (CodeStream &os, const ModelSpecInternal &model, const BackendBase &backend, bool standaloneModules) |
void | generateRunner (CodeStream &definitions, CodeStream &definitionsInternal, CodeStream &runner, const ModelSpecInternal &model, const BackendBase &backend, int localHostID) |
void | generateSupportCode (CodeStream &os, const ModelSpecInternal &model) |
void | generateSynapseUpdate (CodeStream &os, const ModelSpecInternal &model, const BackendBase &backend, bool standaloneModules) |
Helper class for generating code - automatically inserts brackets, indents etc.
Based heavily on: https://stackoverflow.com/questions/15053753/writing-a-manipulator-for-a-custom-stream-class
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::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::vector< std::string > CodeGenerator::generateAll | ( | const ModelSpecInternal & | model, |
const BackendBase & | backend, | ||
const filesystem::path & | outputPath, | ||
bool | standaloneModules = false |
||
) |
void CodeGenerator::generateInit | ( | CodeStream & | os, |
const ModelSpecInternal & | model, | ||
const BackendBase & | backend, | ||
bool | standaloneModules | ||
) |
void CodeGenerator::generateMakefile | ( | std::ostream & | os, |
const BackendBase & | backend, | ||
const std::vector< std::string > & | moduleNames | ||
) |
void CodeGenerator::generateMPI | ( | CodeStream & | os, |
const ModelSpecInternal & | model, | ||
const BackendBase & | backend, | ||
bool | standaloneModules | ||
) |
A function that generates predominantly MPI infrastructure code.
In this function MPI infrastructure code are generated, including: MPI send and receive functions.
void CodeGenerator::generateMSBuild | ( | std::ostream & | os, |
const BackendBase & | backend, | ||
const std::string & | projectGUID, | ||
const std::vector< std::string > & | moduleNames | ||
) |
void CodeGenerator::generateNeuronUpdate | ( | CodeStream & | os, |
const ModelSpecInternal & | model, | ||
const BackendBase & | backend, | ||
bool | standaloneModules | ||
) |
void CodeGenerator::generateRunner | ( | CodeStream & | definitions, |
CodeStream & | definitionsInternal, | ||
CodeStream & | runner, | ||
const ModelSpecInternal & | model, | ||
const BackendBase & | backend, | ||
int | localHostID | ||
) |
void CodeGenerator::generateSupportCode | ( | CodeStream & | os, |
const ModelSpecInternal & | model | ||
) |
void CodeGenerator::generateSynapseUpdate | ( | CodeStream & | os, |
const ModelSpecInternal & | model, | ||
const BackendBase & | backend, | ||
bool | standaloneModules | ||
) |
|
inline |
This function performs a list of name substitutions for variables in code snippets.
|
inline |
This function performs a list of name substitutions for variables in code snippets.
void CodeGenerator::neuronSubstitutionsInSynapticCode | ( | std::string & | wCode, |
const SynapseGroupInternal & | sg, | ||
const std::string & | preIdx, | ||
const std::string & | postIdx, | ||
const std::string & | devPrefix, | ||
double | dt, | ||
const std::string & | preVarPrefix = "" , |
||
const std::string & | preVarSuffix = "" , |
||
const std::string & | postVarPrefix = "" , |
||
const std::string & | postVarSuffix = "" |
||
) |
Function for performing the code and value substitutions necessary to insert neuron related variables, parameters, and extraGlobal parameters into synaptic code.
suffix to be used for postsynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX)
wCode | the code string to work on |
sg | the synapse group connecting the pre and postsynaptic neuron populations whose parameters might need to be substituted |
preIdx | index of the pre-synaptic neuron to be accessed for _pre variables; differs for different Span) |
postIdx | index of the post-synaptic neuron to be accessed for _post variables; differs for different Span) |
devPrefix | device prefix, "dd_" for GPU, nothing for CPU |
dt | simulation timestep (ms) |
preVarPrefix | prefix to be used for presynaptic variable accesses - typically combined with suffix to wrap in function call such as __ldg(&XXX) |
preVarSuffix | suffix to be used for presynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX) |
postVarPrefix | prefix to be used for postsynaptic variable accesses - typically combined with suffix to wrap in function call such as __ldg(&XXX) |
postVarSuffix | suffix to be used for postsynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX) |
std::ostream & CodeGenerator::operator<< | ( | std::ostream & | s, |
const CodeStream::OB & | ob | ||
) |
std::ostream & CodeGenerator::operator<< | ( | std::ostream & | s, |
const CodeStream::CB & | cb | ||
) |
void CodeGenerator::postNeuronSubstitutionsInSynapticCode | ( | std::string & | wCode, |
const SynapseGroupInternal & | sg, | ||
const std::string & | offset, | ||
const std::string & | backPropDelayOffset, | ||
const std::string & | preIdx, | ||
const std::string & | devPrefix, | ||
const std::string & | postVarPrefix = "" , |
||
const std::string & | postVarSuffix = "" |
||
) |
suffix to be used for postsynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX)
wCode | the code string to work on |
devPrefix | device prefix, "dd_" for GPU, nothing for CPU |
postVarPrefix | prefix to be used for postsynaptic variable accesses - typically combined with suffix to wrap in function call such as __ldg(&XXX) |
postVarSuffix | suffix to be used for postsynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX) |
void CodeGenerator::preNeuronSubstitutionsInSynapticCode | ( | std::string & | wCode, |
const SynapseGroupInternal & | sg, | ||
const std::string & | offset, | ||
const std::string & | axonalDelayOffset, | ||
const std::string & | postIdx, | ||
const std::string & | devPrefix, | ||
const std::string & | preVarPrefix = "" , |
||
const std::string & | preVarSuffix = "" |
||
) |
suffix to be used for presynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX)
Function for performing the code and value substitutions necessary to insert neuron related variables, parameters, and extraGlobal parameters into synaptic code.
wCode | the code string to work on |
devPrefix | device prefix, "dd_" for GPU, nothing for CPU |
preVarPrefix | prefix to be used for presynaptic variable accesses - typically combined with suffix to wrap in function call such as __ldg(&XXX) |
preVarSuffix | suffix to be used for presynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX) |
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.
|
inline |
This function performs a list of value substitutions for parameters in code snippets.
|
inline |
This function performs a list of value substitutions for parameters in code snippets.
void CodeGenerator::writePreciseString | ( | std::ostream & | os, |
T | value | ||
) |
This function writes a floating point value to a stream -setting the precision so no digits are lost.
std::string CodeGenerator::writePreciseString | ( | T | value | ) |
This function writes a floating point value to a string - setting the precision so no digits are lost.