User Guide
|
Represent information collected from AST for code generation. More...
Represent information collected from AST for code generation.
Code generation passes require different information from AST. This information is gathered in this single class.
Definition at line 197 of file codegen_info.hpp.
#include <codegen_info.hpp>
Public Types | |
using | SymbolType = std::shared_ptr< symtab::Symbol > |
Public Member Functions | |
bool | ion_has_write_variable () const noexcept |
if any ion has write variable More... | |
bool | is_ion_write_variable (const std::string &name) const noexcept |
if given variable is ion write variable More... | |
bool | is_ion_read_variable (const std::string &name) const noexcept |
if given variable is ion read variable More... | |
bool | is_ion_variable (const std::string &name) const noexcept |
if either read or write variable More... | |
bool | is_current (const std::string &name) const noexcept |
if given variable is a current More... | |
bool | is_ionic_current (const std::string &name) const noexcept |
if given variable is a ionic current More... | |
bool | is_ionic_conc (const std::string &name) const noexcept |
if given variable is a ionic concentration More... | |
bool | is_watch_used () const noexcept |
if watch statements are used More... | |
bool | emit_table_thread () const noexcept |
bool | derivimplicit_used () const |
if legacy derivimplicit solver from coreneuron to be used More... | |
bool | function_uses_table (const std::string &name) const noexcept |
bool | nrn_state_has_eigen_solver_block () const |
true if EigenNewtonSolver is used in nrn_state block More... | |
bool | is_voltage_used_by_watch_statements () const |
true if WatchStatement uses voltage v variable More... | |
Public Attributes | |
std::string | mod_file |
name of mod file More... | |
std::string | mod_suffix |
name of the suffix More... | |
std::string | rsuffix |
point process range and functions don't have suffix More... | |
bool | vectorize = true |
true if mod file is vectorizable (which should be always true for coreneuron) But there are some blocks like LINEAR are not thread safe in neuron or mod2c context. More... | |
bool | thread_safe = true |
if mod file is thread safe (always true for coreneuron) More... | |
bool | point_process = false |
if mod file is point process More... | |
bool | artificial_cell = false |
if mod file is artificial cell More... | |
bool | electrode_current = false |
if electrode current specified More... | |
bool | thread_callback_register = false |
if thread thread call back routines need to register More... | |
bool | bbcore_pointer_used = false |
if bbcore pointer is used More... | |
bool | write_concentration = false |
if write concentration call required in initial block More... | |
bool | net_send_used = false |
if net_send function is used More... | |
bool | net_event_used = false |
if net_even function is used More... | |
bool | diam_used = false |
if diam is used More... | |
bool | area_used = false |
if area is used More... | |
bool | for_netcon_used = false |
if for_netcon is used More... | |
int | watch_count = 0 |
number of watch expressions More... | |
int | table_count = 0 |
number of table statements More... | |
int | thread_data_index = 0 |
thread_data_index indicates number of threads being allocated. More... | |
int | top_local_thread_id = 0 |
Top local variables are those local variables that appear in global scope. More... | |
int | top_local_thread_size = 0 |
total length of all top local variables More... | |
int | thread_var_thread_id = 0 |
thread id for thread promoted variables More... | |
int | thread_var_data_size = 0 |
sum of length of thread promoted variables More... | |
int | derivimplicit_var_thread_id = -1 |
thread id for derivimplicit variables More... | |
int | derivimplicit_list_num = -1 |
slist/dlist id for derivimplicit block More... | |
int | num_solve_blocks = 0 |
number of solve blocks in mod file More... | |
int | num_primes = 0 |
number of primes (all state variables not necessary to be prime) More... | |
int | primes_size = 0 |
sum of length of all prime variables More... | |
int | num_equations = 0 |
number of equations (i.e. More... | |
int | semantic_variable_count |
number of semantic variables More... | |
bool | emit_cvode = false |
True if we have to emit CVODE code TODO: Figure out when this needs to be true. More... | |
const ast::BreakpointBlock * | breakpoint_node = nullptr |
derivative block More... | |
const ast::NrnStateBlock * | nrn_state_block = nullptr |
nrn_state block More... | |
const ast::NetReceiveBlock * | net_receive_node = nullptr |
net receive block for point process More... | |
int | num_net_receive_parameters = 0 |
number of arguments to net_receive block More... | |
const ast::InitialBlock * | net_receive_initial_node = nullptr |
initial block within net receive block More... | |
const ast::InitialBlock * | initial_node = nullptr |
initial block More... | |
const ast::ConstructorBlock * | constructor_node = nullptr |
constructor block More... | |
const ast::DestructorBlock * | destructor_node = nullptr |
destructor block only for point process More... | |
std::vector< const ast::ProcedureBlock * > | procedures |
all procedures defined in the mod file More... | |
std::vector< const ast::DerivimplicitCallback * > | derivimplicit_callbacks |
derivimplicit callbacks need to be emited More... | |
std::vector< const ast::FunctionBlock * > | functions |
all functions defined in the mod file More... | |
std::vector< const ast::FunctionTableBlock * > | function_tables |
all functions tables defined in the mod file More... | |
std::vector< const ast::FactorDef * > | factor_definitions |
all factors defined in the mod file More... | |
std::vector< Ion > | ions |
ions used in the mod file More... | |
std::vector< SymbolType > | range_parameter_vars |
range variables which are parameter as well More... | |
std::vector< SymbolType > | range_assigned_vars |
range variables which are assigned variables as well More... | |
std::vector< SymbolType > | assigned_vars |
remaining assigned variables More... | |
std::vector< SymbolType > | state_vars |
all state variables More... | |
std::vector< SymbolType > | range_state_vars |
state variables excluding such useion read/write variables that are not ionic currents. More... | |
std::vector< SymbolType > | top_local_variables |
local variables in the global scope More... | |
std::vector< SymbolType > | pointer_variables |
pointer or bbcore pointer variables More... | |
std::vector< SymbolType > | random_variables |
RANDOM variables. More... | |
int | first_pointer_var_index = -1 |
index/offset for first pointer variable if exist More... | |
int | first_random_var_index = -1 |
index/offset for first RANDOM variable if exist More... | |
int | tqitem_index = 0 |
tqitem index in integer variables note that if tqitem doesn't exist then the default value should be 0 More... | |
std::string | changed_dt |
updated dt to use with steadystate solver (in initial block) empty string means no change in dt More... | |
std::vector< SymbolType > | global_variables |
global variables More... | |
std::vector< SymbolType > | constant_variables |
constant variables More... | |
std::vector< SymbolType > | thread_variables |
thread variables (e.g. global variables promoted to thread) More... | |
std::vector< SymbolType > | use_ion_variables |
new one used in print_ion_types More... | |
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 initlist function More... | |
std::vector< SymbolType > | table_statement_variables |
table variables More... | |
std::vector< SymbolType > | table_assigned_variables |
std::vector< std::pair< SymbolType, std::string > > | neuron_global_variables |
[Core]NEURON global variables used (e.g. celsius) and their types More... | |
std::vector< const ast::Block * > | functions_with_table |
function or procedures with table statement More... | |
std::vector< Conductance > | conductances |
represent conductance statements used in mod file More... | |
std::vector< IndexSemantics > | semantics |
index variable semantic information More... | |
std::vector< std::string > | currents |
non specific and ionic currents More... | |
std::vector< ast::Node * > | top_blocks |
all top level global blocks More... | |
std::vector< ast::Node * > | top_verbatim_blocks |
all top level verbatim blocks More... | |
std::vector< const ast::WatchStatement * > | watch_statements |
all watch statements More... | |
std::vector< const ast::Block * > | before_after_blocks |
all before after blocks More... | |
std::unordered_set< std::string > | variables_in_verbatim |
all variables/symbols used in the verbatim block More... | |
std::unordered_map< const ast::EigenNewtonSolverBlock *, std::string > | functor_names |
unique functor names for all the EigenNewtonSolverBlock s More... | |
bool | eigen_newton_solver_exist = false |
true if eigen newton solver is used More... | |
bool | eigen_linear_solver_exist = false |
true if eigen linear solver is used More... | |
bool | require_wrote_conc = false |
if we need a call back to wrote_conc in neuron/coreneuron More... | |
using nmodl::codegen::CodegenInfo::SymbolType = std::shared_ptr<symtab::Symbol> |
Definition at line 353 of file codegen_info.hpp.
|
inline |
if legacy derivimplicit solver from coreneuron to be used
Definition at line 485 of file codegen_info.hpp.
|
inlinenoexcept |
Definition at line 480 of file codegen_info.hpp.
|
noexcept |
Definition at line 76 of file codegen_info.cpp.
|
noexcept |
if any ion has write variable
Definition at line 21 of file codegen_info.cpp.
|
noexcept |
if given variable is a current
if a current (ionic or non-specific)
Definition at line 55 of file codegen_info.cpp.
|
noexcept |
if given variable is ion read variable
Definition at line 39 of file codegen_info.cpp.
|
noexcept |
if either read or write variable
Definition at line 49 of file codegen_info.cpp.
|
noexcept |
if given variable is ion write variable
Definition at line 29 of file codegen_info.cpp.
|
noexcept |
if given variable is a ionic concentration
true if given variable name is a ionic concentration
Definition at line 70 of file codegen_info.cpp.
|
noexcept |
if given variable is a ionic current
true is a given variable name if a ionic current (i.e.
currents excluding non-specific current)
Definition at line 63 of file codegen_info.cpp.
bool nmodl::codegen::CodegenInfo::is_voltage_used_by_watch_statements | ( | ) | const |
true if WatchStatement uses voltage v variable
Check if WatchStatement uses voltage variable v.
Watch statement has condition expression which could use voltage variable v
. To avoid memory access into voltage array we check if v
is used and then print necessary code.
Definition at line 103 of file codegen_info.cpp.
|
inlinenoexcept |
if watch statements are used
Definition at line 476 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::nrn_state_has_eigen_solver_block | ( | ) | const |
true if EigenNewtonSolver is used in nrn_state block
Check if NrnState node in the AST has EigenSolverBlock node.
Definition at line 87 of file codegen_info.cpp.
bool nmodl::codegen::CodegenInfo::area_used = false |
if area is used
Definition at line 245 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::artificial_cell = false |
if mod file is artificial cell
Definition at line 221 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::assigned_vars |
remaining assigned variables
Definition at line 362 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::bbcore_pointer_used = false |
if bbcore pointer is used
Definition at line 230 of file codegen_info.hpp.
std::vector<const ast::Block*> nmodl::codegen::CodegenInfo::before_after_blocks |
all before after blocks
Definition at line 440 of file codegen_info.hpp.
const ast::BreakpointBlock* nmodl::codegen::CodegenInfo::breakpoint_node = nullptr |
derivative block
Definition at line 312 of file codegen_info.hpp.
std::string nmodl::codegen::CodegenInfo::changed_dt |
updated dt to use with steadystate solver (in initial block) empty string means no change in dt
Definition at line 393 of file codegen_info.hpp.
std::vector<Conductance> nmodl::codegen::CodegenInfo::conductances |
represent conductance statements used in mod file
Definition at line 422 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::constant_variables |
constant variables
Definition at line 399 of file codegen_info.hpp.
const ast::ConstructorBlock* nmodl::codegen::CodegenInfo::constructor_node = nullptr |
constructor block
Definition at line 330 of file codegen_info.hpp.
std::vector<std::string> nmodl::codegen::CodegenInfo::currents |
non specific and ionic currents
Definition at line 428 of file codegen_info.hpp.
std::vector<const ast::DerivimplicitCallback*> nmodl::codegen::CodegenInfo::derivimplicit_callbacks |
derivimplicit callbacks need to be emited
Definition at line 339 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::derivimplicit_list_num = -1 |
slist/dlist id for derivimplicit block
Definition at line 289 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::derivimplicit_var_thread_id = -1 |
thread id for derivimplicit variables
Definition at line 286 of file codegen_info.hpp.
const ast::DestructorBlock* nmodl::codegen::CodegenInfo::destructor_node = nullptr |
destructor block only for point process
Definition at line 333 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::diam_used = false |
if diam is used
Definition at line 242 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::eigen_linear_solver_exist = false |
true if eigen linear solver is used
Definition at line 452 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::eigen_newton_solver_exist = false |
true if eigen newton solver is used
Definition at line 449 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::electrode_current = false |
if electrode current specified
Definition at line 224 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::emit_cvode = false |
True if we have to emit CVODE code TODO: Figure out when this needs to be true.
Definition at line 309 of file codegen_info.hpp.
std::vector<const ast::FactorDef*> nmodl::codegen::CodegenInfo::factor_definitions |
all factors defined in the mod file
Definition at line 348 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::first_pointer_var_index = -1 |
index/offset for first pointer variable if exist
Definition at line 382 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::first_random_var_index = -1 |
index/offset for first RANDOM variable if exist
Definition at line 385 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::for_netcon_used = false |
if for_netcon is used
Definition at line 248 of file codegen_info.hpp.
std::vector<const ast::FunctionTableBlock*> nmodl::codegen::CodegenInfo::function_tables |
all functions tables defined in the mod file
Definition at line 345 of file codegen_info.hpp.
std::vector<const ast::FunctionBlock*> nmodl::codegen::CodegenInfo::functions |
all functions defined in the mod file
Definition at line 342 of file codegen_info.hpp.
std::vector<const ast::Block*> nmodl::codegen::CodegenInfo::functions_with_table |
function or procedures with table statement
Definition at line 419 of file codegen_info.hpp.
std::unordered_map<const ast::EigenNewtonSolverBlock*, std::string> nmodl::codegen::CodegenInfo::functor_names |
unique functor names for all the EigenNewtonSolverBlock
s
Definition at line 446 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::global_variables |
global variables
Definition at line 396 of file codegen_info.hpp.
const ast::InitialBlock* nmodl::codegen::CodegenInfo::initial_node = nullptr |
initial block
Definition at line 327 of file codegen_info.hpp.
std::vector<Ion> nmodl::codegen::CodegenInfo::ions |
ions used in the mod file
Definition at line 351 of file codegen_info.hpp.
std::string nmodl::codegen::CodegenInfo::mod_file |
name of mod file
Definition at line 199 of file codegen_info.hpp.
std::string nmodl::codegen::CodegenInfo::mod_suffix |
name of the suffix
Definition at line 202 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::net_event_used = false |
if net_even function is used
Definition at line 239 of file codegen_info.hpp.
const ast::InitialBlock* nmodl::codegen::CodegenInfo::net_receive_initial_node = nullptr |
initial block within net receive block
Definition at line 324 of file codegen_info.hpp.
const ast::NetReceiveBlock* nmodl::codegen::CodegenInfo::net_receive_node = nullptr |
net receive block for point process
Definition at line 318 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::net_send_used = false |
if net_send function is used
Definition at line 236 of file codegen_info.hpp.
std::vector<std::pair<SymbolType, std::string> > nmodl::codegen::CodegenInfo::neuron_global_variables |
[Core]NEURON global variables used (e.g. celsius) and their types
Definition at line 416 of file codegen_info.hpp.
const ast::NrnStateBlock* nmodl::codegen::CodegenInfo::nrn_state_block = nullptr |
nrn_state block
Definition at line 315 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::num_equations = 0 |
number of equations (i.e.
statements) in derivative block typically equal to number of primes
Definition at line 302 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::num_net_receive_parameters = 0 |
number of arguments to net_receive block
Definition at line 321 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::num_primes = 0 |
number of primes (all state variables not necessary to be prime)
Definition at line 295 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::num_solve_blocks = 0 |
number of solve blocks in mod file
Definition at line 292 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::point_process = false |
if mod file is point process
Definition at line 218 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::pointer_variables |
pointer or bbcore pointer variables
Definition at line 376 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::prime_variables_by_order |
this is the order in which they appear in derivative block this is required while printing them in initlist function
Definition at line 409 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::primes_size = 0 |
sum of length of all prime variables
Definition at line 298 of file codegen_info.hpp.
std::vector<const ast::ProcedureBlock*> nmodl::codegen::CodegenInfo::procedures |
all procedures defined in the mod file
Definition at line 336 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::random_variables |
RANDOM variables.
Definition at line 379 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::range_assigned_vars |
range variables which are assigned variables as well
Definition at line 359 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::range_parameter_vars |
range variables which are parameter as well
Definition at line 356 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::range_state_vars |
state variables excluding such useion read/write variables that are not ionic currents.
In neuron/mod2c these are stored in the list "rangestate".
Definition at line 370 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::require_wrote_conc = false |
if we need a call back to wrote_conc in neuron/coreneuron
Definition at line 498 of file codegen_info.hpp.
std::string nmodl::codegen::CodegenInfo::rsuffix |
point process range and functions don't have suffix
Definition at line 205 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::semantic_variable_count |
number of semantic variables
Definition at line 305 of file codegen_info.hpp.
std::vector<IndexSemantics> nmodl::codegen::CodegenInfo::semantics |
index variable semantic information
Definition at line 425 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::state_vars |
all state variables
Definition at line 365 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::table_assigned_variables |
Definition at line 413 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::table_count = 0 |
number of table statements
Definition at line 254 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::table_statement_variables |
table variables
Definition at line 412 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::thread_callback_register = false |
if thread thread call back routines need to register
Definition at line 227 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::thread_data_index = 0 |
thread_data_index indicates number of threads being allocated.
For example, if there is derivimplicit method used, then two thread structures are created. When we print global variables then thread_data_index is used to indicate whats next thread id to use.
Definition at line 262 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::thread_safe = true |
if mod file is thread safe (always true for coreneuron)
Definition at line 215 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::thread_var_data_size = 0 |
sum of length of thread promoted variables
Definition at line 283 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::thread_var_thread_id = 0 |
thread id for thread promoted variables
Definition at line 280 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::thread_variables |
thread variables (e.g. global variables promoted to thread)
Definition at line 402 of file codegen_info.hpp.
std::vector<ast::Node*> nmodl::codegen::CodegenInfo::top_blocks |
all top level global blocks
Definition at line 431 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::top_local_thread_id = 0 |
Top local variables are those local variables that appear in global scope.
Thread structure is created for top local variables and doesn't thread id 0. For example, if derivimplicit method is used then thread id 0 is assigned to those structures first. And then next thread id is assigned for top local variables. The idea of thread is assignement is to have same order for variables between neuron and coreneuron. thread id for top local variables
Definition at line 274 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::top_local_thread_size = 0 |
total length of all top local variables
Definition at line 277 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::top_local_variables |
local variables in the global scope
Definition at line 373 of file codegen_info.hpp.
std::vector<ast::Node*> nmodl::codegen::CodegenInfo::top_verbatim_blocks |
all top level verbatim blocks
Definition at line 434 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::tqitem_index = 0 |
tqitem index in integer variables note that if tqitem doesn't exist then the default value should be 0
Definition at line 389 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::use_ion_variables |
new one used in print_ion_types
Definition at line 405 of file codegen_info.hpp.
std::unordered_set<std::string> nmodl::codegen::CodegenInfo::variables_in_verbatim |
all variables/symbols used in the verbatim block
Definition at line 443 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::vectorize = true |
true if mod file is vectorizable (which should be always true for coreneuron) But there are some blocks like LINEAR are not thread safe in neuron or mod2c context.
In this case vectorize is used to determine number of float variable in the data array (e.g. v). For such non thread methods or blocks vectorize is false.
Definition at line 212 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::watch_count = 0 |
number of watch expressions
Definition at line 251 of file codegen_info.hpp.
std::vector<const ast::WatchStatement*> nmodl::codegen::CodegenInfo::watch_statements |
all watch statements
Definition at line 437 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::write_concentration = false |
if write concentration call required in initial block
Definition at line 233 of file codegen_info.hpp.