User Guide
codegen_naming.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Blue Brain Project, EPFL.
3  * See the top-level LICENSE file for details.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #pragma once
9 
10 #include <string>
11 #include <unordered_map>
12 
13 
14 namespace nmodl {
15 namespace codegen {
16 /// different variable names used in code generation
17 namespace naming {
18 
19 /// nmodl language version
20 /// @todo : should be moved from codegen to global scope
21 static constexpr char NMODL_VERSION[] = "7.7.0";
22 
23 /// derivimplicit method in nmodl
24 static constexpr char DERIVIMPLICIT_METHOD[] = "derivimplicit";
25 
26 /// euler method in nmodl
27 static constexpr char EULER_METHOD[] = "euler";
28 
29 /// cnexp method in nmodl
30 static constexpr char CNEXP_METHOD[] = "cnexp";
31 
32 /// cvode method in nmodl
33 static constexpr char AFTER_CVODE_METHOD[] = "after_cvode";
34 
35 /// sparse method in nmodl
36 static constexpr char SPARSE_METHOD[] = "sparse";
37 
38 /// net_event function call in nmodl
39 static constexpr char NET_EVENT_METHOD[] = "net_event";
40 
41 /// net_move function call in nmodl
42 static constexpr char NET_MOVE_METHOD[] = "net_move";
43 
44 /// net_send function call in nmodl
45 static constexpr char NET_SEND_METHOD[] = "net_send";
46 
47 /// artificial cell keyword in nmodl
48 static constexpr char ARTIFICIAL_CELL[] = "ARTIFICIAL_CELL";
49 
50 /// point process keyword in nmodl
51 static constexpr char POINT_PROCESS[] = "POINT_PROCESS";
52 
53 /// inbuilt neuron variable for diameter of the compartment
54 static constexpr char DIAM_VARIABLE[] = "diam";
55 
56 /// inbuilt neuron variable for area of the compartment
57 static constexpr char NODE_AREA_VARIABLE[] = "node_area";
58 
59 /// similar to node_area but user can explicitly declare it as area
60 static constexpr char AREA_VARIABLE[] = "area";
61 
62 /// inbuilt neuron variable for point process
63 static constexpr char POINT_PROCESS_VARIABLE[] = "point_process";
64 
65 /// inbuilt neuron variable for tqitem process
66 static constexpr char TQITEM_VARIABLE[] = "tqitem";
67 
68 /// range variable for conductance
69 static constexpr char CONDUCTANCE_VARIABLE[] = "g";
70 
71 /// global variable to indicate if table is used
72 static constexpr char USE_TABLE_VARIABLE[] = "usetable";
73 
74 /// range variable when conductance is not used (for vectorized model)
75 static constexpr char CONDUCTANCE_UNUSED_VARIABLE[] = "g_unused";
76 
77 /// range variable for voltage when unused (for vectorized model)
78 static constexpr char VOLTAGE_UNUSED_VARIABLE[] = "v_unused";
79 
80 /// variable t indicating last execution time of net receive block
81 static constexpr char T_SAVE_VARIABLE[] = "tsave";
82 
83 /// shadow rhs variable in neuron thread structure
84 static constexpr char NTHREAD_RHS_SHADOW[] = "_shadow_rhs";
85 
86 /// shadow d variable in neuron thread structure
87 static constexpr char NTHREAD_D_SHADOW[] = "_shadow_d";
88 
89 /// global temperature variable
90 static constexpr char CELSIUS_VARIABLE[] = "celsius";
91 
92 /// instance struct member pointing to the global variable structure
93 static constexpr char INST_GLOBAL_MEMBER[] = "global";
94 
95 /// t variable in neuron thread structure
96 static constexpr char NTHREAD_T_VARIABLE[] = "t";
97 
98 /// dt variable in neuron thread structure
99 static constexpr char NTHREAD_DT_VARIABLE[] = "dt";
100 
101 /// default float variable type
102 static constexpr char DEFAULT_FLOAT_TYPE[] = "double";
103 
104 /// default local variable type
105 static constexpr char DEFAULT_LOCAL_VAR_TYPE[] = "double";
106 
107 /// default integer variable type
108 static constexpr char DEFAULT_INTEGER_TYPE[] = "int";
109 
110 /// semantic type for area variable
111 static constexpr char AREA_SEMANTIC[] = "area";
112 
113 /// semantic type for point process variable
114 static constexpr char POINT_PROCESS_SEMANTIC[] = "pntproc";
115 
116 /// semantic type for pointer variable
117 static constexpr char POINTER_SEMANTIC[] = "pointer";
118 
119 /// semantic type for core pointer variable
120 static constexpr char CORE_POINTER_SEMANTIC[] = "bbcorepointer";
121 
122 /// semantic type for RANDOM variable
123 static constexpr char RANDOM_SEMANTIC[] = "random";
124 
125 /// semantic type for net send call
126 static constexpr char NET_SEND_SEMANTIC[] = "netsend";
127 
128 /// semantic type for watch statement
129 static constexpr char WATCH_SEMANTIC[] = "watch";
130 
131 /// semantic type for for_netcon statement
132 static constexpr char FOR_NETCON_SEMANTIC[] = "fornetcon";
133 
134 /// nrn_init method in generated code
135 static constexpr char NRN_INIT_METHOD[] = "nrn_init";
136 
137 /// nrn_constructor method in generated code
138 static constexpr char NRN_CONSTRUCTOR_METHOD[] = "nrn_constructor";
139 
140 /// nrn_destructor method in generated code
141 static constexpr char NRN_DESTRUCTOR_METHOD[] = "nrn_destructor";
142 
143 /// nrn_private_constructor method in generated code
144 inline constexpr char NRN_PRIVATE_CONSTRUCTOR_METHOD[] = "nrn_private_constructor";
145 
146 /// nrn_private_destructor method in generated code
147 inline constexpr char NRN_PRIVATE_DESTRUCTOR_METHOD[] = "nrn_private_destructor";
148 
149 /// nrn_alloc method in generated code
150 static constexpr char NRN_ALLOC_METHOD[] = "nrn_alloc";
151 
152 /// nrn_state method in generated code
153 static constexpr char NRN_STATE_METHOD[] = "nrn_state";
154 
155 /// nrn_cur method in generated code
156 static constexpr char NRN_CUR_METHOD[] = "nrn_cur";
157 
158 /// nrn_jacob method in generated code
159 static constexpr char NRN_JACOB_METHOD[] = "nrn_jacob";
160 
161 /// nrn_watch_check method in generated c++ file
162 static constexpr char NRN_WATCH_CHECK_METHOD[] = "nrn_watch_check";
163 
164 /// verbatim name of the variable for nrn thread arguments
165 static constexpr char THREAD_ARGS[] = "_threadargs_";
166 
167 /// verbatim name of the variable for nrn thread arguments in prototype
168 static constexpr char THREAD_ARGS_PROTO[] = "_threadargsproto_";
169 
170 /// prefix for ion variable
171 static constexpr char ION_VARNAME_PREFIX[] = "ion_";
172 
173 /// hoc_nrnpointerindex name
174 static constexpr char NRN_POINTERINDEX[] = "hoc_nrnpointerindex";
175 
176 
177 /// commonly used variables in verbatim block and how they
178 /// should be mapped to new code generation backends
179 // clang-format off
180  static const std::unordered_map<std::string, std::string> VERBATIM_VARIABLES_MAPPING{
181  {"_nt", "nt"},
182  {"_p", "data"},
183  {"_ppvar", "indexes"},
184  {"_thread", "thread"},
185  {"_iml", "id"},
186  {"_cntml_padded", "pnodecount"},
187  {"_cntml", "nodecount"},
188  {"_tqitem", "tqitem"}};
189 
190  // Functions available in NMODL with RANDOM construct and their mapping to
191  // C++ functions for Random123 interface.
192  static std::unordered_map<std::string, std::string> RANDOM_FUNCTIONS_MAPPING{
193  {"random_setseq", "nrnran123_setseq"},
194  {"random_setids", "nrnran123_setids"},
195  {"random_uniform", "nrnran123_uniform"},
196  {"random_negexp", "nrnran123_negexp"},
197  {"random_normal", "nrnran123_normal"},
198  {"random_ipick", "nrnran123_ipick"},
199  {"random_dpick", "nrnran123_dblpick"}};
200 // clang-format on
201 } // namespace naming
202 } // namespace codegen
203 } // namespace nmodl
nmodl::codegen::naming::RANDOM_SEMANTIC
static constexpr char RANDOM_SEMANTIC[]
semantic type for RANDOM variable
Definition: codegen_naming.hpp:123
nmodl::codegen::naming::NET_SEND_SEMANTIC
static constexpr char NET_SEND_SEMANTIC[]
semantic type for net send call
Definition: codegen_naming.hpp:126
nmodl::codegen::naming::CELSIUS_VARIABLE
static constexpr char CELSIUS_VARIABLE[]
global temperature variable
Definition: codegen_naming.hpp:90
nmodl::codegen::naming::DEFAULT_LOCAL_VAR_TYPE
static constexpr char DEFAULT_LOCAL_VAR_TYPE[]
default local variable type
Definition: codegen_naming.hpp:105
nmodl::codegen::naming::CNEXP_METHOD
static constexpr char CNEXP_METHOD[]
cnexp method in nmodl
Definition: codegen_naming.hpp:30
nmodl::codegen::naming::NRN_PRIVATE_DESTRUCTOR_METHOD
constexpr char NRN_PRIVATE_DESTRUCTOR_METHOD[]
nrn_private_destructor method in generated code
Definition: codegen_naming.hpp:147
nmodl::codegen::naming::POINT_PROCESS_VARIABLE
static constexpr char POINT_PROCESS_VARIABLE[]
inbuilt neuron variable for point process
Definition: codegen_naming.hpp:63
nmodl::codegen::naming::NRN_JACOB_METHOD
static constexpr char NRN_JACOB_METHOD[]
nrn_jacob method in generated code
Definition: codegen_naming.hpp:159
nmodl::codegen::naming::NTHREAD_D_SHADOW
static constexpr char NTHREAD_D_SHADOW[]
shadow d variable in neuron thread structure
Definition: codegen_naming.hpp:87
nmodl::codegen::naming::VOLTAGE_UNUSED_VARIABLE
static constexpr char VOLTAGE_UNUSED_VARIABLE[]
range variable for voltage when unused (for vectorized model)
Definition: codegen_naming.hpp:78
nmodl::codegen::naming::NRN_WATCH_CHECK_METHOD
static constexpr char NRN_WATCH_CHECK_METHOD[]
nrn_watch_check method in generated c++ file
Definition: codegen_naming.hpp:162
nmodl::codegen::naming::POINT_PROCESS
static constexpr char POINT_PROCESS[]
point process keyword in nmodl
Definition: codegen_naming.hpp:51
nmodl
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
nmodl::codegen::naming::NRN_CONSTRUCTOR_METHOD
static constexpr char NRN_CONSTRUCTOR_METHOD[]
nrn_constructor method in generated code
Definition: codegen_naming.hpp:138
nmodl::codegen::naming::NTHREAD_DT_VARIABLE
static constexpr char NTHREAD_DT_VARIABLE[]
dt variable in neuron thread structure
Definition: codegen_naming.hpp:99
nmodl::codegen::naming::NODE_AREA_VARIABLE
static constexpr char NODE_AREA_VARIABLE[]
inbuilt neuron variable for area of the compartment
Definition: codegen_naming.hpp:57
nmodl::codegen::naming::NRN_ALLOC_METHOD
static constexpr char NRN_ALLOC_METHOD[]
nrn_alloc method in generated code
Definition: codegen_naming.hpp:150
nmodl::codegen::naming::SPARSE_METHOD
static constexpr char SPARSE_METHOD[]
sparse method in nmodl
Definition: codegen_naming.hpp:36
nmodl::codegen::naming::ARTIFICIAL_CELL
static constexpr char ARTIFICIAL_CELL[]
artificial cell keyword in nmodl
Definition: codegen_naming.hpp:48
nmodl::codegen::naming::CONDUCTANCE_VARIABLE
static constexpr char CONDUCTANCE_VARIABLE[]
range variable for conductance
Definition: codegen_naming.hpp:69
nmodl::codegen::naming::DEFAULT_FLOAT_TYPE
static constexpr char DEFAULT_FLOAT_TYPE[]
default float variable type
Definition: codegen_naming.hpp:102
nmodl::codegen::naming::NTHREAD_RHS_SHADOW
static constexpr char NTHREAD_RHS_SHADOW[]
shadow rhs variable in neuron thread structure
Definition: codegen_naming.hpp:84
nmodl::codegen::naming::USE_TABLE_VARIABLE
static constexpr char USE_TABLE_VARIABLE[]
global variable to indicate if table is used
Definition: codegen_naming.hpp:72
nmodl::codegen::naming::POINT_PROCESS_SEMANTIC
static constexpr char POINT_PROCESS_SEMANTIC[]
semantic type for point process variable
Definition: codegen_naming.hpp:114
nmodl::codegen::naming::VERBATIM_VARIABLES_MAPPING
static const std::unordered_map< std::string, std::string > VERBATIM_VARIABLES_MAPPING
commonly used variables in verbatim block and how they should be mapped to new code generation backen...
Definition: codegen_naming.hpp:180
nmodl::codegen::naming::NMODL_VERSION
static constexpr char NMODL_VERSION[]
nmodl language version
Definition: codegen_naming.hpp:21
nmodl::codegen::naming::NRN_INIT_METHOD
static constexpr char NRN_INIT_METHOD[]
nrn_init method in generated code
Definition: codegen_naming.hpp:135
nmodl::codegen::naming::THREAD_ARGS
static constexpr char THREAD_ARGS[]
verbatim name of the variable for nrn thread arguments
Definition: codegen_naming.hpp:165
nmodl::codegen::naming::POINTER_SEMANTIC
static constexpr char POINTER_SEMANTIC[]
semantic type for pointer variable
Definition: codegen_naming.hpp:117
nmodl::codegen::naming::AREA_SEMANTIC
static constexpr char AREA_SEMANTIC[]
semantic type for area variable
Definition: codegen_naming.hpp:111
nmodl::codegen::naming::NRN_CUR_METHOD
static constexpr char NRN_CUR_METHOD[]
nrn_cur method in generated code
Definition: codegen_naming.hpp:156
nmodl::codegen::naming::RANDOM_FUNCTIONS_MAPPING
static std::unordered_map< std::string, std::string > RANDOM_FUNCTIONS_MAPPING
Definition: codegen_naming.hpp:192
nmodl::codegen::naming::TQITEM_VARIABLE
static constexpr char TQITEM_VARIABLE[]
inbuilt neuron variable for tqitem process
Definition: codegen_naming.hpp:66
nmodl::codegen::naming::DEFAULT_INTEGER_TYPE
static constexpr char DEFAULT_INTEGER_TYPE[]
default integer variable type
Definition: codegen_naming.hpp:108
nmodl::codegen::naming::INST_GLOBAL_MEMBER
static constexpr char INST_GLOBAL_MEMBER[]
instance struct member pointing to the global variable structure
Definition: codegen_naming.hpp:93
nmodl::codegen::naming::CORE_POINTER_SEMANTIC
static constexpr char CORE_POINTER_SEMANTIC[]
semantic type for core pointer variable
Definition: codegen_naming.hpp:120
nmodl::codegen::naming::WATCH_SEMANTIC
static constexpr char WATCH_SEMANTIC[]
semantic type for watch statement
Definition: codegen_naming.hpp:129
nmodl::codegen::naming::DERIVIMPLICIT_METHOD
static constexpr char DERIVIMPLICIT_METHOD[]
derivimplicit method in nmodl
Definition: codegen_naming.hpp:24
nmodl::codegen::naming::NET_MOVE_METHOD
static constexpr char NET_MOVE_METHOD[]
net_move function call in nmodl
Definition: codegen_naming.hpp:42
nmodl::codegen::naming::EULER_METHOD
static constexpr char EULER_METHOD[]
euler method in nmodl
Definition: codegen_naming.hpp:27
nmodl::codegen::naming::NET_EVENT_METHOD
static constexpr char NET_EVENT_METHOD[]
net_event function call in nmodl
Definition: codegen_naming.hpp:39
nmodl::codegen::naming::NRN_STATE_METHOD
static constexpr char NRN_STATE_METHOD[]
nrn_state method in generated code
Definition: codegen_naming.hpp:153
nmodl::codegen::naming::AREA_VARIABLE
static constexpr char AREA_VARIABLE[]
similar to node_area but user can explicitly declare it as area
Definition: codegen_naming.hpp:60
nmodl::codegen::naming::AFTER_CVODE_METHOD
static constexpr char AFTER_CVODE_METHOD[]
cvode method in nmodl
Definition: codegen_naming.hpp:33
nmodl::codegen::naming::T_SAVE_VARIABLE
static constexpr char T_SAVE_VARIABLE[]
variable t indicating last execution time of net receive block
Definition: codegen_naming.hpp:81
nmodl::codegen::naming::FOR_NETCON_SEMANTIC
static constexpr char FOR_NETCON_SEMANTIC[]
semantic type for for_netcon statement
Definition: codegen_naming.hpp:132
nmodl::codegen::naming::NTHREAD_T_VARIABLE
static constexpr char NTHREAD_T_VARIABLE[]
t variable in neuron thread structure
Definition: codegen_naming.hpp:96
nmodl::codegen::naming::DIAM_VARIABLE
static constexpr char DIAM_VARIABLE[]
inbuilt neuron variable for diameter of the compartment
Definition: codegen_naming.hpp:54
nmodl::codegen::naming::NRN_DESTRUCTOR_METHOD
static constexpr char NRN_DESTRUCTOR_METHOD[]
nrn_destructor method in generated code
Definition: codegen_naming.hpp:141
nmodl::codegen::naming::CONDUCTANCE_UNUSED_VARIABLE
static constexpr char CONDUCTANCE_UNUSED_VARIABLE[]
range variable when conductance is not used (for vectorized model)
Definition: codegen_naming.hpp:75
nmodl::codegen::naming::NRN_POINTERINDEX
static constexpr char NRN_POINTERINDEX[]
hoc_nrnpointerindex name
Definition: codegen_naming.hpp:174
nmodl::codegen::naming::THREAD_ARGS_PROTO
static constexpr char THREAD_ARGS_PROTO[]
verbatim name of the variable for nrn thread arguments in prototype
Definition: codegen_naming.hpp:168
nmodl::codegen::naming::NRN_PRIVATE_CONSTRUCTOR_METHOD
constexpr char NRN_PRIVATE_CONSTRUCTOR_METHOD[]
nrn_private_constructor method in generated code
Definition: codegen_naming.hpp:144
nmodl::codegen::naming::NET_SEND_METHOD
static constexpr char NET_SEND_METHOD[]
net_send function call in nmodl
Definition: codegen_naming.hpp:45
nmodl::codegen::naming::ION_VARNAME_PREFIX
static constexpr char ION_VARNAME_PREFIX[]
prefix for ion variable
Definition: codegen_naming.hpp:171