![]() |
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 335 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 | declared_thread_safe = false |
A mod file can be declared to be thread safe using the keyword THREADSAFE. 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_event 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::CvodeBlock * | cvode_block = nullptr |
the CVODE 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::map< std::string, LongitudinalDiffusionInfo > | longitudinal_diffusion_info |
for each state, the information needed to print the callbacks. 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 > | external_variables |
external variables 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 503 of file codegen_info.hpp.
|
inline |
if legacy derivimplicit solver from coreneuron to be used
Definition at line 638 of file codegen_info.hpp.
|
inlinenoexcept |
Definition at line 633 of file codegen_info.hpp.
|
noexcept |
Definition at line 120 of file codegen_info.cpp.
|
noexcept |
if any ion has write variable
Definition at line 65 of file codegen_info.cpp.
|
noexcept |
if given variable is a current
if a current (ionic or non-specific)
Definition at line 99 of file codegen_info.cpp.
|
noexcept |
if given variable is ion read variable
Definition at line 83 of file codegen_info.cpp.
|
noexcept |
if either read or write variable
Definition at line 93 of file codegen_info.cpp.
|
noexcept |
if given variable is ion write variable
Definition at line 73 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 114 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 107 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 147 of file codegen_info.cpp.
|
inlinenoexcept |
if watch statements are used
Definition at line 629 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 131 of file codegen_info.cpp.
bool nmodl::codegen::CodegenInfo::area_used = false |
if area is used
Definition at line 389 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::artificial_cell = false |
if mod file is artificial cell
Definition at line 365 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::assigned_vars |
remaining assigned variables
Definition at line 512 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::bbcore_pointer_used = false |
if bbcore pointer is used
Definition at line 374 of file codegen_info.hpp.
std::vector<const ast::Block*> nmodl::codegen::CodegenInfo::before_after_blocks |
all before after blocks
Definition at line 593 of file codegen_info.hpp.
const ast::BreakpointBlock* nmodl::codegen::CodegenInfo::breakpoint_node = nullptr |
derivative block
Definition at line 456 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 543 of file codegen_info.hpp.
std::vector<Conductance> nmodl::codegen::CodegenInfo::conductances |
represent conductance statements used in mod file
Definition at line 575 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::constant_variables |
constant variables
Definition at line 549 of file codegen_info.hpp.
const ast::ConstructorBlock* nmodl::codegen::CodegenInfo::constructor_node = nullptr |
constructor block
Definition at line 477 of file codegen_info.hpp.
std::vector<std::string> nmodl::codegen::CodegenInfo::currents |
non specific and ionic currents
Definition at line 581 of file codegen_info.hpp.
const ast::CvodeBlock* nmodl::codegen::CodegenInfo::cvode_block = nullptr |
the CVODE block
Definition at line 462 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::declared_thread_safe = false |
A mod file can be declared to be thread safe using the keyword THREADSAFE.
This boolean is true if and only if the mod file was declared thread safe by the user. For example thread variables require the mod file to be declared thread safe.
Definition at line 359 of file codegen_info.hpp.
std::vector<const ast::DerivimplicitCallback*> nmodl::codegen::CodegenInfo::derivimplicit_callbacks |
derivimplicit callbacks need to be emited
Definition at line 486 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::derivimplicit_list_num = -1 |
slist/dlist id for derivimplicit block
Definition at line 433 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::derivimplicit_var_thread_id = -1 |
thread id for derivimplicit variables
Definition at line 430 of file codegen_info.hpp.
const ast::DestructorBlock* nmodl::codegen::CodegenInfo::destructor_node = nullptr |
destructor block only for point process
Definition at line 480 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::diam_used = false |
if diam is used
Definition at line 386 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::eigen_linear_solver_exist = false |
true if eigen linear solver is used
Definition at line 605 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::eigen_newton_solver_exist = false |
true if eigen newton solver is used
Definition at line 602 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::electrode_current = false |
if electrode current specified
Definition at line 368 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 453 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::external_variables |
external variables
Definition at line 555 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 495 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 532 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 535 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::for_netcon_used = false |
if for_netcon is used
Definition at line 392 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 492 of file codegen_info.hpp.
std::vector<const ast::FunctionBlock*> nmodl::codegen::CodegenInfo::functions |
all functions defined in the mod file
Definition at line 489 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 572 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 599 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::global_variables |
global variables
Definition at line 546 of file codegen_info.hpp.
const ast::InitialBlock* nmodl::codegen::CodegenInfo::initial_node = nullptr |
initial block
Definition at line 474 of file codegen_info.hpp.
std::vector<Ion> nmodl::codegen::CodegenInfo::ions |
ions used in the mod file
Definition at line 501 of file codegen_info.hpp.
std::map<std::string, LongitudinalDiffusionInfo> nmodl::codegen::CodegenInfo::longitudinal_diffusion_info |
for each state, the information needed to print the callbacks.
Definition at line 498 of file codegen_info.hpp.
std::string nmodl::codegen::CodegenInfo::mod_file |
name of mod file
Definition at line 337 of file codegen_info.hpp.
std::string nmodl::codegen::CodegenInfo::mod_suffix |
name of the suffix
Definition at line 340 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::net_event_used = false |
if net_event function is used
Definition at line 383 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 471 of file codegen_info.hpp.
const ast::NetReceiveBlock* nmodl::codegen::CodegenInfo::net_receive_node = nullptr |
net receive block for point process
Definition at line 465 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::net_send_used = false |
if net_send function is used
Definition at line 380 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 569 of file codegen_info.hpp.
const ast::NrnStateBlock* nmodl::codegen::CodegenInfo::nrn_state_block = nullptr |
nrn_state block
Definition at line 459 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 446 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::num_net_receive_parameters = 0 |
number of arguments to net_receive block
Definition at line 468 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 439 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::num_solve_blocks = 0 |
number of solve blocks in mod file
Definition at line 436 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::point_process = false |
if mod file is point process
Definition at line 362 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::pointer_variables |
pointer or bbcore pointer variables
Definition at line 526 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 562 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::primes_size = 0 |
sum of length of all prime variables
Definition at line 442 of file codegen_info.hpp.
std::vector<const ast::ProcedureBlock*> nmodl::codegen::CodegenInfo::procedures |
all procedures defined in the mod file
Definition at line 483 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::random_variables |
RANDOM variables.
Definition at line 529 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 509 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::range_parameter_vars |
range variables which are parameter as well
Definition at line 506 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 520 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 651 of file codegen_info.hpp.
std::string nmodl::codegen::CodegenInfo::rsuffix |
point process range and functions don't have suffix
Definition at line 343 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::semantic_variable_count |
number of semantic variables
Definition at line 449 of file codegen_info.hpp.
std::vector<IndexSemantics> nmodl::codegen::CodegenInfo::semantics |
index variable semantic information
Definition at line 578 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::state_vars |
all state variables
Definition at line 515 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::table_assigned_variables |
Definition at line 566 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::table_count = 0 |
number of table statements
Definition at line 398 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::table_statement_variables |
table variables
Definition at line 565 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 371 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 406 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 353 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::thread_var_data_size = 0 |
sum of length of thread promoted variables
Definition at line 427 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::thread_var_thread_id = 0 |
thread id for thread promoted variables
Definition at line 424 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 552 of file codegen_info.hpp.
std::vector<ast::Node*> nmodl::codegen::CodegenInfo::top_blocks |
all top level global blocks
Definition at line 584 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 418 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::top_local_thread_size = 0 |
total length of all top local variables
Definition at line 421 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::top_local_variables |
local variables in the global scope
Definition at line 523 of file codegen_info.hpp.
std::vector<ast::Node*> nmodl::codegen::CodegenInfo::top_verbatim_blocks |
all top level verbatim blocks
Definition at line 587 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 539 of file codegen_info.hpp.
std::vector<SymbolType> nmodl::codegen::CodegenInfo::use_ion_variables |
new one used in print_ion_types
Definition at line 558 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 596 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 350 of file codegen_info.hpp.
int nmodl::codegen::CodegenInfo::watch_count = 0 |
number of watch expressions
Definition at line 395 of file codegen_info.hpp.
std::vector<const ast::WatchStatement*> nmodl::codegen::CodegenInfo::watch_statements |
all watch statements
Definition at line 590 of file codegen_info.hpp.
bool nmodl::codegen::CodegenInfo::write_concentration = false |
if write concentration call required in initial block
Definition at line 377 of file codegen_info.hpp.