User Guide
codegen_info.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 /**
11  * \file
12  * \brief Various types to store code generation specific information
13  */
14 
15 #include <fmt/format.h>
16 #include <string>
17 #include <unordered_map>
18 #include <unordered_set>
19 #include <utility>
20 
21 #include "ast/ast.hpp"
22 #include "symtab/symbol_table.hpp"
23 
24 
25 namespace nmodl {
26 namespace codegen {
27 
28 /**
29  * \addtogroup codegen_details
30  * \{
31  */
32 
33 /**
34  * \class Conductance
35  * \brief Represent conductance statements used in mod file
36  */
37 struct Conductance {
38  /// name of the ion
39  std::string ion;
40 
41  /// ion variable like intra/extra concentration
42  std::string variable;
43 };
44 
45 
46 /**
47  * \class Ion
48  * \brief Represent ions used in mod file
49  */
50 struct Ion {
51  /// name of the ion
52  std::string name;
53 
54  /// ion variables that are being read
55  std::vector<std::string> reads;
56 
57  /// ion variables that are being implicitly read
58  std::vector<std::string> implicit_reads;
59 
60  /// ion variables that are being written
61  std::vector<std::string> writes;
62 
63  /// if style semantic needed
64  bool need_style = false;
65 
66  Ion() = delete;
67 
68  explicit Ion(std::string name)
69  : name(std::move(name)) {}
70 
71  /**
72  * Check if variable name is a ionic current
73  *
74  * This is equivalent of IONCUR flag in mod2c.
75  * If it is read variable then also get NRNCURIN flag.
76  * If it is write variables then also get NRNCUROUT flag.
77  */
78  bool is_ionic_current(const std::string& text) const {
79  return text == ("i" + name);
80  }
81 
82  /**
83  * Check if variable name is internal cell concentration
84  *
85  * This is equivalent of IONIN flag in mod2c.
86  */
87  bool is_intra_cell_conc(const std::string& text) const {
88  return text == (name + "i");
89  }
90 
91  /**
92  * Check if variable name is external cell concentration
93  *
94  * This is equivalent of IONOUT flag in mod2c.
95  */
96  bool is_extra_cell_conc(const std::string& text) const {
97  return text == (name + "o");
98  }
99 
100  /**
101  * Check if variable name is reveral potential
102  *
103  * This is equivalent of IONEREV flag in mod2c.
104  */
105  bool is_rev_potential(const std::string& text) const {
106  return text == ("e" + name);
107  }
108 
109  /// check if it is either internal or external concentration
110  bool is_ionic_conc(const std::string& text) const {
111  return is_intra_cell_conc(text) || is_extra_cell_conc(text);
112  }
113 
114  /// Is the variable name `text` related to this ion?
115  ///
116  /// Example: For sodium this is true for any of `"ena"`, `"ina"`, `"nai"`
117  /// and `"nao"`; but not `ion_ina`, etc.
118  bool is_ionic_variable(const std::string& text) const {
119  return is_ionic_conc(text) || is_ionic_current(text) || is_rev_potential(text);
120  }
121 
122  bool is_current_derivative(const std::string& text) const {
123  return text == ("di" + name + "dv");
124  }
125 
126  /// for a given ion, return different variable names/properties
127  /// like internal/external concentration, reversial potential,
128  /// ionic current etc.
129  static std::vector<std::string> get_possible_variables(const std::string& ion_name) {
130  return {"i" + ion_name, ion_name + "i", ion_name + "o", "e" + ion_name};
131  }
132 
133  /// Variable index in the ion mechanism.
134  ///
135  /// For sodium (na), the `var_name` must be one of `ina`, `ena`, `nai`,
136  /// `nao` or `dinadv`. Replace `na` with the analogous for other ions.
137  ///
138  /// In NRN the order is:
139  /// 0: ena
140  /// 1: nai
141  /// 2: nao
142  /// 3: ina
143  /// 4: dinadv
144  int variable_index(const std::string& var_name) const {
145  if (is_rev_potential(var_name)) {
146  return 0;
147  }
148  if (is_intra_cell_conc(var_name)) {
149  return 1;
150  }
151  if (is_extra_cell_conc(var_name)) {
152  return 2;
153  }
154  if (is_ionic_current(var_name)) {
155  return 3;
156  }
157  if (is_current_derivative(var_name)) {
158  return 4;
159  }
160 
161  throw std::runtime_error(fmt::format("Invalid `var_name == {}`.", var_name));
162  }
163 };
164 
165 
166 /**
167  * \class IndexSemantics
168  * \brief Represent semantic information for index variable
169  */
171  /// start position in the int array
172  int index;
173 
174  /// name/type of the variable (i.e. semantics)
175  std::string name;
176 
177  /// number of elements (typically one)
178  int size;
179 
180  IndexSemantics() = delete;
181  IndexSemantics(int index, std::string name, int size)
182  : index(index)
183  , name(std::move(name))
184  , size(size) {}
185 };
186 
187 
188 /**
189  * \class CodegenInfo
190  * \brief Represent information collected from AST for code generation
191  *
192  * Code generation passes require different information from AST. This
193  * information is gathered in this single class.
194  *
195  * \todo Need to store all Define i.e. macro definitions?
196  */
197 struct CodegenInfo {
198  /// name of mod file
199  std::string mod_file;
200 
201  /// name of the suffix
202  std::string mod_suffix;
203 
204  /// point process range and functions don't have suffix
205  std::string rsuffix;
206 
207  /// true if mod file is vectorizable (which should be always true for coreneuron)
208  /// But there are some blocks like LINEAR are not thread safe in neuron or mod2c
209  /// context. In this case vectorize is used to determine number of float variable
210  /// in the data array (e.g. v). For such non thread methods or blocks vectorize is
211  /// false.
212  bool vectorize = true;
213 
214  /// if mod file is thread safe (always true for coreneuron)
215  bool thread_safe = true;
216 
217  /// if mod file is point process
218  bool point_process = false;
219 
220  /// if mod file is artificial cell
221  bool artificial_cell = false;
222 
223  /// if electrode current specified
224  bool electrode_current = false;
225 
226  /// if thread thread call back routines need to register
228 
229  /// if bbcore pointer is used
230  bool bbcore_pointer_used = false;
231 
232  /// if write concentration call required in initial block
233  bool write_concentration = false;
234 
235  /// if net_send function is used
236  bool net_send_used = false;
237 
238  /// if net_even function is used
239  bool net_event_used = false;
240 
241  /// if diam is used
242  bool diam_used = false;
243 
244  /// if area is used
245  bool area_used = false;
246 
247  /// if for_netcon is used
248  bool for_netcon_used = false;
249 
250  /// number of watch expressions
251  int watch_count = 0;
252 
253  /// number of table statements
254  int table_count = 0;
255 
256  /**
257  * thread_data_index indicates number of threads being allocated.
258  * For example, if there is derivimplicit method used, then two thread
259  * structures are created. When we print global variables then
260  * thread_data_index is used to indicate whats next thread id to use.
261  */
263 
264  /**
265  * Top local variables are those local variables that appear in global scope.
266  * Thread structure is created for top local variables and doesn't thread id
267  * 0. For example, if derivimplicit method is used then thread id 0 is assigned
268  * to those structures first. And then next thread id is assigned for top local
269  * variables. The idea of thread is assignement is to have same order for variables
270  * between neuron and coreneuron.
271  */
272 
273  /// thread id for top local variables
275 
276  /// total length of all top local variables
278 
279  /// thread id for thread promoted variables
281 
282  /// sum of length of thread promoted variables
284 
285  /// thread id for derivimplicit variables
287 
288  /// slist/dlist id for derivimplicit block
290 
291  /// number of solve blocks in mod file
293 
294  /// number of primes (all state variables not necessary to be prime)
295  int num_primes = 0;
296 
297  /// sum of length of all prime variables
298  int primes_size = 0;
299 
300  /// number of equations (i.e. statements) in derivative block
301  /// typically equal to number of primes
302  int num_equations = 0;
303 
304  /// number of semantic variables
306 
307  /// True if we have to emit CVODE code
308  /// TODO: Figure out when this needs to be true
309  bool emit_cvode = false;
310 
311  /// derivative block
313 
314  /// nrn_state block
316 
317  /// net receive block for point process
319 
320  /// number of arguments to net_receive block
322 
323  /// initial block within net receive block
325 
326  /// initial block
327  const ast::InitialBlock* initial_node = nullptr;
328 
329  /// constructor block
331 
332  /// destructor block only for point process
334 
335  /// all procedures defined in the mod file
336  std::vector<const ast::ProcedureBlock*> procedures;
337 
338  /// derivimplicit callbacks need to be emited
339  std::vector<const ast::DerivimplicitCallback*> derivimplicit_callbacks;
340 
341  /// all functions defined in the mod file
342  std::vector<const ast::FunctionBlock*> functions;
343 
344  /// all functions tables defined in the mod file
345  std::vector<const ast::FunctionTableBlock*> function_tables;
346 
347  /// all factors defined in the mod file
348  std::vector<const ast::FactorDef*> factor_definitions;
349 
350  /// ions used in the mod file
351  std::vector<Ion> ions;
352 
353  using SymbolType = std::shared_ptr<symtab::Symbol>;
354 
355  /// range variables which are parameter as well
356  std::vector<SymbolType> range_parameter_vars;
357 
358  /// range variables which are assigned variables as well
359  std::vector<SymbolType> range_assigned_vars;
360 
361  /// remaining assigned variables
362  std::vector<SymbolType> assigned_vars;
363 
364  /// all state variables
365  std::vector<SymbolType> state_vars;
366 
367  /// state variables excluding such useion read/write variables
368  /// that are not ionic currents. In neuron/mod2c these are stored
369  /// in the list "rangestate".
370  std::vector<SymbolType> range_state_vars;
371 
372  /// local variables in the global scope
373  std::vector<SymbolType> top_local_variables;
374 
375  /// pointer or bbcore pointer variables
376  std::vector<SymbolType> pointer_variables;
377 
378  /// RANDOM variables
379  std::vector<SymbolType> random_variables;
380 
381  /// index/offset for first pointer variable if exist
383 
384  /// index/offset for first RANDOM variable if exist
386 
387  /// tqitem index in integer variables
388  /// note that if tqitem doesn't exist then the default value should be 0
389  int tqitem_index = 0;
390 
391  /// updated dt to use with steadystate solver (in initial block)
392  /// empty string means no change in dt
393  std::string changed_dt;
394 
395  /// global variables
396  std::vector<SymbolType> global_variables;
397 
398  /// constant variables
399  std::vector<SymbolType> constant_variables;
400 
401  /// thread variables (e.g. global variables promoted to thread)
402  std::vector<SymbolType> thread_variables;
403 
404  /// new one used in print_ion_types
405  std::vector<SymbolType> use_ion_variables;
406 
407  /// this is the order in which they appear in derivative block
408  /// this is required while printing them in initlist function
409  std::vector<SymbolType> prime_variables_by_order;
410 
411  /// table variables
412  std::vector<SymbolType> table_statement_variables;
413  std::vector<SymbolType> table_assigned_variables;
414 
415  /// [Core]NEURON global variables used (e.g. celsius) and their types
416  std::vector<std::pair<SymbolType, std::string>> neuron_global_variables;
417 
418  /// function or procedures with table statement
419  std::vector<const ast::Block*> functions_with_table;
420 
421  /// represent conductance statements used in mod file
422  std::vector<Conductance> conductances;
423 
424  /// index variable semantic information
425  std::vector<IndexSemantics> semantics;
426 
427  /// non specific and ionic currents
428  std::vector<std::string> currents;
429 
430  /// all top level global blocks
431  std::vector<ast::Node*> top_blocks;
432 
433  /// all top level verbatim blocks
434  std::vector<ast::Node*> top_verbatim_blocks;
435 
436  /// all watch statements
437  std::vector<const ast::WatchStatement*> watch_statements;
438 
439  /// all before after blocks
440  std::vector<const ast::Block*> before_after_blocks;
441 
442  /// all variables/symbols used in the verbatim block
443  std::unordered_set<std::string> variables_in_verbatim;
444 
445  /// unique functor names for all the \c EigenNewtonSolverBlock s
446  std::unordered_map<const ast::EigenNewtonSolverBlock*, std::string> functor_names;
447 
448  /// true if eigen newton solver is used
450 
451  /// true if eigen linear solver is used
453 
454  /// if any ion has write variable
455  bool ion_has_write_variable() const noexcept;
456 
457  /// if given variable is ion write variable
458  bool is_ion_write_variable(const std::string& name) const noexcept;
459 
460  /// if given variable is ion read variable
461  bool is_ion_read_variable(const std::string& name) const noexcept;
462 
463  /// if either read or write variable
464  bool is_ion_variable(const std::string& name) const noexcept;
465 
466  /// if given variable is a current
467  bool is_current(const std::string& name) const noexcept;
468 
469  /// if given variable is a ionic current
470  bool is_ionic_current(const std::string& name) const noexcept;
471 
472  /// if given variable is a ionic concentration
473  bool is_ionic_conc(const std::string& name) const noexcept;
474 
475  /// if watch statements are used
476  bool is_watch_used() const noexcept {
477  return watch_count > 0;
478  }
479 
480  bool emit_table_thread() const noexcept {
481  return (table_count > 0 && vectorize == true);
482  }
483 
484  /// if legacy derivimplicit solver from coreneuron to be used
485  inline bool derivimplicit_used() const {
486  return !derivimplicit_callbacks.empty();
487  }
488 
489  bool function_uses_table(const std::string& name) const noexcept;
490 
491  /// true if EigenNewtonSolver is used in nrn_state block
493 
494  /// true if WatchStatement uses voltage v variable
496 
497  /// if we need a call back to wrote_conc in neuron/coreneuron
498  bool require_wrote_conc = false;
499 };
500 
501 /** \} */ // end of codegen_backends
502 
503 } // namespace codegen
504 } // namespace nmodl
nmodl::codegen::CodegenInfo::functions
std::vector< const ast::FunctionBlock * > functions
all functions defined in the mod file
Definition: codegen_info.hpp:342
nmodl::codegen::IndexSemantics::IndexSemantics
IndexSemantics()=delete
nmodl::codegen::CodegenInfo::emit_cvode
bool emit_cvode
True if we have to emit CVODE code TODO: Figure out when this needs to be true.
Definition: codegen_info.hpp:309
nmodl::codegen::CodegenInfo::num_net_receive_parameters
int num_net_receive_parameters
number of arguments to net_receive block
Definition: codegen_info.hpp:321
nmodl::codegen::Conductance::ion
std::string ion
name of the ion
Definition: codegen_info.hpp:39
nmodl::codegen::CodegenInfo::ion_has_write_variable
bool ion_has_write_variable() const noexcept
if any ion has write variable
Definition: codegen_info.cpp:21
nmodl::codegen::CodegenInfo::tqitem_index
int tqitem_index
tqitem index in integer variables note that if tqitem doesn't exist then the default value should be ...
Definition: codegen_info.hpp:389
nmodl::codegen::CodegenInfo::top_verbatim_blocks
std::vector< ast::Node * > top_verbatim_blocks
all top level verbatim blocks
Definition: codegen_info.hpp:434
nmodl::codegen::CodegenInfo::for_netcon_used
bool for_netcon_used
if for_netcon is used
Definition: codegen_info.hpp:248
nmodl::codegen::CodegenInfo::net_receive_node
const ast::NetReceiveBlock * net_receive_node
net receive block for point process
Definition: codegen_info.hpp:318
nmodl::codegen::CodegenInfo::ions
std::vector< Ion > ions
ions used in the mod file
Definition: codegen_info.hpp:351
nmodl::codegen::Ion::get_possible_variables
static std::vector< std::string > get_possible_variables(const std::string &ion_name)
for a given ion, return different variable names/properties like internal/external concentration,...
Definition: codegen_info.hpp:129
nmodl::codegen::CodegenInfo::diam_used
bool diam_used
if diam is used
Definition: codegen_info.hpp:242
nmodl::codegen::CodegenInfo::thread_callback_register
bool thread_callback_register
if thread thread call back routines need to register
Definition: codegen_info.hpp:227
nmodl::codegen::CodegenInfo::watch_count
int watch_count
number of watch expressions
Definition: codegen_info.hpp:251
nmodl::codegen::CodegenInfo::derivimplicit_callbacks
std::vector< const ast::DerivimplicitCallback * > derivimplicit_callbacks
derivimplicit callbacks need to be emited
Definition: codegen_info.hpp:339
nmodl::codegen::CodegenInfo::derivimplicit_list_num
int derivimplicit_list_num
slist/dlist id for derivimplicit block
Definition: codegen_info.hpp:289
nmodl::codegen::CodegenInfo::thread_data_index
int thread_data_index
thread_data_index indicates number of threads being allocated.
Definition: codegen_info.hpp:262
nmodl::codegen::CodegenInfo::derivimplicit_used
bool derivimplicit_used() const
if legacy derivimplicit solver from coreneuron to be used
Definition: codegen_info.hpp:485
nmodl::codegen::CodegenInfo::rsuffix
std::string rsuffix
point process range and functions don't have suffix
Definition: codegen_info.hpp:205
nmodl::codegen::CodegenInfo::table_statement_variables
std::vector< SymbolType > table_statement_variables
table variables
Definition: codegen_info.hpp:412
nmodl::ast::NetReceiveBlock
TODO.
Definition: net_receive_block.hpp:39
nmodl::codegen::CodegenInfo::initial_node
const ast::InitialBlock * initial_node
initial block
Definition: codegen_info.hpp:327
nmodl::codegen::CodegenInfo::num_primes
int num_primes
number of primes (all state variables not necessary to be prime)
Definition: codegen_info.hpp:295
nmodl::codegen::CodegenInfo::table_assigned_variables
std::vector< SymbolType > table_assigned_variables
Definition: codegen_info.hpp:413
nmodl::codegen::CodegenInfo::net_send_used
bool net_send_used
if net_send function is used
Definition: codegen_info.hpp:236
nmodl::codegen::Ion::is_ionic_variable
bool is_ionic_variable(const std::string &text) const
Is the variable name text related to this ion?
Definition: codegen_info.hpp:118
nmodl
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
nmodl::codegen::Ion
Represent ions used in mod file.
Definition: codegen_info.hpp:50
symbol_table.hpp
Implement classes for representing symbol table at block and file scope.
nmodl::codegen::CodegenInfo::constructor_node
const ast::ConstructorBlock * constructor_node
constructor block
Definition: codegen_info.hpp:330
nmodl::codegen::CodegenInfo::top_local_thread_size
int top_local_thread_size
total length of all top local variables
Definition: codegen_info.hpp:277
nmodl::codegen::Ion::name
std::string name
name of the ion
Definition: codegen_info.hpp:52
nmodl::codegen::CodegenInfo::is_voltage_used_by_watch_statements
bool is_voltage_used_by_watch_statements() const
true if WatchStatement uses voltage v variable
Definition: codegen_info.cpp:103
nmodl::codegen::CodegenInfo::changed_dt
std::string changed_dt
updated dt to use with steadystate solver (in initial block) empty string means no change in dt
Definition: codegen_info.hpp:393
nmodl::codegen::CodegenInfo::constant_variables
std::vector< SymbolType > constant_variables
constant variables
Definition: codegen_info.hpp:399
nmodl::codegen::CodegenInfo::functor_names
std::unordered_map< const ast::EigenNewtonSolverBlock *, std::string > functor_names
unique functor names for all the EigenNewtonSolverBlock s
Definition: codegen_info.hpp:446
nmodl::codegen::CodegenInfo::bbcore_pointer_used
bool bbcore_pointer_used
if bbcore pointer is used
Definition: codegen_info.hpp:230
nmodl::codegen::CodegenInfo::mod_suffix
std::string mod_suffix
name of the suffix
Definition: codegen_info.hpp:202
nmodl::codegen::CodegenInfo::procedures
std::vector< const ast::ProcedureBlock * > procedures
all procedures defined in the mod file
Definition: codegen_info.hpp:336
nmodl::codegen::CodegenInfo
Represent information collected from AST for code generation.
Definition: codegen_info.hpp:197
nmodl::codegen::CodegenInfo::global_variables
std::vector< SymbolType > global_variables
global variables
Definition: codegen_info.hpp:396
nmodl::codegen::CodegenInfo::table_count
int table_count
number of table statements
Definition: codegen_info.hpp:254
nmodl::codegen::CodegenInfo::first_pointer_var_index
int first_pointer_var_index
index/offset for first pointer variable if exist
Definition: codegen_info.hpp:382
nmodl::codegen::CodegenInfo::thread_safe
bool thread_safe
if mod file is thread safe (always true for coreneuron)
Definition: codegen_info.hpp:215
nmodl::codegen::Ion::writes
std::vector< std::string > writes
ion variables that are being written
Definition: codegen_info.hpp:61
nmodl::codegen::CodegenInfo::state_vars
std::vector< SymbolType > state_vars
all state variables
Definition: codegen_info.hpp:365
nmodl::codegen::CodegenInfo::watch_statements
std::vector< const ast::WatchStatement * > watch_statements
all watch statements
Definition: codegen_info.hpp:437
nmodl::codegen::CodegenInfo::semantic_variable_count
int semantic_variable_count
number of semantic variables
Definition: codegen_info.hpp:305
nmodl::codegen::CodegenInfo::thread_var_data_size
int thread_var_data_size
sum of length of thread promoted variables
Definition: codegen_info.hpp:283
nmodl::ast::InitialBlock
Represents a INITIAL block in the NMODL.
Definition: initial_block.hpp:49
nmodl::codegen::CodegenInfo::semantics
std::vector< IndexSemantics > semantics
index variable semantic information
Definition: codegen_info.hpp:425
nmodl::codegen::CodegenInfo::artificial_cell
bool artificial_cell
if mod file is artificial cell
Definition: codegen_info.hpp:221
nmodl::codegen::CodegenInfo::area_used
bool area_used
if area is used
Definition: codegen_info.hpp:245
nmodl::codegen::Ion::is_rev_potential
bool is_rev_potential(const std::string &text) const
Check if variable name is reveral potential.
Definition: codegen_info.hpp:105
nmodl::codegen::IndexSemantics::IndexSemantics
IndexSemantics(int index, std::string name, int size)
Definition: codegen_info.hpp:181
nmodl::codegen::IndexSemantics::name
std::string name
name/type of the variable (i.e. semantics)
Definition: codegen_info.hpp:175
nmodl::codegen::Ion::Ion
Ion()=delete
nmodl::ast::BreakpointBlock
Represents a BREAKPOINT block in NMODL.
Definition: breakpoint_block.hpp:53
nmodl::codegen::CodegenInfo::top_local_variables
std::vector< SymbolType > top_local_variables
local variables in the global scope
Definition: codegen_info.hpp:373
nmodl::codegen::Ion::need_style
bool need_style
if style semantic needed
Definition: codegen_info.hpp:64
nmodl::codegen::CodegenInfo::num_solve_blocks
int num_solve_blocks
number of solve blocks in mod file
Definition: codegen_info.hpp:292
nmodl::ast::DestructorBlock
Represents a DESTRUCTOR block in the NMODL.
Definition: destructor_block.hpp:53
nmodl::codegen::CodegenInfo::eigen_linear_solver_exist
bool eigen_linear_solver_exist
true if eigen linear solver is used
Definition: codegen_info.hpp:452
nmodl::codegen::CodegenInfo::thread_variables
std::vector< SymbolType > thread_variables
thread variables (e.g. global variables promoted to thread)
Definition: codegen_info.hpp:402
nmodl::ast::ConstructorBlock
Represents a CONSTRUCTOR block in the NMODL.
Definition: constructor_block.hpp:51
nmodl::codegen::CodegenInfo::top_blocks
std::vector< ast::Node * > top_blocks
all top level global blocks
Definition: codegen_info.hpp:431
nmodl::codegen::CodegenInfo::is_ionic_current
bool is_ionic_current(const std::string &name) const noexcept
if given variable is a ionic current
Definition: codegen_info.cpp:63
nmodl::codegen::CodegenInfo::variables_in_verbatim
std::unordered_set< std::string > variables_in_verbatim
all variables/symbols used in the verbatim block
Definition: codegen_info.hpp:443
nmodl::codegen::CodegenInfo::require_wrote_conc
bool require_wrote_conc
if we need a call back to wrote_conc in neuron/coreneuron
Definition: codegen_info.hpp:498
nmodl::codegen::IndexSemantics
Represent semantic information for index variable.
Definition: codegen_info.hpp:170
nmodl::codegen::Ion::is_intra_cell_conc
bool is_intra_cell_conc(const std::string &text) const
Check if variable name is internal cell concentration.
Definition: codegen_info.hpp:87
nmodl::codegen::IndexSemantics::size
int size
number of elements (typically one)
Definition: codegen_info.hpp:178
nmodl::codegen::CodegenInfo::breakpoint_node
const ast::BreakpointBlock * breakpoint_node
derivative block
Definition: codegen_info.hpp:312
nmodl::codegen::CodegenInfo::eigen_newton_solver_exist
bool eigen_newton_solver_exist
true if eigen newton solver is used
Definition: codegen_info.hpp:449
nmodl::codegen::Ion::is_extra_cell_conc
bool is_extra_cell_conc(const std::string &text) const
Check if variable name is external cell concentration.
Definition: codegen_info.hpp:96
nmodl::codegen::CodegenInfo::currents
std::vector< std::string > currents
non specific and ionic currents
Definition: codegen_info.hpp:428
nmodl::codegen::CodegenInfo::first_random_var_index
int first_random_var_index
index/offset for first RANDOM variable if exist
Definition: codegen_info.hpp:385
nmodl::codegen::CodegenInfo::point_process
bool point_process
if mod file is point process
Definition: codegen_info.hpp:218
nmodl::codegen::CodegenInfo::nrn_state_block
const ast::NrnStateBlock * nrn_state_block
nrn_state block
Definition: codegen_info.hpp:315
nmodl::codegen::CodegenInfo::vectorize
bool vectorize
true if mod file is vectorizable (which should be always true for coreneuron) But there are some bloc...
Definition: codegen_info.hpp:212
nmodl::codegen::Conductance::variable
std::string variable
ion variable like intra/extra concentration
Definition: codegen_info.hpp:42
nmodl::codegen::CodegenInfo::mod_file
std::string mod_file
name of mod file
Definition: codegen_info.hpp:199
nmodl::codegen::CodegenInfo::range_assigned_vars
std::vector< SymbolType > range_assigned_vars
range variables which are assigned variables as well
Definition: codegen_info.hpp:359
nmodl::codegen::CodegenInfo::functions_with_table
std::vector< const ast::Block * > functions_with_table
function or procedures with table statement
Definition: codegen_info.hpp:419
nmodl::codegen::Ion::is_ionic_conc
bool is_ionic_conc(const std::string &text) const
check if it is either internal or external concentration
Definition: codegen_info.hpp:110
nmodl::codegen::CodegenInfo::is_ion_write_variable
bool is_ion_write_variable(const std::string &name) const noexcept
if given variable is ion write variable
Definition: codegen_info.cpp:29
nmodl::codegen::CodegenInfo::function_tables
std::vector< const ast::FunctionTableBlock * > function_tables
all functions tables defined in the mod file
Definition: codegen_info.hpp:345
nmodl::codegen::CodegenInfo::primes_size
int primes_size
sum of length of all prime variables
Definition: codegen_info.hpp:298
ast.hpp
Auto generated AST classes declaration.
nmodl::codegen::CodegenInfo::function_uses_table
bool function_uses_table(const std::string &name) const noexcept
Definition: codegen_info.cpp:76
nmodl::codegen::CodegenInfo::net_event_used
bool net_event_used
if net_even function is used
Definition: codegen_info.hpp:239
nmodl::codegen::Ion::variable_index
int variable_index(const std::string &var_name) const
Variable index in the ion mechanism.
Definition: codegen_info.hpp:144
nmodl::codegen::CodegenInfo::derivimplicit_var_thread_id
int derivimplicit_var_thread_id
thread id for derivimplicit variables
Definition: codegen_info.hpp:286
nmodl::ast::NrnStateBlock
Represents the coreneuron nrn_state callback function.
Definition: nrn_state_block.hpp:39
nmodl::codegen::CodegenInfo::conductances
std::vector< Conductance > conductances
represent conductance statements used in mod file
Definition: codegen_info.hpp:422
nmodl::codegen::IndexSemantics::index
int index
start position in the int array
Definition: codegen_info.hpp:172
nmodl::codegen::CodegenInfo::emit_table_thread
bool emit_table_thread() const noexcept
Definition: codegen_info.hpp:480
nmodl::codegen::CodegenInfo::neuron_global_variables
std::vector< std::pair< SymbolType, std::string > > neuron_global_variables
[Core]NEURON global variables used (e.g. celsius) and their types
Definition: codegen_info.hpp:416
nmodl::codegen::CodegenInfo::electrode_current
bool electrode_current
if electrode current specified
Definition: codegen_info.hpp:224
nmodl::codegen::Ion::is_current_derivative
bool is_current_derivative(const std::string &text) const
Definition: codegen_info.hpp:122
nmodl::codegen::Ion::implicit_reads
std::vector< std::string > implicit_reads
ion variables that are being implicitly read
Definition: codegen_info.hpp:58
nmodl::codegen::CodegenInfo::net_receive_initial_node
const ast::InitialBlock * net_receive_initial_node
initial block within net receive block
Definition: codegen_info.hpp:324
nmodl::codegen::CodegenInfo::is_ion_read_variable
bool is_ion_read_variable(const std::string &name) const noexcept
if given variable is ion read variable
Definition: codegen_info.cpp:39
nmodl::codegen::CodegenInfo::factor_definitions
std::vector< const ast::FactorDef * > factor_definitions
all factors defined in the mod file
Definition: codegen_info.hpp:348
nmodl::codegen::CodegenInfo::prime_variables_by_order
std::vector< SymbolType > prime_variables_by_order
this is the order in which they appear in derivative block this is required while printing them in in...
Definition: codegen_info.hpp:409
nmodl::codegen::CodegenInfo::pointer_variables
std::vector< SymbolType > pointer_variables
pointer or bbcore pointer variables
Definition: codegen_info.hpp:376
nmodl::codegen::CodegenInfo::is_watch_used
bool is_watch_used() const noexcept
if watch statements are used
Definition: codegen_info.hpp:476
nmodl::codegen::CodegenInfo::thread_var_thread_id
int thread_var_thread_id
thread id for thread promoted variables
Definition: codegen_info.hpp:280
nmodl::codegen::CodegenInfo::nrn_state_has_eigen_solver_block
bool nrn_state_has_eigen_solver_block() const
true if EigenNewtonSolver is used in nrn_state block
Definition: codegen_info.cpp:87
nmodl::codegen::CodegenInfo::range_parameter_vars
std::vector< SymbolType > range_parameter_vars
range variables which are parameter as well
Definition: codegen_info.hpp:356
nmodl::codegen::CodegenInfo::top_local_thread_id
int top_local_thread_id
Top local variables are those local variables that appear in global scope.
Definition: codegen_info.hpp:274
nmodl::codegen::Conductance
Represent conductance statements used in mod file.
Definition: codegen_info.hpp:37
nmodl::codegen::CodegenInfo::SymbolType
std::shared_ptr< symtab::Symbol > SymbolType
Definition: codegen_info.hpp:353
nmodl::codegen::CodegenInfo::destructor_node
const ast::DestructorBlock * destructor_node
destructor block only for point process
Definition: codegen_info.hpp:333
nmodl::codegen::CodegenInfo::before_after_blocks
std::vector< const ast::Block * > before_after_blocks
all before after blocks
Definition: codegen_info.hpp:440
nmodl::codegen::CodegenInfo::is_ionic_conc
bool is_ionic_conc(const std::string &name) const noexcept
if given variable is a ionic concentration
Definition: codegen_info.cpp:70
nmodl::codegen::CodegenInfo::num_equations
int num_equations
number of equations (i.e.
Definition: codegen_info.hpp:302
nmodl::codegen::CodegenInfo::is_ion_variable
bool is_ion_variable(const std::string &name) const noexcept
if either read or write variable
Definition: codegen_info.cpp:49
nmodl::codegen::CodegenInfo::use_ion_variables
std::vector< SymbolType > use_ion_variables
new one used in print_ion_types
Definition: codegen_info.hpp:405
nmodl::codegen::CodegenInfo::is_current
bool is_current(const std::string &name) const noexcept
if given variable is a current
Definition: codegen_info.cpp:55
nmodl::codegen::CodegenInfo::assigned_vars
std::vector< SymbolType > assigned_vars
remaining assigned variables
Definition: codegen_info.hpp:362
nmodl::codegen::CodegenInfo::write_concentration
bool write_concentration
if write concentration call required in initial block
Definition: codegen_info.hpp:233
nmodl::codegen::CodegenInfo::random_variables
std::vector< SymbolType > random_variables
RANDOM variables.
Definition: codegen_info.hpp:379
nmodl::codegen::Ion::reads
std::vector< std::string > reads
ion variables that are being read
Definition: codegen_info.hpp:55
nmodl::codegen::CodegenInfo::range_state_vars
std::vector< SymbolType > range_state_vars
state variables excluding such useion read/write variables that are not ionic currents.
Definition: codegen_info.hpp:370
nmodl::codegen::Ion::is_ionic_current
bool is_ionic_current(const std::string &text) const
Check if variable name is a ionic current.
Definition: codegen_info.hpp:78
nmodl::codegen::Ion::Ion
Ion(std::string name)
Definition: codegen_info.hpp:68