User Guide
codegen_coreneuron_cpp_visitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Blue Brain Project, EPFL.
3  * See the top-level LICENSE file for details.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #pragma once
9 
10 /**
11  * \dir
12  * \brief Code generation backend implementations for CoreNEURON
13  *
14  * \file
15  * \brief \copybrief nmodl::codegen::CodegenCoreneuronCppVisitor
16  */
17 
18 #include <algorithm>
19 #include <cmath>
20 #include <ctime>
21 #include <numeric>
22 #include <ostream>
23 #include <string>
24 #include <string_view>
25 #include <utility>
26 
28 #include "codegen/codegen_info.hpp"
30 #include "printer/code_printer.hpp"
31 #include "symtab/symbol_table.hpp"
32 #include "utils/logger.hpp"
33 #include "visitors/ast_visitor.hpp"
34 
35 
36 namespace nmodl {
37 
38 namespace codegen {
39 
40 
41 using printer::CodePrinter;
42 
43 
44 /**
45  * \defgroup codegen_backends Codegen Backends
46  * \ingroup codegen
47  * \brief Code generation backends for CoreNEURON
48  * \{
49  */
50 
51 /**
52  * \class CodegenCoreneuronCppVisitor
53  * \brief %Visitor for printing C++ code compatible with legacy api of CoreNEURON
54  *
55  * \todo
56  * - Handle define statement (i.e. macros)
57  * - If there is a return statement in the verbatim block
58  * of inlined function then it will be error. Need better
59  * error checking. For example, see netstim.mod where we
60  * have removed return from verbatim block.
61  */
63  public:
65 
66  protected:
67  /****************************************************************************************/
68  /* Member variables */
69  /****************************************************************************************/
70 
71 
72  /****************************************************************************************/
73  /* Generic information getters */
74  /****************************************************************************************/
75 
76 
77  /**
78  * Name of the simulator the code was generated for
79  */
80  std::string simulator_name() override;
81 
82 
83  /**
84  * Name of the code generation backend
85  */
86  std::string backend_name() const override;
87 
88 
89  /**
90  * Determine the number of threads to allocate
91  */
92  int num_thread_objects() const noexcept {
93  return info.vectorize ? (info.thread_data_index + 1) : 0;
94  }
95 
96  bool needs_v_unused() const override;
97 
98  /****************************************************************************************/
99  /* Common helper routines accross codegen functions */
100  /****************************************************************************************/
101 
102 
103  /**
104  * Determine the position in the data array for a given float variable
105  * \param name The name of a float variable
106  * \return The position index in the data array
107  */
108  int position_of_float_var(const std::string& name) const override;
109 
110 
111  /**
112  * Determine the position in the data array for a given int variable
113  * \param name The name of an int variable
114  * \return The position index in the data array
115  */
116  int position_of_int_var(const std::string& name) const override;
117 
118 
119  /**
120  * Process a token in a verbatim block for possible variable renaming
121  * \param token The verbatim token to be processed
122  * \return The code after variable renaming
123  */
124  std::string process_verbatim_token(const std::string& token);
125 
126  /**
127  * Check if variable is qualified as constant
128  * \param name The name of variable
129  * \return \c true if it is constant
130  */
131  virtual bool is_constant_variable(const std::string& name) const;
132 
133 
134  /****************************************************************************************/
135  /* Backend specific routines */
136  /****************************************************************************************/
137 
138 
139  /**
140  * Print the code to copy derivative advance flag to device
141  */
142  virtual void print_deriv_advance_flag_transfer_to_device() const;
143 
144 
145  /**
146  * Print pragma annotation for increase and capture of variable in automatic way
147  */
148  virtual void print_device_atomic_capture_annotation() const;
149 
150 
151  /**
152  * Print the code to update NetSendBuffer_t count from device to host
153  */
154  virtual void print_net_send_buf_count_update_to_host() const;
155 
156 
157  /**
158  * Print the code to update NetSendBuffer_t from device to host
159  */
160  virtual void print_net_send_buf_update_to_host() const;
161 
162 
163  /**
164  * Print the code to update NetSendBuffer_t count from host to device
165  */
166  virtual void print_net_send_buf_count_update_to_device() const;
167 
168  /**
169  * Print the code to update dt from host to device
170  */
171  virtual void print_dt_update_to_device() const;
172 
173  /**
174  * Print the code to synchronise/wait on stream specific to NrnThread
175  */
176  virtual void print_device_stream_wait() const;
177 
178 
179  /**
180  * Print accelerator annotations indicating data presence on device
181  */
183 
184 
185  /**
186  * Print matching block end of accelerator annotations for data presence on device
187  */
189 
190 
191  /**
192  * Print accelerator kernels begin annotation for net_init kernel
193  */
195 
196 
197  /**
198  * Print accelerator kernels end annotation for net_init kernel
199  */
201 
202 
203  /**
204  * Check if reduction block in \c nrn\_cur required
205  */
206  virtual bool nrn_cur_reduction_loop_required();
207 
208 
209  /**
210  * Print the setup method for setting matrix shadow vectors
211  *
212  */
213  virtual void print_rhs_d_shadow_variables();
214 
215 
216  /**
217  * Print the update to matrix elements with/without shadow vectors
218  *
219  */
220  virtual void print_nrn_cur_matrix_shadow_update();
221 
222 
223  /**
224  * Print the reduction to matrix elements from shadow vectors
225  *
226  */
228 
229 
230  /**
231  * Print atomic update pragma for reduction statements
232  */
233  virtual void print_atomic_reduction_pragma();
234 
235 
236  /**
237  * Print backend specific global method annotation
238  *
239  * \note This is not used for the C++ backend
240  */
241  virtual void print_global_method_annotation();
242 
243 
244  /**
245  * Print backend specific includes (none needed for C++ backend)
246  */
247  virtual void print_backend_includes();
248 
249 
250  /**
251  * Check if ion variable copies should be avoided
252  */
253  bool optimize_ion_variable_copies() const override;
254 
255 
256  /**
257  * Print memory allocation routine
258  */
259  virtual void print_memory_allocation_routine() const;
260 
261 
262  /**
263  * Print backend specific abort routine
264  */
265  virtual void print_abort_routine() const;
266 
267 
268  /**
269  * Print declarations of the functions used by \ref
270  * print_instance_struct_copy_to_device and \ref
271  * print_instance_struct_delete_from_device.
272  */
274 
275  /**
276  * Print the definitions of the functions used by \ref
277  * print_instance_struct_copy_to_device and \ref
278  * print_instance_struct_delete_from_device. Declarations of these functions
279  * are printed by \ref print_instance_struct_transfer_routine_declarations.
280  *
281  * This updates the (pointer) member variables in the device copy of the
282  * instance struct to contain device pointers, which is why you must pass a
283  * list of names of those member variables.
284  *
285  * \param ptr_members List of instance struct member names.
286  */
288  std::vector<std::string> const& /* ptr_members */) {}
289 
290 
291  /**
292  * Transfer the instance struct to the device. This calls a function
293  * declared by \ref print_instance_struct_transfer_routine_declarations.
294  */
296 
297 
298  /**
299  * Delete the instance struct from the device. This calls a function
300  * declared by \ref print_instance_struct_transfer_routine_declarations.
301  */
303 
304 
305  /****************************************************************************************/
306  /* Printing routines for code generation */
307  /****************************************************************************************/
308 
309 
310  /**
311  * Print function and procedures prototype declaration
312  */
313  void print_function_prototypes() override;
314 
315 
316  /**
317  * Print check_table functions
318  */
320 
321 
322  void print_function_or_procedure(const ast::Block& node,
323  const std::string& name,
324  const std::unordered_set<CppObjectSpecifier>& specifiers = {
325  CppObjectSpecifier::Inline}) override;
326 
327 
328  /**
329  * Common helper function to help printing function or procedure blocks
330  * \param node the AST node representing the function or procedure in NMODL
331  */
332  void print_function_procedure_helper(const ast::Block& node) override;
333 
334 
335  /****************************************************************************************/
336  /* Code-specific helper routines */
337  /****************************************************************************************/
338 
339  void add_variable_tqitem(std::vector<IndexVariableInfo>& variables) override;
340  void add_variable_point_process(std::vector<IndexVariableInfo>& variables) override;
341 
342  /**
343  * Arguments for functions that are defined and used internally.
344  * \return the method arguments
345  */
346  std::string internal_method_arguments() override;
347 
348 
349  /**
350  * Parameters for internally defined functions
351  * \return the method parameters
352  */
354 
355 
356  /**
357  * Arguments for external functions called from generated code
358  * \return A string representing the arguments passed to an external function
359  */
360  const std::string external_method_arguments() noexcept override;
361 
362 
363  /**
364  * Parameters for functions in generated code that are called back from external code
365  *
366  * Functions registered in NEURON during initialization for callback must adhere to a prescribed
367  * calling convention. This method generates the string representing the function parameters for
368  * these externally called functions.
369  * \param table
370  * \return A ParamVector representing the parameters of the function
371  */
372  const ParamVector external_method_parameters(bool table = false) noexcept override;
373 
374 
375  /**
376  * Arguments for "_threadargs_" macro in neuron implementation
377  */
378  std::string nrn_thread_arguments() const override;
379 
380 
381  /**
382  * Arguments for "_threadargs_" macro in neuron implementation
383  */
384  std::string nrn_thread_internal_arguments() override;
385 
386 
388  const ast::FunctionTableBlock& node) override;
389 
390 
391  /**
392  * Replace commonly used verbatim variables
393  * \param name A variable name to be checked and possibly updated
394  * \return The possibly replace variable name
395  */
396  std::string replace_if_verbatim_variable(std::string name);
397 
398 
399  /**
400  * Process a verbatim block for possible variable renaming
401  * \param text The verbatim code to be processed
402  * \return The code with all variables renamed as needed
403  */
404  std::string process_verbatim_text(std::string const& text);
405 
406 
407  /**
408  * Arguments for register_mech or point_register_mech function
409  */
410  std::string register_mechanism_arguments() const override;
411 
412 
413  void append_conc_write_statements(std::vector<ShadowUseStatement>& statements,
414  const Ion& ion,
415  const std::string& concentration) override;
416 
417  /****************************************************************************************/
418  /* Code-specific printing routines for code generations */
419  /****************************************************************************************/
420 
421 
422  /**
423  * Print the getter method for index position of first pointer variable
424  *
425  */
427 
428 
429  /**
430  * Print the getter method for index position of first RANDOM variable
431  *
432  */
434 
435 
436  /**
437  * Print the getter methods for float and integer variables count
438  *
439  */
441 
442 
443  /**
444  * Print the getter method for getting number of arguments for net_receive
445  *
446  */
448 
449 
450  /**
451  * Print the getter method for returning mechtype
452  *
453  */
454  void print_mech_type_getter();
455 
456 
457  /**
458  * Print the getter method for returning membrane list from NrnThread
459  *
460  */
461  void print_memb_list_getter();
462 
463 
464  virtual std::string namespace_name() override;
465 
466 
467  /**
468  * Print the getter method for thread variables and ids
469  *
470  */
471  void print_thread_getters();
472 
473 
474  /****************************************************************************************/
475  /* Routines for returning variable name */
476  /****************************************************************************************/
477 
478 
479  /**
480  * Determine the name of a \c float variable given its symbol
481  *
482  * This function typically returns the accessor expression in backend code for the given symbol.
483  * Since the model variables are stored in data arrays and accessed by offset, this function
484  * will return the C++ string representing the array access at the correct offset
485  *
486  * \param symbol The symbol of a variable for which we want to obtain its name
487  * \param use_instance Should the variable be accessed via instance or data array
488  * \return The backend code string representing the access to the given variable
489  * symbol
490  */
491  std::string float_variable_name(const SymbolType& symbol, bool use_instance) const override;
492 
493 
494  /**
495  * Determine the name of an \c int variable given its symbol
496  *
497  * This function typically returns the accessor expression in backend code for the given symbol.
498  * Since the model variables are stored in data arrays and accessed by offset, this function
499  * will return the C++ string representing the array access at the correct offset
500  *
501  * \param symbol The symbol of a variable for which we want to obtain its name
502  * \param name The name of the index variable
503  * \param use_instance Should the variable be accessed via instance or data array
504  * \return The backend code string representing the access to the given variable
505  * symbol
506  */
507  std::string int_variable_name(const IndexVariableInfo& symbol,
508  const std::string& name,
509  bool use_instance) const override;
510 
511 
512  /**
513  * Determine the variable name for a global variable given its symbol
514  * \param symbol The symbol of a variable for which we want to obtain its name
515  * \param use_instance Should the variable be accessed via the (host-only)
516  * global variable or the instance-specific copy (also available on GPU).
517  * \return The C++ string representing the access to the global variable
518  */
519  std::string global_variable_name(const SymbolType& symbol,
520  bool use_instance = true) const override;
521 
522 
523  /**
524  * Determine variable name in the structure of mechanism properties
525  *
526  * \param name Variable name that is being printed
527  * \param use_instance Should the variable be accessed via instance or data array
528  * \return The C++ string representing the access to the variable in the neuron
529  * thread structure
530  */
531  std::string get_variable_name(const std::string& name, bool use_instance = true) const override;
532 
533 
534  /****************************************************************************************/
535  /* Main printing routines for code generation */
536  /****************************************************************************************/
537 
538 
539  /**
540  * Print standard C/C++ includes
541  */
542  void print_standard_includes() override;
543 
544 
545  /**
546  * Print includes from coreneuron
547  */
549 
550 
551  void print_sdlists_init(bool print_initializers) override;
552 
553 
554  /**
555  * Print the structure that wraps all global variables used in the NMODL
556  *
557  * \param print_initializers Whether to include default values in the struct
558  * definition (true: int foo{42}; false: int foo;)
559  */
560  void print_mechanism_global_var_structure(bool print_initializers) override;
561 
562 
563  /**
564  * Print byte arrays that register scalar and vector variables for hoc interface
565  *
566  */
567  void print_global_variables_for_hoc() override;
568 
569 
570  /**
571  * Print the mechanism registration function
572  *
573  */
574  void print_mechanism_register() override;
575 
576 
577  /**
578  * Print thread related memory allocation and deallocation callbacks
579  */
581 
582 
583  /**
584  * Print structure of ion variables used for local copies
585  */
587 
588 
589  /**
590  * Print constructor of ion variables
591  * \param members The ion variable names
592  */
593  virtual void print_ion_var_constructor(const std::vector<std::string>& members);
594 
595 
596  /**
597  * Print the ion variable struct
598  */
599  void print_ion_variable() override;
600 
601 
602  /**
603  * Print the pragma annotation to update global variables from host to the device
604  *
605  * \note This is not used for the C++ backend
606  */
608 
609 
610  /**
611  * Print the function that initialize range variable with different data type
612  */
614 
615 
616  /**
617  * Returns floating point type for given range variable symbol
618  * \param symbol A range variable symbol
619  */
620  std::string get_range_var_float_type(const SymbolType& symbol);
621 
622 
623  /**
624  * Print initial block statements
625  *
626  * Generate the target backend code corresponding to the NMODL initial block statements
627  *
628  * \param node The AST Node representing a NMODL initial block
629  */
630  void print_initial_block(const ast::InitialBlock* node);
631 
632 
633  /**
634  * Print common code for global functions like nrn_init, nrn_cur and nrn_state
635  * \param type The target backend code block type
636  */
638  const std::string& function_name = "") override;
639 
640 
641  /**
642  * Print the \c nrn\_init function definition
643  * \param skip_init_check \c true to generate code executing the initialization conditionally
644  */
645  void print_nrn_init(bool skip_init_check = true);
646 
647 
648  /**
649  * Print NMODL before / after block in target backend code
650  * \param node AST node of type before/after type being printed
651  * \param block_id Index of the before/after block
652  */
653  virtual void print_before_after_block(const ast::Block* node, size_t block_id);
654 
655 
656  /**
657  * Print nrn_constructor function definition
658  *
659  */
660  void print_nrn_constructor() override;
661 
662 
663  /**
664  * Print nrn_destructor function definition
665  *
666  */
667  void print_nrn_destructor() override;
668 
669 
670  /**
671  * Print nrn_alloc function definition
672  *
673  */
674  void print_nrn_alloc() override;
675 
676 
677  /**
678  * Print watch activate function
679  *
680  */
681  void print_watch_activate();
682 
683 
684  /**
685  * Print watch activate function
686  */
687  void print_watch_check();
688 
689 
690  /**
691  * Print the common code section for net receive related methods
692  *
693  * \param node The AST node representing the corresponding NMODL block
694  * \param need_mech_inst \c true if a local \c inst variable needs to be defined in generated
695  * code
696  */
697  void print_net_receive_common_code(const ast::Block& node, bool need_mech_inst = true);
698 
699 
700  /**
701  * Print call to \c net\_send
702  * \param node The AST node representing the function call
703  */
704  void print_net_send_call(const ast::FunctionCall& node) override;
705 
706 
707  /**
708  * Print call to net\_move
709  * \param node The AST node representing the function call
710  */
711  void print_net_move_call(const ast::FunctionCall& node) override;
712 
713 
714  /**
715  * Print call to net\_event
716  * \param node The AST node representing the function call
717  */
718  void print_net_event_call(const ast::FunctionCall& node) override;
719 
720  void print_function_table_call(const ast::FunctionCall& node) override;
721 
722 
723  /**
724  * Print initial block in the net receive block
725  */
726  void print_net_init();
727 
728 
729  /**
730  * Print send event move block used in net receive as well as watch
731  */
732  void print_send_event_move();
733 
734 
735  /**
736  * Generate the target backend code for the \c net\_receive\_buffering function delcaration
737  * \return The target code string
738  */
739  virtual std::string net_receive_buffering_declaration();
740 
741 
742  /**
743  * Print the target backend code for defining and checking a local \c Memb\_list variable
744  */
745  virtual void print_get_memb_list();
746 
747 
748  /**
749  * Print the code for the main \c net\_receive loop
750  */
751  virtual void print_net_receive_loop_begin();
752 
753 
754  /**
755  * Print the code for closing the main \c net\_receive loop
756  */
757  virtual void print_net_receive_loop_end();
758 
759 
760  /**
761  * Print kernel for buffering net_receive events
762  *
763  * This kernel is only needed for accelerator backends where \c net\_receive needs to be
764  * executed in two stages as the actual communication must be done in the host code. \param
765  * need_mech_inst \c true if the generated code needs a local inst variable to be defined
766  */
767  void print_net_receive_buffering(bool need_mech_inst = true);
768 
769 
770  /**
771  * Print the code related to the update of NetSendBuffer_t cnt. For GPU this needs to be done
772  * with atomic operation, on CPU it's not needed.
773  *
774  */
775  virtual void print_net_send_buffering_cnt_update() const;
776 
777 
778  /**
779  * Print statement that grows NetSendBuffering_t structure if needed.
780  * This function should be overridden for backends that cannot dynamically reallocate the buffer
781  */
782  virtual void print_net_send_buffering_grow();
783 
784 
785  /**
786  * Print kernel for buffering net_send events
787  *
788  * This kernel is only needed for accelerator backends where \c net\_send needs to be executed
789  * in two stages as the actual communication must be done in the host code.
790  */
792 
793 
794  /**
795  * Print \c net\_receive kernel function definition
796  */
798 
799 
800  /**
801  * Print \c net\_receive function definition
802  */
803  void print_net_receive();
804 
805 
806  /**
807  * Print derivative kernel when \c derivimplicit method is used
808  *
809  * \param block The corresponding AST node representing an NMODL \c derivimplicit block
810  */
811  void print_derivimplicit_kernel(const ast::Block& block);
812 
813 
814  /**
815  * Print code block to transfer newtonspace structure to device
816  */
817  virtual void print_newtonspace_transfer_to_device() const;
818 
819 
820  /****************************************************************************************/
821  /* Print nrn_state routine */
822  /****************************************************************************************/
823 
824 
825  /**
826  * Print nrn_state / state update function definition
827  */
828  void print_nrn_state() override;
829 
830 
831  /****************************************************************************************/
832  /* Print nrn_cur related routines */
833  /****************************************************************************************/
834 
835 
836  /**
837  * Print the \c nrn_current kernel
838  *
839  * \note nrn_cur_kernel will have two calls to nrn_current if no conductance keywords specified
840  * \param node the AST node representing the NMODL breakpoint block
841  */
842  void print_nrn_current(const ast::BreakpointBlock& node) override;
843 
844 
845  /**
846  * Print the \c nrn\_cur kernel with NMODL \c conductance keyword provisions
847  *
848  * If the NMODL \c conductance keyword is used in the \c breakpoint block, then
849  * CodegenCoreneuronCppVisitor::print_nrn_cur_kernel will use this printer
850  *
851  * \param node the AST node representing the NMODL breakpoint block
852  */
853  void print_nrn_cur_conductance_kernel(const ast::BreakpointBlock& node) override;
854 
855 
856  /**
857  * Print the \c nrn\_cur kernel without NMODL \c conductance keyword provisions
858  *
859  * If the NMODL \c conductance keyword is \b not used in the \c breakpoint block, then
860  * CodegenCoreneuronCppVisitor::print_nrn_cur_kernel will use this printer
861  */
862  void print_nrn_cur_non_conductance_kernel() override;
863 
864 
865  /**
866  * Print main body of nrn_cur function
867  * \param node the AST node representing the NMODL breakpoint block
868  */
869  void print_nrn_cur_kernel(const ast::BreakpointBlock& node) override;
870 
871 
872  /**
873  * Print fast membrane current calculation code
874  */
875  void print_fast_imem_calculation() override;
876 
877 
878  /**
879  * Print nrn_cur / current update function definition
880  */
881  void print_nrn_cur() override;
882 
883 
884  /****************************************************************************************/
885  /* Main code printing entry points */
886  /****************************************************************************************/
887 
888 
889  /**
890  * Print all includes
891  *
892  */
893  void print_headers_include() override;
894 
895 
896  /**
897  * Print common getters
898  *
899  */
900  void print_common_getters();
901 
902 
903  /**
904  * Print all classes
905  * \param print_initializers Whether to include default values.
906  */
907  void print_data_structures(bool print_initializers) override;
908 
909 
910  /**
911  * Set v_unused (voltage) for NRN_PRCELLSTATE feature
912  */
913  void print_v_unused() const override;
914 
915 
916  /**
917  * Set g_unused (conductance) for NRN_PRCELLSTATE feature
918  */
919  void print_g_unused() const override;
920 
921 
922  /**
923  * Print all compute functions for every backend
924  *
925  */
926  void print_compute_functions() override;
927 
928 
929  /**
930  * Print entry point to code generation
931  *
932  */
933  void print_codegen_routines() override;
934 
935 
936  /****************************************************************************************/
937  /* Overloaded visitor routines */
938  /****************************************************************************************/
939 
940 
941  void visit_derivimplicit_callback(const ast::DerivimplicitCallback& node) override;
942  void visit_for_netcon(const ast::ForNetcon& node) override;
943  void visit_verbatim(const ast::Verbatim& node) override;
944  void visit_watch_statement(const ast::WatchStatement& node) override;
945  void visit_protect_statement(const ast::ProtectStatement& node) override;
946 
947  ParamVector functor_params() override;
948 
949  public:
950  /****************************************************************************************/
951  /* Public printing routines for code generation for use in unit tests */
952  /****************************************************************************************/
953 
954 
955  /**
956  * Print the function that initialize instance structure
957  */
959 
960 
961  /**
962  * Print the structure that wraps all range and int variables required for the NMODL
963  *
964  * \param print_initializers Whether or not default values for variables
965  * be included in the struct declaration.
966  */
967  void print_mechanism_range_var_structure(bool print_initializers) override;
968 };
969 
970 
971 /** \} */ // end of codegen_backends
972 
973 } // namespace codegen
974 } // namespace nmodl
nmodl::codegen::CodegenCoreneuronCppVisitor::print_coreneuron_includes
void print_coreneuron_includes()
Print includes from coreneuron.
Definition: codegen_coreneuron_cpp_visitor.cpp:897
nmodl::codegen::CodegenCoreneuronCppVisitor::needs_v_unused
bool needs_v_unused() const override
Definition: codegen_coreneuron_cpp_visitor.cpp:62
nmodl::codegen::CodegenCoreneuronCppVisitor::net_receive_buffering_declaration
virtual std::string net_receive_buffering_declaration()
Generate the target backend code for the net_receive_buffering function delcaration.
Definition: codegen_coreneuron_cpp_visitor.cpp:2332
nmodl::codegen::CodegenCoreneuronCppVisitor::nrn_cur_reduction_loop_required
virtual bool nrn_cur_reduction_loop_required()
Check if reduction block in nrn_cur required.
Definition: codegen_coreneuron_cpp_visitor.cpp:236
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_move_call
void print_net_move_call(const ast::FunctionCall &node) override
Print call to net_move.
Definition: codegen_coreneuron_cpp_visitor.cpp:2186
nmodl::codegen::CodegenCoreneuronCppVisitor::print_mechanism_range_var_structure
void print_mechanism_range_var_structure(bool print_initializers) override
Print the structure that wraps all range and int variables required for the NMODL.
Definition: codegen_coreneuron_cpp_visitor.cpp:1461
nmodl::ast::Verbatim
Represents a C code block.
Definition: verbatim.hpp:38
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_send_buf_count_update_to_host
virtual void print_net_send_buf_count_update_to_host() const
Print the code to update NetSendBuffer_t count from device to host.
Definition: codegen_coreneuron_cpp_visitor.cpp:177
nmodl::codegen::CodegenCoreneuronCppVisitor
Visitor for printing C++ code compatible with legacy api of CoreNEURON
Definition: codegen_coreneuron_cpp_visitor.hpp:62
nmodl::codegen::CodegenCoreneuronCppVisitor::print_function_prototypes
void print_function_prototypes() override
Print function and procedures prototype declaration.
Definition: codegen_coreneuron_cpp_visitor.cpp:329
nmodl::codegen::CodegenCoreneuronCppVisitor::process_verbatim_text
std::string process_verbatim_text(std::string const &text)
Process a verbatim block for possible variable renaming.
Definition: codegen_coreneuron_cpp_visitor.cpp:545
nmodl::codegen::CodegenCoreneuronCppVisitor::print_v_unused
void print_v_unused() const override
Set v_unused (voltage) for NRN_PRCELLSTATE feature.
Definition: codegen_coreneuron_cpp_visitor.cpp:2913
nmodl::codegen::CodegenCoreneuronCppVisitor::print_derivimplicit_kernel
void print_derivimplicit_kernel(const ast::Block &block)
Print derivative kernel when derivimplicit method is used.
Definition: codegen_coreneuron_cpp_visitor.cpp:2543
nmodl::codegen::CodegenCoreneuronCppVisitor::visit_protect_statement
void visit_protect_statement(const ast::ProtectStatement &node) override
visit node of type ast::ProtectStatement
Definition: codegen_coreneuron_cpp_visitor.cpp:3042
nmodl::codegen::CodegenCoreneuronCppVisitor::print_device_stream_wait
virtual void print_device_stream_wait() const
Print the code to synchronise/wait on stream specific to NrnThread.
Definition: codegen_coreneuron_cpp_visitor.cpp:197
nmodl::codegen::CodegenCoreneuronCppVisitor::print_instance_struct_delete_from_device
virtual void print_instance_struct_delete_from_device()
Delete the instance struct from the device.
Definition: codegen_coreneuron_cpp_visitor.hpp:302
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_send_buf_count_update_to_device
virtual void print_net_send_buf_count_update_to_device() const
Print the code to update NetSendBuffer_t count from host to device.
Definition: codegen_coreneuron_cpp_visitor.cpp:187
nmodl::codegen::CodegenCppVisitor::info
codegen::CodegenInfo info
All ast information for code generation.
Definition: codegen_cpp_visitor.hpp:331
nmodl::codegen::CodegenCoreneuronCppVisitor::global_variable_name
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.
Definition: codegen_coreneuron_cpp_visitor.cpp:797
nmodl::codegen::CodegenCoreneuronCppVisitor::print_newtonspace_transfer_to_device
virtual void print_newtonspace_transfer_to_device() const
Print code block to transfer newtonspace structure to device.
Definition: codegen_coreneuron_cpp_visitor.cpp:2632
nmodl::codegen::CodegenInfo::thread_data_index
int thread_data_index
thread_data_index indicates number of threads being allocated.
Definition: codegen_info.hpp:406
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_send_call
void print_net_send_call(const ast::FunctionCall &node) override
Print call to net_send.
Definition: codegen_coreneuron_cpp_visitor.cpp:2154
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_receive_loop_begin
virtual void print_net_receive_loop_begin()
Print the code for the main net_receive loop.
Definition: codegen_coreneuron_cpp_visitor.cpp:2346
nmodl::codegen::CodegenCoreneuronCppVisitor::print_kernel_data_present_annotation_block_begin
virtual void print_kernel_data_present_annotation_block_begin()
Print accelerator annotations indicating data presence on device.
Definition: codegen_coreneuron_cpp_visitor.cpp:216
nmodl::ast::FunctionTableBlock
TODO.
Definition: function_table_block.hpp:39
nmodl::codegen::CodegenCoreneuronCppVisitor::print_g_unused
void print_g_unused() const override
Set g_unused (conductance) for NRN_PRCELLSTATE feature.
Definition: codegen_coreneuron_cpp_visitor.cpp:2925
nmodl::codegen::CodegenCoreneuronCppVisitor::print_common_getters
void print_common_getters()
Print common getters.
Definition: codegen_coreneuron_cpp_visitor.cpp:2895
nmodl::codegen::CodegenCoreneuronCppVisitor::int_variable_name
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.
Definition: codegen_coreneuron_cpp_visitor.cpp:771
nmodl::codegen::CodegenCoreneuronCppVisitor::print_initial_block
void print_initial_block(const ast::InitialBlock *node)
Print initial block statements.
Definition: codegen_coreneuron_cpp_visitor.cpp:1720
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_receive_kernel
void print_net_receive_kernel()
Print net_receive kernel function definition.
Definition: codegen_coreneuron_cpp_visitor.cpp:2443
nmodl::codegen::CodegenCoreneuronCppVisitor::print_thread_getters
void print_thread_getters()
Print the getter method for thread variables and ids.
Definition: codegen_coreneuron_cpp_visitor.cpp:704
nmodl::codegen::CodegenCoreneuronCppVisitor::simulator_name
std::string simulator_name() override
Name of the simulator the code was generated for.
Definition: codegen_coreneuron_cpp_visitor.cpp:58
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_send_buffering
void print_net_send_buffering()
Print kernel for buffering net_send events.
Definition: codegen_coreneuron_cpp_visitor.cpp:2416
nmodl::codegen::CodegenCoreneuronCppVisitor::namespace_name
virtual std::string namespace_name() override
Name of "our" namespace.
Definition: codegen_coreneuron_cpp_visitor.cpp:689
nmodl
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
nmodl::codegen::CodegenCoreneuronCppVisitor::num_thread_objects
int num_thread_objects() const noexcept
Determine the number of threads to allocate.
Definition: codegen_coreneuron_cpp_visitor.hpp:92
nmodl::codegen::CodegenCoreneuronCppVisitor::print_fast_imem_calculation
void print_fast_imem_calculation() override
Print fast membrane current calculation code.
Definition: codegen_coreneuron_cpp_visitor.cpp:2822
nmodl::codegen::CodegenCoreneuronCppVisitor::print_dt_update_to_device
virtual void print_dt_update_to_device() const
Print the code to update dt from host to device.
Definition: codegen_coreneuron_cpp_visitor.cpp:192
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_init_acc_serial_annotation_block_end
virtual void print_net_init_acc_serial_annotation_block_end()
Print accelerator kernels end annotation for net_init kernel.
Definition: codegen_coreneuron_cpp_visitor.cpp:231
nmodl::codegen::CodegenCoreneuronCppVisitor::external_method_parameters
const ParamVector external_method_parameters(bool table=false) noexcept override
Parameters for functions in generated code that are called back from external code.
Definition: codegen_coreneuron_cpp_visitor.cpp:468
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_init
void print_net_init()
Print initial block in the net receive block.
Definition: codegen_coreneuron_cpp_visitor.cpp:2279
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_event_call
void print_net_event_call(const ast::FunctionCall &node) override
Print call to net_event.
Definition: codegen_coreneuron_cpp_visitor.cpp:2213
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_destructor
void print_nrn_destructor() override
Print nrn_destructor function definition.
Definition: codegen_coreneuron_cpp_visitor.cpp:1948
nmodl::codegen::CodegenCoreneuronCppVisitor::print_sdlists_init
void print_sdlists_init(bool print_initializers) override
Definition: codegen_coreneuron_cpp_visitor.cpp:930
symbol_table.hpp
Implement classes for representing symbol table at block and file scope.
nmodl::codegen::CodegenCoreneuronCppVisitor::print_headers_include
void print_headers_include() override
Print all includes.
Definition: codegen_coreneuron_cpp_visitor.cpp:2888
nmodl::codegen::CodegenCoreneuronCppVisitor::print_send_event_move
void print_send_event_move()
Print send event move block used in net receive as well as watch.
Definition: codegen_coreneuron_cpp_visitor.cpp:2311
nmodl::codegen::CodegenCoreneuronCppVisitor::append_conc_write_statements
void append_conc_write_statements(std::vector< ShadowUseStatement > &statements, const Ion &ion, const std::string &concentration) override
Generate Function call statement for nrn_wrote_conc.
Definition: codegen_coreneuron_cpp_visitor.cpp:583
nmodl::codegen::CodegenCoreneuronCppVisitor::print_instance_struct_copy_to_device
virtual void print_instance_struct_copy_to_device()
Transfer the instance struct to the device.
Definition: codegen_coreneuron_cpp_visitor.hpp:295
nmodl::codegen::CodegenCoreneuronCppVisitor::print_global_variables_for_hoc
void print_global_variables_for_hoc() override
Print byte arrays that register scalar and vector variables for hoc interface.
Definition: codegen_coreneuron_cpp_visitor.cpp:1153
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_receive_common_code
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.
Definition: codegen_coreneuron_cpp_visitor.cpp:2103
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_current
void print_nrn_current(const ast::BreakpointBlock &node) override
Print the nrn_current kernel.
Definition: codegen_coreneuron_cpp_visitor.cpp:2697
nmodl::codegen::CodegenCoreneuronCppVisitor::print_function_table_call
void print_function_table_call(const ast::FunctionCall &node) override
Print special code when calling FUNCTION_TABLEs.
Definition: codegen_coreneuron_cpp_visitor.cpp:2228
nmodl::codegen::CodegenCoreneuronCppVisitor::print_first_pointer_var_index_getter
void print_first_pointer_var_index_getter()
Print the getter method for index position of first pointer variable.
Definition: codegen_coreneuron_cpp_visitor.cpp:629
nmodl::codegen::CodegenCoreneuronCppVisitor::print_setup_range_variable
void print_setup_range_variable()
Print the function that initialize range variable with different data type.
Definition: codegen_coreneuron_cpp_visitor.cpp:1560
nmodl::codegen::CodegenCoreneuronCppVisitor::internal_method_arguments
std::string internal_method_arguments() override
Arguments for functions that are defined and used internally.
Definition: codegen_coreneuron_cpp_visitor.cpp:438
nmodl::codegen::CodegenCoreneuronCppVisitor::print_instance_struct_transfer_routine_declarations
virtual void print_instance_struct_transfer_routine_declarations()
Print declarations of the functions used by print_instance_struct_copy_to_device and print_instance_s...
Definition: codegen_coreneuron_cpp_visitor.hpp:273
nmodl::codegen::CodegenCoreneuronCppVisitor::nrn_thread_arguments
std::string nrn_thread_arguments() const override
Arguments for "_threadargs_" macro in neuron implementation.
Definition: codegen_coreneuron_cpp_visitor.cpp:486
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_receive_arg_size_getter
void print_net_receive_arg_size_getter()
Print the getter method for getting number of arguments for net_receive.
Definition: codegen_coreneuron_cpp_visitor.cpp:658
nmodl::codegen::CodegenCoreneuronCppVisitor::function_table_parameters
std::pair< ParamVector, ParamVector > function_table_parameters(const ast::FunctionTableBlock &node) override
Parameters of the function itself "{}" and "table_{}".
Definition: codegen_coreneuron_cpp_visitor.cpp:503
nmodl::codegen::CodegenCoreneuronCppVisitor::print_function_or_procedure
void print_function_or_procedure(const ast::Block &node, const std::string &name, const std::unordered_set< CppObjectSpecifier > &specifiers={ CppObjectSpecifier::Inline}) override
Print nmodl function or procedure (common code)
Definition: codegen_coreneuron_cpp_visitor.cpp:372
codegen_cpp_visitor.hpp
Visitor for printing C++ code compatible with legacy api of CoreNEURON
nmodl::codegen::CodegenCoreneuronCppVisitor::visit_verbatim
void visit_verbatim(const ast::Verbatim &node) override
visit node of type ast::Verbatim
Definition: codegen_coreneuron_cpp_visitor.cpp:121
codegen_naming.hpp
nmodl::ast::Block
Base class for all block scoped nodes.
Definition: block.hpp:41
nmodl::ast::InitialBlock
Represents a INITIAL block in the NMODL.
Definition: initial_block.hpp:49
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_cur_matrix_shadow_update
virtual void print_nrn_cur_matrix_shadow_update()
Print the update to matrix elements with/without shadow vectors.
Definition: codegen_coreneuron_cpp_visitor.cpp:249
nmodl::codegen::CodegenCoreneuronCppVisitor::register_mechanism_arguments
std::string register_mechanism_arguments() const override
Arguments for register_mech or point_register_mech function.
Definition: codegen_coreneuron_cpp_visitor.cpp:564
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_init_acc_serial_annotation_block_begin
virtual void print_net_init_acc_serial_annotation_block_begin()
Print accelerator kernels begin annotation for net_init kernel.
Definition: codegen_coreneuron_cpp_visitor.cpp:226
nmodl::codegen::CodegenCoreneuronCppVisitor::print_deriv_advance_flag_transfer_to_device
virtual void print_deriv_advance_flag_transfer_to_device() const
Print the code to copy derivative advance flag to device.
Definition: codegen_coreneuron_cpp_visitor.cpp:167
nmodl::codegen::CodegenCoreneuronCppVisitor::print_first_random_var_index_getter
void print_first_random_var_index_getter()
Print the getter method for index position of first RANDOM variable.
Definition: codegen_coreneuron_cpp_visitor.cpp:637
nmodl::ast::WatchStatement
Represent WATCH statement in NMODL.
Definition: watch_statement.hpp:39
nmodl::codegen::CodegenCoreneuronCppVisitor::print_before_after_block
virtual void print_before_after_block(const ast::Block *node, size_t block_id)
Print NMODL before / after block in target backend code.
Definition: codegen_coreneuron_cpp_visitor.cpp:1882
nmodl::ast::BreakpointBlock
Represents a BREAKPOINT block in NMODL.
Definition: breakpoint_block.hpp:53
nmodl::ast::FunctionCall
TODO.
Definition: function_call.hpp:38
nmodl::ast::ProtectStatement
TODO.
Definition: protect_statement.hpp:38
nmodl::codegen::CodegenCoreneuronCppVisitor::print_ion_variable
void print_ion_variable() override
Print the ion variable struct.
Definition: codegen_coreneuron_cpp_visitor.cpp:1550
code_printer.hpp
Helper class for printing C/C++ code.
nmodl::codegen::CodegenCoreneuronCppVisitor::print_ion_var_structure
void print_ion_var_structure()
Print structure of ion variables used for local copies.
Definition: codegen_coreneuron_cpp_visitor.cpp:1503
nmodl::codegen::CodegenCoreneuronCppVisitor::internal_method_parameters
ParamVector internal_method_parameters() override
Parameters for internally defined functions.
Definition: codegen_coreneuron_cpp_visitor.cpp:446
nmodl::codegen::CodegenCoreneuronCppVisitor::position_of_int_var
int position_of_int_var(const std::string &name) const override
Determine the position in the data array for a given int variable.
Definition: codegen_coreneuron_cpp_visitor.cpp:76
nmodl::codegen::CodegenCoreneuronCppVisitor::is_constant_variable
virtual bool is_constant_variable(const std::string &name) const
Check if variable is qualified as constant.
Definition: codegen_coreneuron_cpp_visitor.cpp:142
nmodl::codegen::CodegenCoreneuronCppVisitor::print_function_procedure_helper
void print_function_procedure_helper(const ast::Block &node) override
Common helper function to help printing function or procedure blocks.
Definition: codegen_coreneuron_cpp_visitor.cpp:395
nmodl::codegen::CodegenCoreneuronCppVisitor::visit_for_netcon
void visit_for_netcon(const ast::ForNetcon &node) override
visit node of type ast::ForNetcon
Definition: codegen_coreneuron_cpp_visitor.cpp:3004
nmodl::codegen::CodegenCoreneuronCppVisitor::print_compute_functions
void print_compute_functions() override
Print all compute functions for every backend.
Definition: codegen_coreneuron_cpp_visitor.cpp:2934
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_cur_conductance_kernel
void print_nrn_cur_conductance_kernel(const ast::BreakpointBlock &node) override
Print the nrn_cur kernel with NMODL conductance keyword provisions.
Definition: codegen_coreneuron_cpp_visitor.cpp:2715
nmodl::codegen::CodegenCoreneuronCppVisitor::print_memory_allocation_routine
virtual void print_memory_allocation_routine() const
Print memory allocation routine.
Definition: codegen_coreneuron_cpp_visitor.cpp:298
nmodl::codegen::CodegenCoreneuronCppVisitor::print_check_table_thread_function
void print_check_table_thread_function()
Print check_table functions.
Definition: codegen_coreneuron_cpp_visitor.cpp:348
nmodl::codegen::CodegenCoreneuronCppVisitor::backend_name
std::string backend_name() const override
Name of the code generation backend.
Definition: codegen_coreneuron_cpp_visitor.cpp:53
nmodl::codegen::CodegenCoreneuronCppVisitor::print_rhs_d_shadow_variables
virtual void print_rhs_d_shadow_variables()
Print the setup method for setting matrix shadow vectors.
Definition: codegen_coreneuron_cpp_visitor.cpp:241
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_receive
void print_net_receive()
Print net_receive function definition.
Definition: codegen_coreneuron_cpp_visitor.cpp:2502
nmodl::codegen::CodegenInfo::vectorize
bool vectorize
true if mod file is vectorizable (which should be always true for coreneuron) But there are some bloc...
Definition: codegen_info.hpp:350
nmodl::codegen::CodegenCoreneuronCppVisitor::optimize_ion_variable_copies
bool optimize_ion_variable_copies() const override
Check if ion variable copies should be avoided.
Definition: codegen_coreneuron_cpp_visitor.cpp:293
codegen_info.hpp
Various types to store code generation specific information.
nmodl::codegen::CodegenCoreneuronCppVisitor::print_mechanism_global_var_structure
void print_mechanism_global_var_structure(bool print_initializers) override
Print the structure that wraps all global variables used in the NMODL.
Definition: codegen_coreneuron_cpp_visitor.cpp:1009
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_constructor
void print_nrn_constructor() override
Print nrn_constructor function definition.
Definition: codegen_coreneuron_cpp_visitor.cpp:1936
nmodl::codegen::CodegenCoreneuronCppVisitor::print_kernel_data_present_annotation_block_end
virtual void print_kernel_data_present_annotation_block_end()
Print matching block end of accelerator annotations for data presence on device.
Definition: codegen_coreneuron_cpp_visitor.cpp:221
nmodl::codegen::CodegenCoreneuronCppVisitor::print_instance_struct_transfer_routines
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_instanc...
Definition: codegen_coreneuron_cpp_visitor.hpp:287
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_alloc
void print_nrn_alloc() override
Print nrn_alloc function definition.
Definition: codegen_coreneuron_cpp_visitor.cpp:1960
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_cur_matrix_shadow_reduction
virtual void print_nrn_cur_matrix_shadow_reduction()
Print the reduction to matrix elements from shadow vectors.
Definition: codegen_coreneuron_cpp_visitor.cpp:262
nmodl::codegen::CodegenCoreneuronCppVisitor::print_memb_list_getter
void print_memb_list_getter()
Print the getter method for returning membrane list from NrnThread.
Definition: codegen_coreneuron_cpp_visitor.cpp:678
nmodl::codegen::CppObjectSpecifier::Inline
@ Inline
nmodl::codegen::CodegenCoreneuronCppVisitor::print_watch_check
void print_watch_check()
Print watch activate function.
Definition: codegen_coreneuron_cpp_visitor.cpp:2021
nmodl::codegen::CodegenCoreneuronCppVisitor::print_instance_variable_setup
void print_instance_variable_setup()
Print the function that initialize instance structure.
Definition: codegen_coreneuron_cpp_visitor.cpp:1597
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_init
void print_nrn_init(bool skip_init_check=true)
Print the nrn_init function definition.
Definition: codegen_coreneuron_cpp_visitor.cpp:1807
nmodl::codegen::CodegenCoreneuronCppVisitor::get_variable_name
std::string get_variable_name(const std::string &name, bool use_instance=true) const override
Determine variable name in the structure of mechanism properties.
Definition: codegen_coreneuron_cpp_visitor.cpp:807
nmodl::ast::ForNetcon
TODO.
Definition: for_netcon.hpp:39
nmodl::codegen::CodegenCoreneuronCppVisitor::print_abort_routine
virtual void print_abort_routine() const
Print backend specific abort routine.
Definition: codegen_coreneuron_cpp_visitor.cpp:316
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_cur
void print_nrn_cur() override
Print nrn_cur / current update function definition.
Definition: codegen_coreneuron_cpp_visitor.cpp:2851
nmodl::codegen::CodegenCoreneuronCppVisitor::get_range_var_float_type
std::string get_range_var_float_type(const SymbolType &symbol)
Returns floating point type for given range variable symbol.
Definition: codegen_coreneuron_cpp_visitor.cpp:1581
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_send_buffering_cnt_update
virtual void print_net_send_buffering_cnt_update() const
Print the code related to the update of NetSendBuffer_t cnt.
Definition: codegen_coreneuron_cpp_visitor.cpp:2404
nmodl::codegen::CodegenCoreneuronCppVisitor::print_thread_memory_callbacks
void print_thread_memory_callbacks()
Print thread related memory allocation and deallocation callbacks.
Definition: codegen_coreneuron_cpp_visitor.cpp:1398
nmodl::ast::DerivimplicitCallback
Represent a callback to NEURON's derivimplicit solver.
Definition: derivimplicit_callback.hpp:38
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_receive_buffering
void print_net_receive_buffering(bool need_mech_inst=true)
Print kernel for buffering net_receive events.
Definition: codegen_coreneuron_cpp_visitor.cpp:2358
nmodl::codegen::CodegenCoreneuronCppVisitor::print_global_function_common_code
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.
Definition: codegen_coreneuron_cpp_visitor.cpp:1756
nmodl::codegen::CodegenCoreneuronCppVisitor::functor_params
ParamVector functor_params() override
The parameters of the Newton solver "functor".
Definition: codegen_coreneuron_cpp_visitor.cpp:981
logger.hpp
Implement logger based on spdlog library.
nmodl::SymbolType
parser::NmodlParser::symbol_type SymbolType
Definition: main_nmodl.cpp:33
nmodl::codegen::BlockType
BlockType
Helper to represent various block types.
Definition: codegen_cpp_visitor.hpp:56
nmodl::codegen::CodegenCoreneuronCppVisitor::print_mechanism_register
void print_mechanism_register() override
Print the mechanism registration function.
Definition: codegen_coreneuron_cpp_visitor.cpp:1260
nmodl::codegen::CodegenCoreneuronCppVisitor::print_global_method_annotation
virtual void print_global_method_annotation()
Print backend specific global method annotation.
Definition: codegen_coreneuron_cpp_visitor.cpp:283
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_cur_kernel
void print_nrn_cur_kernel(const ast::BreakpointBlock &node) override
Print main body of nrn_cur function.
Definition: codegen_coreneuron_cpp_visitor.cpp:2786
nmodl::codegen::CodegenCoreneuronCppVisitor::nrn_thread_internal_arguments
std::string nrn_thread_internal_arguments() override
Arguments for "_threadargs_" macro in neuron implementation.
Definition: codegen_coreneuron_cpp_visitor.cpp:498
nmodl::codegen::CodegenCoreneuronCppVisitor::print_device_atomic_capture_annotation
virtual void print_device_atomic_capture_annotation() const
Print pragma annotation for increase and capture of variable in automatic way.
Definition: codegen_coreneuron_cpp_visitor.cpp:172
nmodl::codegen::CodegenCoreneuronCppVisitor::visit_derivimplicit_callback
void visit_derivimplicit_callback(const ast::DerivimplicitCallback &node) override
visit node of type ast::DerivimplicitCallback
Definition: codegen_coreneuron_cpp_visitor.cpp:2996
nmodl::codegen::CodegenCppVisitor
Visitor for printing C++ code compatible with legacy api of CoreNEURON
Definition: codegen_cpp_visitor.hpp:241
nmodl::codegen::CodegenCppVisitor::CodegenCppVisitor
CodegenCppVisitor(std::string mod_filename, std::ostream &stream, std::string float_type, const bool optimize_ionvar_copies, std::unique_ptr< nmodl::utils::Blame > blame=nullptr)
Constructs the C++ code generator visitor.
Definition: codegen_cpp_visitor.hpp:259
nmodl::codegen::CodegenCoreneuronCppVisitor::print_get_memb_list
virtual void print_get_memb_list()
Print the target backend code for defining and checking a local Memb_list variable.
Definition: codegen_coreneuron_cpp_visitor.cpp:2337
nmodl::codegen::CodegenCoreneuronCppVisitor::print_num_variable_getter
void print_num_variable_getter()
Print the getter methods for float and integer variables count.
Definition: codegen_coreneuron_cpp_visitor.cpp:645
nmodl::codegen::CodegenCoreneuronCppVisitor::print_standard_includes
void print_standard_includes() override
Print standard C/C++ includes.
Definition: codegen_coreneuron_cpp_visitor.cpp:886
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_receive_loop_end
virtual void print_net_receive_loop_end()
Print the code for closing the main net_receive loop.
Definition: codegen_coreneuron_cpp_visitor.cpp:2353
nmodl::codegen::CodegenCoreneuronCppVisitor::print_mech_type_getter
void print_mech_type_getter()
Print the getter method for returning mechtype.
Definition: codegen_coreneuron_cpp_visitor.cpp:669
nmodl::codegen::CodegenCoreneuronCppVisitor::float_variable_name
std::string float_variable_name(const SymbolType &symbol, bool use_instance) const override
Determine the name of a float variable given its symbol.
Definition: codegen_coreneuron_cpp_visitor.cpp:753
nmodl::codegen::CodegenCoreneuronCppVisitor::print_global_variable_device_update_annotation
virtual void print_global_variable_device_update_annotation()
Print the pragma annotation to update global variables from host to the device.
Definition: codegen_coreneuron_cpp_visitor.cpp:1555
nmodl::codegen::CodegenCoreneuronCppVisitor::add_variable_tqitem
void add_variable_tqitem(std::vector< IndexVariableInfo > &variables) override
Add the variable tqitem during get_int_variables.
Definition: codegen_coreneuron_cpp_visitor.cpp:413
nmodl::codegen::CodegenCoreneuronCppVisitor::visit_watch_statement
void visit_watch_statement(const ast::WatchStatement &node) override
visit node of type ast::WatchStatement
Definition: codegen_coreneuron_cpp_visitor.cpp:3036
nmodl::codegen::CodegenCoreneuronCppVisitor::external_method_arguments
const std::string external_method_arguments() noexcept override
Arguments for external functions called from generated code.
Definition: codegen_coreneuron_cpp_visitor.cpp:463
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_cur_non_conductance_kernel
void print_nrn_cur_non_conductance_kernel() override
Print the nrn_cur kernel without NMODL conductance keyword provisions.
Definition: codegen_coreneuron_cpp_visitor.cpp:2752
nmodl::codegen::CodegenCoreneuronCppVisitor::print_backend_includes
virtual void print_backend_includes()
Print backend specific includes (none needed for C++ backend)
Definition: codegen_coreneuron_cpp_visitor.cpp:288
nmodl::codegen::CodegenCoreneuronCppVisitor::process_verbatim_token
std::string process_verbatim_token(const std::string &token)
Process a token in a verbatim block for possible variable renaming.
Definition: codegen_coreneuron_cpp_visitor.cpp:85
nmodl::codegen::CodegenCoreneuronCppVisitor::print_nrn_state
void print_nrn_state() override
Print nrn_state / state update function definition.
Definition: codegen_coreneuron_cpp_visitor.cpp:2642
nmodl::codegen::CodegenCoreneuronCppVisitor::add_variable_point_process
void add_variable_point_process(std::vector< IndexVariableInfo > &variables) override
Add the variable point_process during get_int_variables.
Definition: codegen_coreneuron_cpp_visitor.cpp:427
nmodl::codegen::CodegenCoreneuronCppVisitor::print_codegen_routines
void print_codegen_routines() override
Print entry point to code generation.
Definition: codegen_coreneuron_cpp_visitor.cpp:2965
nmodl::codegen::CodegenCoreneuronCppVisitor::print_watch_activate
void print_watch_activate()
Print watch activate function.
Definition: codegen_coreneuron_cpp_visitor.cpp:1973
nmodl::codegen::CodegenCoreneuronCppVisitor::print_atomic_reduction_pragma
virtual void print_atomic_reduction_pragma()
Print atomic update pragma for reduction statements.
Definition: codegen_coreneuron_cpp_visitor.cpp:278
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_send_buffering_grow
virtual void print_net_send_buffering_grow()
Print statement that grows NetSendBuffering_t structure if needed.
Definition: codegen_coreneuron_cpp_visitor.cpp:2409
nmodl::codegen::CodegenCoreneuronCppVisitor::print_net_send_buf_update_to_host
virtual void print_net_send_buf_update_to_host() const
Print the code to update NetSendBuffer_t from device to host.
Definition: codegen_coreneuron_cpp_visitor.cpp:182
nmodl::codegen::CodegenCoreneuronCppVisitor::print_data_structures
void print_data_structures(bool print_initializers) override
Print all classes.
Definition: codegen_coreneuron_cpp_visitor.cpp:2906
nmodl::codegen::CodegenCoreneuronCppVisitor::replace_if_verbatim_variable
std::string replace_if_verbatim_variable(std::string name)
Replace commonly used verbatim variables.
Definition: codegen_coreneuron_cpp_visitor.cpp:516
nmodl::codegen::CodegenCoreneuronCppVisitor::print_ion_var_constructor
virtual void print_ion_var_constructor(const std::vector< std::string > &members)
Print constructor of ion variables.
Definition: codegen_coreneuron_cpp_visitor.cpp:1533
nmodl::codegen::CodegenCoreneuronCppVisitor::position_of_float_var
int position_of_float_var(const std::string &name) const override
Determine the position in the data array for a given float variable.
Definition: codegen_coreneuron_cpp_visitor.cpp:71
nmodl::codegen::CodegenCppVisitor::ParamVector
std::vector< std::tuple< std::string, std::string, std::string, std::string > > ParamVector
A vector of parameters represented by a 4-tuple of strings:
Definition: codegen_cpp_visitor.hpp:297
ast_visitor.hpp
Concrete visitor for all AST classes.