User Guide
|
Visitor for printing C++ code compatible with legacy api of CoreNEURON More...
Visitor for printing C++ code compatible with legacy api of CoreNEURON
Definition at line 62 of file codegen_coreneuron_cpp_visitor.hpp.
#include <codegen_coreneuron_cpp_visitor.hpp>
Protected Member Functions | |
std::string | simulator_name () override |
Name of the simulator the code was generated for. More... | |
virtual std::string | backend_name () const override |
Name of the code generation backend. More... | |
int | num_thread_objects () const noexcept |
Determine the number of threads to allocate. More... | |
int | position_of_float_var (const std::string &name) const override |
Determine the position in the data array for a given float variable. More... | |
int | position_of_int_var (const std::string &name) const override |
Determine the position in the data array for a given int variable. More... | |
std::string | process_verbatim_token (const std::string &token) |
Process a token in a verbatim block for possible variable renaming. More... | |
virtual bool | is_constant_variable (const std::string &name) const |
Check if variable is qualified as constant. More... | |
virtual void | print_deriv_advance_flag_transfer_to_device () const |
Print the code to copy derivative advance flag to device. More... | |
virtual void | print_device_atomic_capture_annotation () const |
Print pragma annotation for increase and capture of variable in automatic way. More... | |
virtual void | print_net_send_buf_count_update_to_host () const |
Print the code to update NetSendBuffer_t count from device to host. More... | |
virtual void | print_net_send_buf_update_to_host () const |
Print the code to update NetSendBuffer_t from device to host. More... | |
virtual void | print_net_send_buf_count_update_to_device () const |
Print the code to update NetSendBuffer_t count from host to device. More... | |
virtual void | print_dt_update_to_device () const |
Print the code to update dt from host to device. More... | |
virtual void | print_device_stream_wait () const |
Print the code to synchronise/wait on stream specific to NrnThread. More... | |
virtual void | print_kernel_data_present_annotation_block_begin () |
Print accelerator annotations indicating data presence on device. More... | |
virtual void | print_kernel_data_present_annotation_block_end () |
Print matching block end of accelerator annotations for data presence on device. More... | |
virtual void | print_net_init_acc_serial_annotation_block_begin () |
Print accelerator kernels begin annotation for net_init kernel. More... | |
virtual void | print_net_init_acc_serial_annotation_block_end () |
Print accelerator kernels end annotation for net_init kernel. More... | |
virtual void | print_channel_iteration_block_parallel_hint (BlockType type, const ast::Block *block) |
Print pragma annotations for channel iterations. More... | |
virtual bool | nrn_cur_reduction_loop_required () |
Check if reduction block in nrn_cur required. More... | |
virtual void | print_rhs_d_shadow_variables () |
Print the setup method for setting matrix shadow vectors. More... | |
virtual void | print_nrn_cur_matrix_shadow_update () |
Print the update to matrix elements with/without shadow vectors. More... | |
virtual void | print_nrn_cur_matrix_shadow_reduction () |
Print the reduction to matrix elements from shadow vectors. More... | |
virtual void | print_atomic_reduction_pragma () override |
Print atomic update pragma for reduction statements. More... | |
virtual void | print_device_method_annotation () |
Print the backend specific device method annotation. More... | |
virtual void | print_global_method_annotation () |
Print backend specific global method annotation. More... | |
virtual void | print_backend_namespace_start () |
Prints the start of namespace for the backend-specific code. More... | |
virtual void | print_backend_namespace_stop () |
Prints the end of namespace for the backend-specific code. More... | |
virtual void | print_backend_includes () |
Print backend specific includes (none needed for C++ backend) More... | |
bool | optimize_ion_variable_copies () const override |
Check if ion variable copies should be avoided. More... | |
virtual void | print_memory_allocation_routine () const |
Print memory allocation routine. More... | |
virtual void | print_abort_routine () const |
Print backend specific abort routine. More... | |
virtual void | print_instance_struct_transfer_routine_declarations () |
Print declarations of the functions used by print_instance_struct_copy_to_device and print_instance_struct_delete_from_device. More... | |
virtual void | print_instance_struct_transfer_routines (std::vector< std::string > const &) |
Print the definitions of the functions used by print_instance_struct_copy_to_device and print_instance_struct_delete_from_device. More... | |
virtual void | print_instance_struct_copy_to_device () |
Transfer the instance struct to the device. More... | |
virtual void | print_instance_struct_delete_from_device () |
Delete the instance struct from the device. More... | |
void | print_top_verbatim_blocks () |
Print top level (global scope) verbatim blocks. More... | |
void | print_function_prototypes () override |
Print function and procedures prototype declaration. More... | |
std::tuple< bool, int > | check_if_var_is_array (const std::string &name) |
Check if the given name exist in the symbol. More... | |
void | print_table_check_function (const ast::Block &node) |
Print check_function() for functions or procedure using table. More... | |
void | print_table_replacement_function (const ast::Block &node) |
Print replacement function for function or procedure using table. More... | |
void | print_check_table_thread_function () |
Print check_table functions. More... | |
void | print_function_or_procedure (const ast::Block &node, const std::string &name) override |
Print nmodl function or procedure (common code) More... | |
void | print_function_procedure_helper (const ast::Block &node) override |
Common helper function to help printing function or procedure blocks. More... | |
virtual void | print_procedure (const ast::ProcedureBlock &node) override |
Print NMODL procedure in target backend code. More... | |
void | print_function (const ast::FunctionBlock &node) override |
Print NMODL function in target backend code. More... | |
void | print_function_tables (const ast::FunctionTableBlock &node) |
Print NMODL function_table in target backend code. More... | |
bool | is_functor_const (const ast::StatementBlock &variable_block, const ast::StatementBlock &functor_block) |
Checks whether the functor_block generated by sympy solver modifies any variable outside its scope. More... | |
void | print_functor_definition (const ast::EigenNewtonSolverBlock &node) |
Based on the EigenNewtonSolverBlock passed print the definition needed for its functor. More... | |
virtual void | print_eigen_linear_solver (const std::string &float_type, int N) |
std::string | internal_method_arguments () override |
Arguments for functions that are defined and used internally. More... | |
ParamVector | internal_method_parameters () override |
Parameters for internally defined functions. More... | |
const char * | external_method_arguments () noexcept override |
Arguments for external functions called from generated code. More... | |
const char * | external_method_parameters (bool table=false) noexcept override |
Parameters for functions in generated code that are called back from external code. More... | |
std::string | nrn_thread_arguments () const override |
Arguments for "_threadargs_" macro in neuron implementation. More... | |
std::string | nrn_thread_internal_arguments () override |
Arguments for "_threadargs_" macro in neuron implementation. More... | |
std::string | replace_if_verbatim_variable (std::string name) |
Replace commonly used verbatim variables. More... | |
std::string | process_verbatim_text (std::string const &text) override |
Process a verbatim block for possible variable renaming. More... | |
std::string | register_mechanism_arguments () const override |
Arguments for register_mech or point_register_mech function. More... | |
std::string | conc_write_statement (const std::string &ion_name, const std::string &concentration, int index) override |
Generate Function call statement for nrn_wrote_conc. More... | |
void | print_first_pointer_var_index_getter () |
Print the getter method for index position of first pointer variable. More... | |
void | print_first_random_var_index_getter () |
Print the getter method for index position of first RANDOM variable. More... | |
void | print_num_variable_getter () |
Print the getter methods for float and integer variables count. More... | |
void | print_net_receive_arg_size_getter () |
Print the getter method for getting number of arguments for net_receive. More... | |
void | print_mech_type_getter () |
Print the getter method for returning mechtype. More... | |
void | print_memb_list_getter () |
Print the getter method for returning membrane list from NrnThread. More... | |
void | print_namespace_start () override |
Prints the start of the coreneuron namespace. More... | |
void | print_namespace_stop () override |
Prints the end of the coreneuron namespace. More... | |
void | print_thread_getters () |
Print the getter method for thread variables and ids. More... | |
std::string | float_variable_name (const SymbolType &symbol, bool use_instance) const override |
Determine the name of a float variable given its symbol. More... | |
std::string | int_variable_name (const IndexVariableInfo &symbol, const std::string &name, bool use_instance) const override |
Determine the name of an int variable given its symbol. More... | |
std::string | global_variable_name (const SymbolType &symbol, bool use_instance=true) const override |
Determine the variable name for a global variable given its symbol. More... | |
std::string | get_variable_name (const std::string &name, bool use_instance=true) const override |
Determine variable name in the structure of mechanism properties. More... | |
void | print_backend_info () override |
Print top file header printed in generated code. More... | |
void | print_standard_includes () override |
Print standard C/C++ includes. More... | |
void | print_coreneuron_includes () |
Print includes from coreneuron. More... | |
void | print_sdlists_init (bool print_initializers) override |
void | print_mechanism_global_var_structure (bool print_initializers) override |
Print the structure that wraps all global variables used in the NMODL. More... | |
void | print_global_variables_for_hoc () override |
Print byte arrays that register scalar and vector variables for hoc interface. More... | |
void | print_mechanism_register () override |
Print the mechanism registration function. More... | |
void | print_thread_memory_callbacks () |
Print thread related memory allocation and deallocation callbacks. More... | |
void | print_ion_var_structure () |
Print structure of ion variables used for local copies. More... | |
virtual void | print_ion_var_constructor (const std::vector< std::string > &members) |
Print constructor of ion variables. More... | |
virtual void | print_ion_variable () |
Print the ion variable struct. More... | |
virtual void | print_global_variable_device_update_annotation () |
Print the pragma annotation to update global variables from host to the device. More... | |
void | print_setup_range_variable () |
Print the function that initialize range variable with different data type. More... | |
std::string | get_range_var_float_type (const SymbolType &symbol) |
Returns floating point type for given range variable symbol. More... | |
void | print_initial_block (const ast::InitialBlock *node) |
Print initial block statements. More... | |
virtual void | print_global_function_common_code (BlockType type, const std::string &function_name="") override |
Print common code for global functions like nrn_init, nrn_cur and nrn_state. More... | |
void | print_nrn_init (bool skip_init_check=true) |
Print the nrn_init function definition. More... | |
virtual void | print_before_after_block (const ast::Block *node, size_t block_id) |
Print NMODL before / after block in target backend code. More... | |
void | print_nrn_constructor () override |
Print nrn_constructor function definition. More... | |
void | print_nrn_destructor () override |
Print nrn_destructor function definition. More... | |
void | print_functors_definitions () |
Go through the map of EigenNewtonSolverBlock s and their corresponding functor names and print the functor definitions before the definitions of the functions of the generated file. More... | |
void | print_nrn_alloc () override |
Print nrn_alloc function definition. More... | |
void | print_watch_activate () |
Print watch activate function. More... | |
void | print_watch_check () |
Print watch activate function. More... | |
void | print_net_receive_common_code (const ast::Block &node, bool need_mech_inst=true) |
Print the common code section for net receive related methods. More... | |
void | print_net_send_call (const ast::FunctionCall &node) override |
Print call to net_send . More... | |
void | print_net_move_call (const ast::FunctionCall &node) override |
Print call to net_move. More... | |
void | print_net_event_call (const ast::FunctionCall &node) override |
Print call to net_event. More... | |
void | print_net_init () |
Print initial block in the net receive block. More... | |
void | print_send_event_move () |
Print send event move block used in net receive as well as watch. More... | |
virtual std::string | net_receive_buffering_declaration () |
Generate the target backend code for the net_receive_buffering function delcaration. More... | |
virtual void | print_get_memb_list () |
Print the target backend code for defining and checking a local Memb_list variable. More... | |
virtual void | print_net_receive_loop_begin () |
Print the code for the main net_receive loop. More... | |
virtual void | print_net_receive_loop_end () |
Print the code for closing the main net_receive loop. More... | |
void | print_net_receive_buffering (bool need_mech_inst=true) |
Print kernel for buffering net_receive events. More... | |
virtual void | print_net_send_buffering_cnt_update () const |
Print the code related to the update of NetSendBuffer_t cnt. More... | |
virtual void | print_net_send_buffering_grow () |
Print statement that grows NetSendBuffering_t structure if needed. More... | |
void | print_net_send_buffering () |
Print kernel for buffering net_send events. More... | |
void | print_net_receive_kernel () |
Print net_receive kernel function definition. More... | |
void | print_net_receive () |
Print net_receive function definition. More... | |
void | print_derivimplicit_kernel (const ast::Block &block) |
Print derivative kernel when derivimplicit method is used. More... | |
virtual void | print_newtonspace_transfer_to_device () const |
Print code block to transfer newtonspace structure to device. More... | |
void | print_nrn_state () override |
Print nrn_state / state update function definition. More... | |
void | print_nrn_current (const ast::BreakpointBlock &node) override |
Print the nrn_current kernel. More... | |
void | print_nrn_cur_conductance_kernel (const ast::BreakpointBlock &node) override |
Print the nrn_cur kernel with NMODL conductance keyword provisions. More... | |
void | print_nrn_cur_non_conductance_kernel () override |
Print the nrn_cur kernel without NMODL conductance keyword provisions. More... | |
void | print_nrn_cur_kernel (const ast::BreakpointBlock &node) override |
Print main body of nrn_cur function. More... | |
virtual void | print_fast_imem_calculation () override |
Print fast membrane current calculation code. More... | |
void | print_nrn_cur () override |
Print nrn_cur / current update function definition. More... | |
void | print_headers_include () override |
Print all includes. More... | |
void | print_namespace_begin () override |
Print start of namespaces. More... | |
void | print_namespace_end () override |
Print end of namespaces. More... | |
void | print_common_getters () |
Print common getters. More... | |
void | print_data_structures (bool print_initializers) override |
Print all classes. More... | |
void | print_v_unused () const override |
Set v_unused (voltage) for NRN_PRCELLSTATE feature. More... | |
void | print_g_unused () const override |
Set g_unused (conductance) for NRN_PRCELLSTATE feature. More... | |
virtual void | print_compute_functions () override |
Print all compute functions for every backend. More... | |
virtual void | print_codegen_routines () override |
Print entry point to code generation. More... | |
void | visit_derivimplicit_callback (const ast::DerivimplicitCallback &node) override |
visit node of type ast::DerivimplicitCallback More... | |
void | visit_eigen_newton_solver_block (const ast::EigenNewtonSolverBlock &node) override |
visit node of type ast::EigenNewtonSolverBlock More... | |
void | visit_eigen_linear_solver_block (const ast::EigenLinearSolverBlock &node) override |
visit node of type ast::EigenLinearSolverBlock More... | |
void | visit_for_netcon (const ast::ForNetcon &node) override |
visit node of type ast::ForNetcon More... | |
virtual void | visit_watch_statement (const ast::WatchStatement &node) override |
visit node of type ast::WatchStatement More... | |
template<typename T > | |
void | print_function_declaration (const T &node, const std::string &name) |
Print prototype declarations of functions or procedures. More... | |
Protected Member Functions inherited from nmodl::codegen::CodegenCppVisitor | |
std::string | nmodl_version () const noexcept |
Return Nmodl language version. More... | |
std::string | instance_struct () const |
Name of structure that wraps range variables. More... | |
std::string | node_data_struct () const |
Name of structure that wraps node variables. More... | |
std::string | global_struct () const |
Name of structure that wraps global variables. More... | |
std::string | global_struct_instance () const |
Name of the (host-only) global instance of global_struct More... | |
const char * | local_var_type () const noexcept |
Data type for the local variables. More... | |
const char * | default_float_data_type () const noexcept |
Default data type for floating point elements. More... | |
const std::string & | float_data_type () const noexcept |
Data type for floating point elements specified on command line. More... | |
const char * | default_int_data_type () const noexcept |
Default data type for integer (offset) elements. More... | |
const char * | operator_for_rhs () const noexcept |
Operator for rhs vector update (matrix update) More... | |
const char * | operator_for_d () const noexcept |
Operator for diagonal vector update (matrix update) More... | |
std::string | get_channel_info_var_name () const noexcept |
Name of channel info variable. More... | |
bool | ion_variable_struct_required () const |
Check if a structure for ion variables is required. More... | |
template<typename T > | |
bool | has_parameter_of_name (const T &node, const std::string &name) |
Check if function or procedure node has parameter with given name. More... | |
bool | net_send_buffer_required () const noexcept |
Check if net_send_buffer is required. More... | |
bool | net_receive_buffering_required () const noexcept |
Check if net receive/send buffering kernels required. More... | |
bool | nrn_state_required () const noexcept |
Check if nrn_state function is required. More... | |
bool | nrn_cur_required () const noexcept |
Check if nrn_cur function is required. More... | |
bool | net_receive_required () const noexcept |
Check if net_receive function is required. More... | |
bool | range_variable_setup_required () const noexcept |
Check if setup_range_variable function is required. More... | |
bool | net_receive_exist () const noexcept |
Check if net_receive node exist. More... | |
bool | breakpoint_exist () const noexcept |
Check if breakpoint node exist. More... | |
bool | defined_method (const std::string &name) const |
Check if given method is defined in this model. More... | |
bool | is_net_send (const std::string &name) const noexcept |
Checks if given function name is net_send . More... | |
bool | is_net_move (const std::string &name) const noexcept |
Checks if given function name is net_move . More... | |
bool | is_net_event (const std::string &name) const noexcept |
Checks if given function name is net_event . More... | |
int | float_variables_size () const |
Number of float variables in the model. More... | |
int | int_variables_size () const |
Number of integer variables in the model. More... | |
std::string | format_double_string (const std::string &value) |
Convert a given double value to its string representation. More... | |
std::string | format_float_string (const std::string &value) |
Convert a given float value to its string representation. More... | |
void | update_index_semantics () |
populate all index semantics needed for registration with coreneuron More... | |
std::vector< SymbolType > | get_float_variables () const |
Determine all float variables required during code generation. More... | |
std::vector< IndexVariableInfo > | get_int_variables () |
Determine all int variables required during code generation. More... | |
std::vector< std::string > | ion_read_statements (BlockType type) const |
For a given output block type, return statements for all read ion variables. More... | |
std::vector< std::string > | ion_read_statements_optimized (BlockType type) const |
For a given output block type, return minimal statements for all read ion variables. More... | |
std::vector< ShadowUseStatement > | ion_write_statements (BlockType type) |
For a given output block type, return statements for writing back ion variables. More... | |
std::string | process_shadow_update_statement (const ShadowUseStatement &statement, BlockType type) |
Process shadow update statement. More... | |
std::string | breakpoint_current (std::string current) const |
Determine the variable name for the "current" used in breakpoint block taking into account intermediate code transformations. More... | |
virtual void | print_global_var_struct_decl () |
Instantiate global var instance. More... | |
void | print_statement_block (const ast::StatementBlock &node, bool open_brace=true, bool close_brace=true) |
Print any statement block in nmodl with option to (not) print braces. More... | |
virtual void | print_function_call (const ast::FunctionCall &node) |
Print call to internal or external function. More... | |
void | rename_function_arguments () |
Rename function/procedure arguments that conflict with default arguments. More... | |
template<typename T > | |
void | print_vector_elements (const std::vector< T > &elements, const std::string &separator, const std::string &prefix="") |
Print the items in a vector as a list. More... | |
std::string | add_escape_quote (const std::string &text) const |
Add quotes to string to be output. More... | |
std::string | method_name (const std::string &name) const |
Constructs the name of a function or procedure. More... | |
SymbolType | make_symbol (const std::string &name) const |
Creates a temporary symbol. More... | |
std::string | update_if_ion_variable_name (const std::string &name) const |
Determine the updated name if the ion variable has been optimized. More... | |
virtual void | print_global_var_struct_assertions () const |
Print static assertions about the global variable struct. More... | |
void | print_prcellstate_macros () const |
Print declaration of macro NRN_PRCELLSTATE for debugging. More... | |
void | print_mechanism_info () |
Print backend code for byte array that has mechanism information (to be registered with NEURON/CoreNEURON) More... | |
void | print_nmodl_constants () |
Print the nmodl constants used in backend code. More... | |
void | visit_binary_expression (const ast::BinaryExpression &node) override |
visit node of type ast::BinaryExpression More... | |
void | visit_binary_operator (const ast::BinaryOperator &node) override |
visit node of type ast::BinaryOperator More... | |
void | visit_boolean (const ast::Boolean &node) override |
visit node of type ast::Boolean More... | |
void | visit_double (const ast::Double &node) override |
visit node of type ast::Double More... | |
void | visit_else_if_statement (const ast::ElseIfStatement &node) override |
visit node of type ast::ElseIfStatement More... | |
void | visit_else_statement (const ast::ElseStatement &node) override |
visit node of type ast::ElseStatement More... | |
void | visit_float (const ast::Float &node) override |
visit node of type ast::Float More... | |
void | visit_from_statement (const ast::FromStatement &node) override |
visit node of type ast::FromStatement More... | |
void | visit_function_call (const ast::FunctionCall &node) override |
visit node of type ast::FunctionCall More... | |
void | visit_if_statement (const ast::IfStatement &node) override |
visit node of type ast::IfStatement More... | |
void | visit_indexed_name (const ast::IndexedName &node) override |
visit node of type ast::IndexedName More... | |
void | visit_integer (const ast::Integer &node) override |
visit node of type ast::Integer More... | |
void | visit_local_list_statement (const ast::LocalListStatement &node) override |
visit node of type ast::LocalListStatement More... | |
void | visit_name (const ast::Name &node) override |
visit node of type ast::Name More... | |
void | visit_paren_expression (const ast::ParenExpression &node) override |
visit node of type ast::ParenExpression More... | |
void | visit_prime_name (const ast::PrimeName &node) override |
visit node of type ast::PrimeName More... | |
void | visit_statement_block (const ast::StatementBlock &node) override |
void | visit_string (const ast::String &node) override |
visit node of type ast::String More... | |
void | visit_unary_operator (const ast::UnaryOperator &node) override |
visit node of type ast::UnaryOperator More... | |
void | visit_unit (const ast::Unit &node) override |
visit node of type ast::Unit More... | |
void | visit_var_name (const ast::VarName &node) override |
void | visit_verbatim (const ast::Verbatim &node) override |
visit node of type ast::Verbatim More... | |
void | visit_while_statement (const ast::WhileStatement &node) override |
visit node of type ast::WhileStatement More... | |
void | visit_update_dt (const ast::UpdateDt &node) override |
visit node of type ast::UpdateDt More... | |
void | visit_protect_statement (const ast::ProtectStatement &node) override |
visit node of type ast::ProtectStatement More... | |
void | visit_mutex_lock (const ast::MutexLock &node) override |
visit node of type ast::MutexLock More... | |
void | visit_mutex_unlock (const ast::MutexUnlock &node) override |
visit node of type ast::MutexUnlock More... | |
void | visit_solution_expression (const ast::SolutionExpression &node) override |
visit node of type ast::SolutionExpression More... | |
std::string | compute_method_name (BlockType type) const |
Additional Inherited Members | |
Protected Types inherited from nmodl::codegen::CodegenCppVisitor | |
using | SymbolType = std::shared_ptr< symtab::Symbol > |
using | ParamVector = std::vector< std::tuple< std::string, std::string, std::string, std::string > > |
A vector of parameters represented by a 4-tuple of strings: More... | |
Static Protected Member Functions inherited from nmodl::codegen::CodegenCppVisitor | |
static bool | need_semicolon (const ast::Statement &node) |
Check if a semicolon is required at the end of given statement. More... | |
static std::string | get_parameter_str (const ParamVector ¶ms) |
Generate the string representing the procedure parameter declaration. More... | |
static bool | statement_to_skip (const ast::Statement &node) |
Check if given statement should be skipped during code generation. More... | |
static std::pair< std::string, std::string > | read_ion_variable_name (const std::string &name) |
Return ion variable name and corresponding ion read variable name. More... | |
static std::pair< std::string, std::string > | write_ion_variable_name (const std::string &name) |
Return ion variable name and corresponding ion write variable name. More... | |
Protected Attributes inherited from nmodl::codegen::CodegenCppVisitor | |
std::unique_ptr< CodePrinter > | printer |
Code printer object for target (C++) More... | |
std::string | mod_filename |
Name of mod file (without .mod suffix) More... | |
std::string | float_type = codegen::naming::DEFAULT_FLOAT_TYPE |
Data type of floating point variables. More... | |
bool | optimize_ionvar_copies = true |
Flag to indicate if visitor should avoid ion variable copies. More... | |
codegen::CodegenInfo | info |
All ast information for code generation. More... | |
symtab::SymbolTable * | program_symtab = nullptr |
Symbol table for the program. More... | |
std::vector< SymbolType > | codegen_float_variables |
All float variables for the model. More... | |
std::vector< IndexVariableInfo > | codegen_int_variables |
All int variables for the model. More... | |
std::vector< SymbolType > | codegen_global_variables |
All global variables for the model. More... | |
bool | enable_variable_name_lookup = true |
Variable name should be converted to instance name (but not for function arguments) More... | |
bool | printing_net_receive = false |
true if currently net_receive block being printed More... | |
bool | printing_net_init = false |
true if currently initial block of net_receive being printed More... | |
bool | printing_top_verbatim_blocks = false |
true if currently printing top level verbatim blocks More... | |
bool | internal_method_call_encountered = false |
true if internal method call was encountered while processing verbatim block More... | |
int | current_watch_statement = 0 |
Index of watch statement being printed. More... | |
|
overrideprotectedvirtual |
Name of the code generation backend.
Implements nmodl::codegen::CodegenCppVisitor.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 51 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Check if the given name exist in the symbol.
return
a tuple <true, array_length> if variable is an array otherwise <false, 0> Definition at line 424 of file codegen_coreneuron_cpp_visitor.cpp.
|
inline |
Constructs the C++ code generator visitor.
This constructor instantiates an NMODL C++ code generator and allows writing generated code directly to a file in [output_dir]/[mod_filename].cpp.
AstVisitor
the AST must be visited using e.g. visit_program
in order to generate the C++ code corresponding to the AST.mod_filename | The name of the model for which code should be generated. It is used for constructing an output filename. |
output_dir | The directory where target C++ file should be generated. |
float_type | The float type to use in the generated code. The string will be used as-is in the target code. This defaults to double . |
Definition at line 198 of file codegen_cpp_visitor.hpp.
|
inline |
Constructs the C++ code generator visitor.
This constructor instantiates an NMODL C++ code generator and allows writing generated code into an output stream.
AstVisitor
the AST must be visited using e.g. visit_program
in order to generate the C++ code corresponding to the AST.mod_filename | The name of the model for which code should be generated. It is used for constructing an output filename. |
stream | The output stream onto which to write the generated code |
float_type | The float type to use in the generated code. The string will be used as-is in the target code. This defaults to double . |
Definition at line 226 of file codegen_cpp_visitor.hpp.
|
overrideprotectedvirtual |
Generate Function call statement for nrn_wrote_conc.
ion_name | The name of the ion variable |
concentration | The name of the concentration variable |
index |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1053 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtualnoexcept |
Arguments for external functions called from generated code.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 939 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtualnoexcept |
Parameters for functions in generated code that are called back from external code.
Functions registered in NEURON during initialization for callback must adhere to a prescribed calling convention. This method generates the string representing the function parameters for these externally called functions.
table |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 944 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Determine the name of a float
variable given its symbol.
This function typically returns the accessor expression in backend code for the given symbol. Since the model variables are stored in data arrays and accessed by offset, this function will return the C++ string representing the array access at the correct offset
symbol | The symbol of a variable for which we want to obtain its name |
use_instance | Should the variable be accessed via instance or data array |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1218 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Returns floating point type for given range variable symbol.
symbol | A range variable symbol |
If floating point type like "float" is specified on command line then we can't turn all variables to new type. This is because certain variables are pointers to internal variables (e.g. ions). Hence, we check if given variable can be safely converted to new type. If so, return new type.
Definition at line 2057 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Determine variable name in the structure of mechanism properties.
name | Variable name that is being printed |
use_instance | Should the variable be accessed via instance or data array |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1274 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Determine the variable name for a global variable given its symbol.
symbol | The symbol of a variable for which we want to obtain its name |
use_instance | Should the variable be accessed via the (host-only) global variable or the instance-specific copy (also available on GPU). |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1264 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Determine the name of an int
variable given its symbol.
This function typically returns the accessor expression in backend code for the given symbol. Since the model variables are stored in data arrays and accessed by offset, this function will return the C++ string representing the array access at the correct offset
symbol | The symbol of a variable for which we want to obtain its name |
name | The name of the index variable |
use_instance | Should the variable be accessed via instance or data array |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1238 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Arguments for functions that are defined and used internally.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 911 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Parameters for internally defined functions.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 922 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Check if variable is qualified as constant.
name | The name of variable |
true
if it is constantThis can be override in the backend. For example, parameters can be constant except in INITIAL block where they are set to 0. As initial block is/can be executed on c++/cpu backend, gpu backend can mark the parameter as constant.
Definition at line 130 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Checks whether the functor_block generated by sympy solver modifies any variable outside its scope.
If it does then return false, so that the operator() of the struct functor of the Eigen Newton solver doesn't have const qualifier.
variable_block | Statement Block of the variables declarations used in the functor struct of the solver |
functor_block | Actual code being printed in the operator() of the functor struct of the solver |
Definition at line 766 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Generate the target backend code for the net_receive_buffering
function delcaration.
Definition at line 2816 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Check if reduction block in nrn_cur
required.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 259 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Arguments for "_threadargs_" macro in neuron implementation.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 954 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Arguments for "_threadargs_" macro in neuron implementation.
Function call arguments when function or procedure is defined in the same mod file itself.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 966 of file codegen_coreneuron_cpp_visitor.cpp.
|
inlineprotectednoexcept |
Determine the number of threads to allocate.
Definition at line 92 of file codegen_coreneuron_cpp_visitor.hpp.
|
overrideprotectedvirtual |
Check if ion variable copies should be avoided.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 331 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Determine the position in the data array for a given float variable.
name | The name of a float variable |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 66 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Determine the position in the data array for a given int variable.
name | The name of an int variable |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 78 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print backend specific abort routine.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 353 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print atomic update pragma for reduction statements.
In the current implementation of CPU/CPP backend we need to emit atomic pragma only with PROTECT construct (atomic rduction requirement for other cases on CPU is handled via separate shadow vectors).
Implements nmodl::codegen::CodegenCppVisitor.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 301 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print backend specific includes (none needed for C++ backend)
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 326 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print top file header printed in generated code.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1347 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Prints the start of namespace for the backend-specific code.
For the C++ backend no additional namespace is required
Definition at line 316 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Prints the end of namespace for the backend-specific code.
For the C++ backend no additional namespace is required
Definition at line 321 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print NMODL before / after block in target backend code.
node | AST node of type before/after type being printed |
block_id | Index of the before/after block |
name of the before/after function
print common function code like init/state/current
print main body
loop end including data annotation block
Definition at line 2372 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print pragma annotations for channel iterations.
This can be overriden by backends to provide additonal annotations or pragmas to enable for example SIMD code generation (e.g. through ivdep
) The default implementation prints
type | The block type |
Depending programming model and compiler, we print compiler hint for parallelization. For example:
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 236 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print check_table functions.
Definition at line 644 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print entry point to code generation.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3463 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print common getters.
Definition at line 3393 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print all compute functions for every backend.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3432 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print includes from coreneuron.
Definition at line 1378 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print all classes.
print_initializers | Whether to include default values. |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3404 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the code to copy derivative advance flag to device.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 155 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print derivative kernel when derivimplicit
method is used.
block | The corresponding AST node representing an NMODL derivimplicit block |
Need to add instance into instance struct? data used here is wrong in AoS because as in original implementation, data is not incremented every iteration for AoS. May be better to derive actual variable names? [resolved now?] slist needs to added as local variable
Definition at line 3028 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print pragma annotation for increase and capture of variable in automatic way.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 160 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the backend specific device method annotation.
Definition at line 306 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the code to synchronise/wait on stream specific to NrnThread.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 185 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the code to update dt from host to device.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 180 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Definition at line 869 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print fast membrane current calculation code.
Implements nmodl::codegen::CodegenCppVisitor.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 3308 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the getter method for index position of first pointer variable.
Definition at line 1080 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the getter method for index position of first RANDOM variable.
Definition at line 1089 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print NMODL function in target backend code.
node |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 708 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print nmodl function or procedure (common code)
node | the AST node representing the function or procedure in NMODL |
name | the name of the function or procedure |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 668 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Common helper function to help printing function or procedure blocks.
node | the AST node representing the function or procedure in NMODL |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 689 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print function and procedures prototype declaration.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 390 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print NMODL function_table in target backend code.
node |
Definition at line 728 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Based on the EigenNewtonSolverBlock
passed print the definition needed for its functor.
node | EigenNewtonSolverBlock for which to print the functor |
Definition at line 802 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Go through the map of EigenNewtonSolverBlock
s and their corresponding functor names and print the functor definitions before the definitions of the functions of the generated file.
Definition at line 2450 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Set g_unused (conductance) for NRN_PRCELLSTATE feature.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3423 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the target backend code for defining and checking a local Memb_list
variable.
Definition at line 2821 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print common code for global functions like nrn_init, nrn_cur and nrn_state.
type | The target backend code block type |
TODO: Remove this when the code generation is propery done Related to https://github.com/BlueBrain/nmodl/issues/692
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 2246 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print backend specific global method annotation.
Definition at line 311 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the pragma annotation to update global variables from host to the device.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 2031 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print byte arrays that register scalar and vector variables for hoc interface.
Print structs that encapsulate information about scalar and vector elements of type global and thread variables.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1625 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print all includes.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3374 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print initial block statements.
Generate the target backend code corresponding to the NMODL initial block statements
node | The AST Node representing a NMODL initial block |
Definition at line 2196 of file codegen_coreneuron_cpp_visitor.cpp.
|
inlineprotectedvirtual |
Transfer the instance struct to the device.
This calls a function declared by print_instance_struct_transfer_routine_declarations.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 336 of file codegen_coreneuron_cpp_visitor.hpp.
|
inlineprotectedvirtual |
Delete the instance struct from the device.
This calls a function declared by print_instance_struct_transfer_routine_declarations.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 343 of file codegen_coreneuron_cpp_visitor.hpp.
|
inlineprotectedvirtual |
Print declarations of the functions used by print_instance_struct_copy_to_device and print_instance_struct_delete_from_device.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 314 of file codegen_coreneuron_cpp_visitor.hpp.
|
inlineprotectedvirtual |
Print the definitions of the functions used by print_instance_struct_copy_to_device and print_instance_struct_delete_from_device.
Declarations of these functions are printed by print_instance_struct_transfer_routine_declarations.
This updates the (pointer) member variables in the device copy of the instance struct to contain device pointers, which is why you must pass a list of names of those member variables.
ptr_members | List of instance struct member names. |
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 328 of file codegen_coreneuron_cpp_visitor.hpp.
void nmodl::codegen::CodegenCoreneuronCppVisitor::print_instance_variable_setup | ( | ) |
Print the function that initialize instance structure.
Definition at line 2073 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print constructor of ion variables.
members | The ion variable names |
Definition at line 2009 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print structure of ion variables used for local copies.
Definition at line 1979 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the ion variable struct.
Definition at line 2026 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print accelerator annotations indicating data presence on device.
Each kernel such as nrn_init
, nrn_state
and nrn_cur
could be offloaded to accelerator. In this case, at very top level, we print pragma for data present. For example:
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 204 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print matching block end of accelerator annotations for data presence on device.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 209 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the getter method for returning mechtype.
Definition at line 1125 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print the structure that wraps all global variables used in the NMODL.
print_initializers | Whether to include default values in the struct definition (true: int foo{42}; false: int foo;) |
Variables required for type of ion, type of point process etc. are of static int type. For the C++ backend type, it's ok to have these variables as file scoped static variables.
Initial values of state variables (h0) are also defined as static variables. Note that the state could be ion variable and it could be also range variable. Hence lookup into symbol table before.
When model is not vectorized (shouldn't be the case in coreneuron) the top local variables become static variables.
Note that static variables are already initialized to 0. We do the same for some variables to keep same code as neuron.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1478 of file codegen_coreneuron_cpp_visitor.cpp.
|
overridevirtual |
Print the structure that wraps all range and int variables required for the NMODL.
print_initializers | Whether or not default values for variables be included in the struct declaration. |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1937 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print the mechanism registration function.
Every mod file has register function to connect with the simulator. Various information about mechanism and callbacks get registered with the simulator using suffix_reg() function.
Here are details:
register all before/after blocks
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1732 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the getter method for returning membrane list from NrnThread.
Definition at line 1135 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print memory allocation routine.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 336 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print start of namespaces.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3381 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print end of namespaces.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3387 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Prints the start of the coreneuron
namespace.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1147 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Prints the end of the coreneuron
namespace.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1153 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print call to net_event.
node | The AST node representing the function call |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 2711 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print initial block in the net receive block.
Definition at line 2763 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print accelerator kernels begin annotation for net_init kernel.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 214 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print accelerator kernels end annotation for net_init kernel.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 219 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print call to net_move.
node | The AST node representing the function call |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 2684 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print net_receive
function definition.
Definition at line 2987 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the getter method for getting number of arguments for net_receive.
Definition at line 1113 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print kernel for buffering net_receive events.
This kernel is only needed for accelerator backends where net_receive
needs to be executed in two stages as the actual communication must be done in the host code.
need_mech_inst | true if the generated code needs a local inst variable to be defined |
Definition at line 2842 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the common code section for net receive related methods.
node | The AST node representing the corresponding NMODL block |
need_mech_inst | true if a local inst variable needs to be defined in generated code |
Definition at line 2601 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print net_receive
kernel function definition.
Definition at line 2928 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the code for the main net_receive
loop.
Definition at line 2830 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the code for closing the main net_receive
loop.
Definition at line 2837 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the code to update NetSendBuffer_t count from host to device.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 175 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the code to update NetSendBuffer_t count from device to host.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 165 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the code to update NetSendBuffer_t from device to host.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 170 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print kernel for buffering net_send events.
This kernel is only needed for accelerator backends where net_send
needs to be executed in two stages as the actual communication must be done in the host code.
Definition at line 2900 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the code related to the update of NetSendBuffer_t cnt.
For GPU this needs to be done with atomic operation, on CPU it's not needed.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 2888 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print statement that grows NetSendBuffering_t structure if needed.
This function should be overridden for backends that cannot dynamically reallocate the buffer
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 2893 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print call to net_send
.
node | The AST node representing the function call |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 2652 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print code block to transfer newtonspace structure to device.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 3117 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print nrn_alloc function definition.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 2458 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print nrn_constructor function definition.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 2426 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print nrn_cur / current update function definition.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3337 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print the nrn_cur
kernel with NMODL conductance
keyword provisions.
If the NMODL conductance
keyword is used in the breakpoint
block, then CodegenCoreneuronCppVisitor::print_nrn_cur_kernel will use this printer
node | the AST node representing the NMODL breakpoint block |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3201 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print main body of nrn_cur function.
node | the AST node representing the NMODL breakpoint block |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3272 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the reduction to matrix elements from shadow vectors.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 285 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the update to matrix elements with/without shadow vectors.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 272 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print the nrn_cur
kernel without NMODL conductance
keyword provisions.
If the NMODL conductance
keyword is not used in the breakpoint
block, then CodegenCoreneuronCppVisitor::print_nrn_cur_kernel will use this printer
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3238 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print the nrn_current
kernel.
node | the AST node representing the NMODL breakpoint block |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3182 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print nrn_destructor function definition.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 2438 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the nrn_init
function definition.
skip_init_check | true to generate code executing the initialization conditionally |
Definition at line 2297 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print nrn_state / state update function definition.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3127 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the getter methods for float and integer variables count.
Definition at line 1098 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print NMODL procedure in target backend code.
node |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 703 of file codegen_coreneuron_cpp_visitor.cpp.
|
protectedvirtual |
Print the setup method for setting matrix shadow vectors.
Reimplemented in nmodl::codegen::CodegenAccVisitor.
Definition at line 264 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1411 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print send event move block used in net receive as well as watch.
Definition at line 2795 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the function that initialize range variable with different data type.
Definition at line 2036 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Print standard C/C++ includes.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1367 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print check_function()
for functions or procedure using table.
node | The AST node representing a function or procedure block |
Definition at line 438 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print replacement function for function or procedure using table.
node | The AST node representing a function or procedure block |
Definition at line 535 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print the getter method for thread variables and ids.
There are three types of thread variables currently considered:
These variables are allocated into different thread structures and have corresponding thread ids. Thread id start from 0. In mod2c implementation, thread_data_index is increased at various places and it is used to decide the index of thread.
Definition at line 1169 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print thread related memory allocation and deallocation callbacks.
Definition at line 1874 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print top level (global scope) verbatim blocks.
Definition at line 366 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Set v_unused (voltage) for NRN_PRCELLSTATE feature.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 3411 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print watch activate function.
Check if this is correctly handled in neuron and coreneuron.
Definition at line 2471 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Print watch activate function.
need to verify with neuron/coreneuron about rest.
Definition at line 2519 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Process a verbatim block for possible variable renaming.
Processing commonly used constructs in the verbatim blocks.
text | The verbatim code to be processed |
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1007 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Process a token in a verbatim block for possible variable renaming.
token | The verbatim token to be processed |
Often top level verbatim blocks use variables with old names. Here we process if we are processing verbatim block at global scope.
Definition at line 94 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Arguments for register_mech or point_register_mech function.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 1034 of file codegen_coreneuron_cpp_visitor.cpp.
|
protected |
Replace commonly used verbatim variables.
Replace commonly used variables in the verbatim blocks into their corresponding variable name in the new code generation backend.
name | A variable name to be checked and possibly updated |
if function is defined the same mod file then the arguments must contain mechanism instance as well.
Definition at line 978 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
Name of the simulator the code was generated for.
Implements nmodl::codegen::CodegenCppVisitor.
Definition at line 56 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
visit node of type ast::DerivimplicitCallback
Implements nmodl::visitor::ConstVisitor.
Definition at line 3494 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
visit node of type ast::EigenLinearSolverBlock
Implements nmodl::visitor::ConstVisitor.
Definition at line 3530 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
visit node of type ast::EigenNewtonSolverBlock
Implements nmodl::visitor::ConstVisitor.
Definition at line 3502 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
visit node of type ast::ForNetcon
Implements nmodl::visitor::ConstVisitor.
Definition at line 3556 of file codegen_coreneuron_cpp_visitor.cpp.
|
overrideprotectedvirtual |
visit node of type ast::WatchStatement
Implements nmodl::visitor::ConstVisitor.
Definition at line 3594 of file codegen_coreneuron_cpp_visitor.cpp.