GeNN
3.3.0
GPU enhanced Neuronal Networks (GeNN)
|
#include <iomanip>
#include <limits>
#include <string>
#include <sstream>
#include <vector>
#include "variableMode.h"
Go to the source code of this file.
Classes | |
struct | GenericFunction |
struct | FunctionTemplate |
class | PairKeyConstIter< BaseIter > |
Custom iterator for iterating through the keys of containers containing pairs. More... | |
Namespaces | |
NeuronModels | |
NewModels | |
Functions | |
template<typename BaseIter > | |
PairKeyConstIter< BaseIter > | GetPairKeyConstIter (BaseIter iter) |
Helper function for creating a PairKeyConstIter from an iterator. More... | |
void | substitute (string &s, const string &trg, const string &rep) |
Tool for substituting strings in the neuron code strings or other templates. More... | |
bool | regexVarSubstitute (string &s, const string &trg, const string &rep) |
Tool for substituting variable names in the neuron code strings or other templates using regular expressions. More... | |
bool | regexFuncSubstitute (string &s, const string &trg, const string &rep) |
Tool for substituting function names in the neuron code strings or other templates using regular expressions. More... | |
bool | isRNGRequired (const std::string &code) |
Does the code string contain any functions requiring random number generator. More... | |
bool | isInitRNGRequired (const std::vector< NewModels::VarInit > &varInitialisers, const std::vector< VarMode > &varModes, VarInit initLocation) |
Does the model with the vectors of variable initialisers and modes require an RNG for the specified init location i.e. host or device. 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 (string &code, const string &prefix, NameIter namesBegin, NameIter namesEnd, const string &postfix="", const string &ext="") |
This function performs a list of name substitutions for variables in code snippets. More... | |
void | name_substitutions (string &code, const string &prefix, const vector< string > &names, const string &postfix="", const 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 (string &code, NameIter namesBegin, NameIter namesEnd, const vector< double > &values, const string &ext="") |
This function performs a list of value substitutions for parameters in code snippets. More... | |
void | value_substitutions (string &code, const vector< string > &names, const vector< double > &values, const string &ext="") |
This function performs a list of value substitutions for parameters in code snippets. More... | |
void | functionSubstitutions (std::string &code, const std::string &ftype, const std::vector< FunctionTemplate > functions) |
This function performs a list of function substitutions in code snipped. More... | |
string | ensureFtype (const string &oldcode, const 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 string &code, const string &codeName) |
This function checks for unknown variable definitions and returns a gennError if any are found. More... | |
uint32_t | hashString (const std::string &string) |
This function returns the 32-bit hash of a string - because these are used across MPI nodes which may have different libstdc++ it would be risky to use std::hash. More... | |
void | preNeuronSubstitutionsInSynapticCode (string &wCode, const SynapseGroup *sg, const string &offset, const string &axonalDelayOffset, const string &postIdx, const string &devPrefix, const string &preVarPrefix="", const 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 (string &wCode, const SynapseGroup *sg, const string &offset, const string &backPropDelayOffset, const string &preIdx, const string &devPrefix, const string &postVarPrefix="", const 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 | neuron_substitutions_in_synaptic_code (string &wCode, const SynapseGroup *sg, const string &preIdx, const string &postIdx, const string &devPrefix, double dt, const string &preVarPrefix="", const string &preVarSuffix="", const string &postVarPrefix="", const string &postVarSuffix="") |
Function for performing the code and value substitutions necessary to insert neuron related variables, parameters, and extraGlobal parameters into synaptic code. More... | |
Variables | |
const std::vector< FunctionTemplate > | cudaFunctions |
CUDA implementations of standard functions. More... | |
const std::vector< FunctionTemplate > | cpuFunctions |
CPU implementations of standard functions. More... | |
void checkUnreplacedVariables | ( | const string & | code, |
const string & | codeName | ||
) |
This function checks for unknown variable definitions and returns a gennError if any are found.
string ensureFtype | ( | const string & | oldcode, |
const 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 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))
void functionSubstitutions | ( | std::string & | code, |
const std::string & | ftype, | ||
const std::vector< FunctionTemplate > | functions | ||
) |
This function performs a list of function substitutions in code snipped.
|
inline |
Helper function for creating a PairKeyConstIter from an iterator.
uint32_t hashString | ( | const std::string & | string | ) |
This function returns the 32-bit hash of a string - because these are used across MPI nodes which may have different libstdc++ it would be risky to use std::hash.
https://stackoverflow.com/questions/19411742/what-is-the-default-hash-function-used-in-c-stdunordered-map suggests that libstdc++ uses MurmurHash2 so this seems as good a bet as any MurmurHash2, by Austin Appleby It has a few limitations -
bool isInitRNGRequired | ( | const std::vector< NewModels::VarInit > & | varInitialisers, |
const std::vector< VarMode > & | varModes, | ||
VarInit | initLocation | ||
) |
Does the model with the vectors of variable initialisers and modes require an RNG for the specified init location i.e. host or device.
Does the model with the vectors of variable initialisers and modes require an RNG for the specified init location i.e. host or device.
bool isRNGRequired | ( | const std::string & | code | ) |
Does the code string contain any functions requiring random number generator.
|
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 neuron_substitutions_in_synaptic_code | ( | string & | wCode, |
const SynapseGroup * | sg, | ||
const string & | preIdx, | ||
const string & | postIdx, | ||
const string & | devPrefix, | ||
double | dt, | ||
const string & | preVarPrefix = "" , |
||
const string & | preVarSuffix = "" , |
||
const string & | postVarPrefix = "" , |
||
const 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) |
void postNeuronSubstitutionsInSynapticCode | ( | string & | wCode, |
const SynapseGroup * | sg, | ||
const string & | offset, | ||
const string & | backPropDelayOffset, | ||
const string & | preIdx, | ||
const string & | devPrefix, | ||
const string & | postVarPrefix = "" , |
||
const 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 preNeuronSubstitutionsInSynapticCode | ( | string & | wCode, |
const SynapseGroup * | sg, | ||
const string & | offset, | ||
const string & | axonalDelayOffset, | ||
const string & | preIdx, | ||
const string & | devPrefix, | ||
const string & | preVarPrefix, | ||
const string & | preVarSuffix | ||
) |
suffix to be used for presynaptic variable accesses - typically combined with prefix to wrap in function call such as __ldg(&XXX)
suffix to be used for presynaptic 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 |
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 regexFuncSubstitute | ( | string & | s, |
const string & | trg, | ||
const string & | rep | ||
) |
Tool for substituting function names in the neuron code strings or other templates using regular expressions.
bool regexVarSubstitute | ( | string & | s, |
const string & | trg, | ||
const string & | rep | ||
) |
Tool for substituting variable names in the neuron code strings or other templates using regular expressions.
void substitute | ( | string & | s, |
const string & | trg, | ||
const 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 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 writePreciseString | ( | T | value | ) |
This function writes a floating point value to a string - setting the precision so no digits are lost.
const std::vector<FunctionTemplate> cpuFunctions |
CPU implementations of standard functions.
const std::vector<FunctionTemplate> cudaFunctions |
CUDA implementations of standard functions.