27 void setVarLocation(
const std::string &varName,
VarLocation loc);
32 const std::string &
getName()
const{
return m_Name; }
38 const std::vector<double> &
getParams()
const{
return m_Params; }
41 const std::vector<Models::EGPReference> &
getEGPReferences()
const{
return m_EGPReferences; }
44 VarLocation getVarLocation(
const std::string &varName)
const;
50 bool isVarInitRequired()
const;
53 CustomUpdateBase(
const std::string &name,
const std::string &updateGroupName,
55 const std::vector<Models::VarInit> &varInitialisers,
const std::vector<Models::EGPReference> &egpReferences,
61 void initDerivedParams(
double dt);
69 bool isInitRNGRequired()
const;
71 bool isZeroCopyEnabled()
const;
78 void updateHash(boost::uuids::detail::sha1 &hash)
const;
82 void updateInitHash(boost::uuids::detail::sha1 &hash)
const;
84 boost::uuids::detail::sha1::digest_type getVarLocationHashDigest()
const;
90 const auto vars = getCustomUpdateModel()->getVars();
91 if(std::any_of(vars.cbegin(), vars.cend(),
101 const auto modelVarRefs = getCustomUpdateModel()->getVarRefs();
102 for (
size_t i = 0; i < varRefs.size(); i++) {
103 const auto varRef = varRefs.at(i);
104 const auto modelVarRef = modelVarRefs.at(i);
120 const auto modelVarRefs = getCustomUpdateModel()->getVarRefs();
121 for(
size_t i = 0; i < varRefs.size(); i++) {
122 const auto varRef = varRefs.at(i);
123 const auto modelVarRef = modelVarRefs.at(i);
127 if(varRef.getVar().type != modelVarRef.type) {
128 throw std::runtime_error(
"Incompatible type for variable reference '" + modelVarRef.name +
"'");
135 throw std::runtime_error(
"Reduction target variable reference must be to SHARED or SHARED_NEURON variables.");
146 m_Batched = std::any_of(varRefs.cbegin(), varRefs.cend(),
157 const auto modelVarRefs = getCustomUpdateModel()->getVarRefs();
158 for (
size_t i = 0; i < varRefs.size(); i++) {
159 const auto varRef = varRefs.at(i);
160 const auto modelVarRef = modelVarRefs.at(i);
167 throw std::runtime_error(
"Variable references to SHARED variables in batched custom updates cannot be read-write.");
176 const std::string m_Name;
177 const std::string m_UpdateGroupName;
180 const std::vector<double> m_Params;
181 std::vector<double> m_DerivedParams;
182 std::vector<Models::VarInit> m_VarInitialisers;
184 std::vector<Models::EGPReference> m_EGPReferences;
187 std::vector<VarLocation> m_VarLocation;
190 std::vector<VarLocation> m_ExtraGlobalParamLocation;
205 const std::vector<Models::VarReference> &
getVarReferences()
const{
return m_VarReferences; }
206 unsigned int getSize()
const {
return m_Size; }
209 CustomUpdate(
const std::string &name,
const std::string &updateGroupName,
211 const std::vector<Models::VarInit> &varInitialisers,
const std::vector<Models::VarReference> &varReferences,
212 const std::vector<Models::EGPReference> &egpReferences,
VarLocation defaultVarLocation,
218 void finalize(
unsigned int batchSize);
229 boost::uuids::detail::sha1::digest_type getHashDigest()
const;
233 boost::uuids::detail::sha1::digest_type getInitHashDigest()
const;
241 const std::vector<Models::VarReference> m_VarReferences;
242 const unsigned int m_Size;
258 const std::vector<Models::WUVarReference> &
getVarReferences()
const{
return m_VarReferences; }
261 CustomUpdateWU(
const std::string &name,
const std::string &updateGroupName,
263 const std::vector<Models::VarInit> &varInitialisers,
const std::vector<Models::WUVarReference> &varReferences,
264 const std::vector<Models::EGPReference> &egpReferences,
VarLocation defaultVarLocation,
270 void finalize(
unsigned int batchSize);
276 bool isTransposeOperation()
const;
282 boost::uuids::detail::sha1::digest_type getHashDigest()
const;
286 boost::uuids::detail::sha1::digest_type getInitHashDigest()
const;
292 const std::vector<Models::WUVarReference> m_VarReferences;
Definition: neuronGroup.h:21
Definition: customUpdate.h:16
VarLocation
< Flags defining which memory space variables should be allocated in
Definition: variableMode.h:10
const std::vector< double > & getDerivedParams() const
Definition: customUpdate.h:66
bool isBatched() const
Is this custom update batched i.e. run in parallel across model batches.
Definition: customUpdate.h:74
const std::string & getName() const
Definition: customUpdate.h:32
bool isBatchReduction() const
Definition: customUpdate.h:223
Definition: customUpdate.h:199
const std::vector< double > & getParams() const
Definition: customUpdate.h:38
const std::vector< Models::VarReference > & getVarReferences() const
Definition: customUpdate.h:205
void checkVarReferences(const std::vector< V > &varRefs)
Helper function to check if variable reference types match those specified in model.
Definition: customUpdate.h:117
#define GENN_EXPORT
Definition: gennExport.h:13
VarLocation getVarLocation(size_t index) const
Get variable location for custom update model state variable.
Definition: customUpdate.h:47
Definition: customUpdate.h:252
Base class for all current source models.
Definition: customUpdateModels.h:31
bool isNeuronReduction() const
Definition: customUpdate.h:224
const std::vector< Models::VarInit > & getVarInitialisers() const
Definition: customUpdate.h:39
Definition: synapseGroupInternal.h:9
const SynapseGroupInternal * getSynapseGroup() const
Definition: customUpdate.h:278
const NeuronGroup * getDelayNeuronGroup() const
Definition: customUpdate.h:235
void updateHash(const T &value, boost::uuids::detail::sha1 &hash)
Hash arithmetic types and enums.
Definition: gennUtils.h:128
A variable has a name, a type and an access type.
Definition: models.h:58
This variable should be shared between batches.
unsigned int getSize() const
Definition: customUpdate.h:206
const CustomUpdateModels::Base * getCustomUpdateModel() const
Gets the custom update model used by this group.
Definition: customUpdate.h:36
const std::vector< Models::EGPReference > & getEGPReferences() const
Definition: customUpdate.h:41
VarAccessDuplication
Flags defining how variables should be duplicated across multiple batches.
Definition: varAccess.h:28
void checkVarReferenceBatching(const std::vector< V > &varRefs, unsigned int batchSize)
Helper function to check if variable reference types match those specified in model.
Definition: customUpdate.h:142
const std::vector< Models::WUVarReference > & getVarReferences() const
Definition: customUpdate.h:258
bool isBatchReduction() const
Definition: customUpdate.h:275
bool isReduction(const std::vector< V > &varRefs, VarAccessDuplication duplication) const
Definition: customUpdate.h:87
This variable is read-write.
const std::string & getUpdateGroupName() const
Definition: customUpdate.h:33
bool isPerNeuron() const
Definition: customUpdate.h:225
This variable should be duplicated in each batch.