GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
varAccess.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 //----------------------------------------------------------------------------
5 // Enumerations
6 //----------------------------------------------------------------------------
9 enum class VarAccessModeAttribute : unsigned int
10 {
11  READ_ONLY = (1 << 0),
12  READ_WRITE = (1 << 1),
13  REDUCE = (1 << 2),
14  SUM = (1 << 3),
15  MAX = (1 << 4),
16 };
17 
19 enum class VarAccessMode : unsigned int
20 {
21  READ_WRITE = static_cast<unsigned int>(VarAccessModeAttribute::READ_WRITE),
22  READ_ONLY = static_cast<unsigned int>(VarAccessModeAttribute::READ_ONLY),
23  REDUCE_SUM = static_cast<unsigned int>(VarAccessModeAttribute::REDUCE) | static_cast<unsigned int>(VarAccessModeAttribute::SUM),
24  REDUCE_MAX = static_cast<unsigned int>(VarAccessModeAttribute::REDUCE) | static_cast<unsigned int>(VarAccessModeAttribute::MAX),
25 };
26 
28 enum class VarAccessDuplication : unsigned int
29 {
30  DUPLICATE = (1 << 5),
31  SHARED = (1 << 6),
32  SHARED_NEURON = (1 << 7)
33 };
34 
36 enum class VarAccess : unsigned int
37 {
38  READ_WRITE = static_cast<unsigned int>(VarAccessMode::READ_WRITE) | static_cast<unsigned int>(VarAccessDuplication::DUPLICATE),
39  READ_ONLY = static_cast<unsigned int>(VarAccessMode::READ_ONLY) | static_cast<unsigned int>(VarAccessDuplication::SHARED),
40  READ_ONLY_SHARED_NEURON = static_cast<unsigned int>(VarAccessMode::READ_ONLY) | static_cast<unsigned int>(VarAccessDuplication::SHARED_NEURON),
41  READ_ONLY_DUPLICATE = static_cast<unsigned int>(VarAccessMode::READ_ONLY) | static_cast<unsigned int>(VarAccessDuplication::DUPLICATE),
42  REDUCE_BATCH_SUM = static_cast<unsigned int>(VarAccessMode::REDUCE_SUM) | static_cast<unsigned int>(VarAccessDuplication::SHARED),
43  REDUCE_BATCH_MAX = static_cast<unsigned int>(VarAccessMode::REDUCE_MAX) | static_cast<unsigned int>(VarAccessDuplication::SHARED),
44  REDUCE_NEURON_SUM = static_cast<unsigned int>(VarAccessMode::REDUCE_SUM) | static_cast<unsigned int>(VarAccessDuplication::SHARED_NEURON),
45  REDUCE_NEURON_MAX = static_cast<unsigned int>(VarAccessMode::REDUCE_MAX) | static_cast<unsigned int>(VarAccessDuplication::SHARED_NEURON),
46 };
47 
48 //----------------------------------------------------------------------------
49 // Operators
50 //----------------------------------------------------------------------------
51 inline bool operator & (VarAccess type, VarAccessMode mode)
52 {
53  return (static_cast<unsigned int>(type) & static_cast<unsigned int>(mode)) != 0;
54 }
55 
56 inline bool operator & (VarAccess type, VarAccessDuplication duplication)
57 {
58  return (static_cast<unsigned int>(type) & static_cast<unsigned int>(duplication)) != 0;
59 }
60 
61 inline bool operator & (VarAccess type, VarAccessModeAttribute modeAttribute)
62 {
63  return (static_cast<unsigned int>(type) & static_cast<unsigned int>(modeAttribute)) != 0;
64 }
65 
66 inline bool operator & (VarAccessMode mode, VarAccessModeAttribute modeAttribute)
67 {
68  return (static_cast<unsigned int>(mode) & static_cast<unsigned int>(modeAttribute)) != 0;
69 }
70 
71 //----------------------------------------------------------------------------
72 // Helpers
73 //----------------------------------------------------------------------------
75 {
76  return static_cast<VarAccessMode>(static_cast<unsigned int>(type) & 0x1F);
77 }
78 
80 {
81  return static_cast<VarAccessDuplication>(static_cast<unsigned int>(type) & ~0x1F);
82 }
bool operator&(VarAccess type, VarAccessMode mode)
Definition: varAccess.h:51
VarAccessMode
Supported combination of VarAccessModeAttribute.
Definition: varAccess.h:19
This variable is read only.
VarAccessModeAttribute
Definition: varAccess.h:9
VarAccess
Supported combinations of VarAccessMode and VarAccessDuplication.
Definition: varAccess.h:36
VarAccessMode getVarAccessMode(VarAccess type)
Definition: varAccess.h:74
This variable should be shared between batches.
This variable&#39;s reduction operation is a summation.
This variable is a reduction target.
VarAccessDuplication
Flags defining how variables should be duplicated across multiple batches.
Definition: varAccess.h:28
VarAccessDuplication getVarAccessDuplication(VarAccess type)
Definition: varAccess.h:79
This variable is read-write.
This variable should be duplicated in each batch.