NEURON
codegen_acc_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  * \file
12  * \brief \copybrief nmodl::codegen::CodegenAccVisitor
13  */
14 
16 
17 
18 namespace nmodl {
19 namespace codegen {
20 
21 /**
22  * \addtogroup codegen_backends
23  * \{
24  */
25 
26 /**
27  * \class CodegenAccVisitor
28  * \brief %Visitor for printing C++ code with OpenACC backend
29  */
31  public:
32  using CodegenCoreneuronCppVisitor::CodegenCoreneuronCppVisitor;
33 
34  protected:
35  /// name of the code generation backend
36  std::string backend_name() const override;
37 
38 
39  /// common includes : standard c++, coreneuron and backend specific
40  void print_backend_includes() override;
41 
42 
43  /// ivdep like annotation for channel iterations
44  void print_parallel_iteration_hint(BlockType type, const ast::Block* block) override;
45 
46 
47  /// atomic update pragma for reduction statements
48  void print_atomic_reduction_pragma() override;
49 
50 
51  /// memory allocation routine
52  void print_memory_allocation_routine() const override;
53 
54 
55  /// abort routine
56  void print_abort_routine() const override;
57 
58 
59  /// annotations like "acc enter data present(...)" for main kernel
61 
62 
63  /// end of annotation like "acc enter data"
65 
66 
67  /// start of annotation "acc kernels" for net_init kernel
69 
70 
71  /// end of annotation "acc kernels" for net_init kernel
73 
74 
75  /// update to matrix elements with/without shadow vectors
76  void print_nrn_cur_matrix_shadow_update() override;
77 
78 
79  /// reduction to matrix elements from shadow vectors
81 
82  /// fast membrane current calculation
83  void print_fast_imem_calculation() override;
84 
85  /// setup method for setting matrix shadow vectors
86  void print_rhs_d_shadow_variables() override;
87 
88 
89  /// if reduction block in nrn_cur required
90  bool nrn_cur_reduction_loop_required() override;
91 
92  /// update global variable from host to the device
94 
95  /// transfer newtonspace structure to device
96  void print_newtonspace_transfer_to_device() const override;
97 
98  /// declare helper functions for copying the instance struct to the device
100 
101  /// define helper functions for copying the instance struct to the device
103  const std::vector<std::string>& ptr_members) override;
104 
105  /// call helper function for copying the instance struct to the device
106  void print_instance_struct_copy_to_device() override;
107 
108  /// call helper function that deletes the instance struct from the device
110 
111  /// update derivimplicit advance flag on the gpu device
112  void print_deriv_advance_flag_transfer_to_device() const override;
113 
114  /// update NetSendBuffer_t count from device to host
115  void print_net_send_buf_count_update_to_host() const override;
116 
117  /// update NetSendBuffer_t from device to host
118  void print_net_send_buf_update_to_host() const override;
119 
120  /// update NetSendBuffer_t count from host to device
121  void print_net_send_buf_count_update_to_device() const override;
122 
123  /// update dt from host to device
124  void print_dt_update_to_device() const override;
125 
126  // synchronise/wait on stream specific to NrnThread
127  void print_device_stream_wait() const override;
128 
129  /// print atomic capture pragma
130  void print_device_atomic_capture_annotation() const override;
131 
132  /// print atomic update of NetSendBuffer_t cnt
133  void print_net_send_buffering_cnt_update() const override;
134 
135  /// Replace default implementation by a no-op
136  /// since the buffer cannot be grown up during gpu execution
137  void print_net_send_buffering_grow() override;
138 };
139 
140 /** \} */ // end of codegen_backends
141 
142 } // namespace codegen
143 } // namespace nmodl
Base class for all block scoped nodes.
Definition: block.hpp:41
Visitor for printing C++ code with OpenACC backend
void print_kernel_data_present_annotation_block_begin() override
annotations like "acc enter data present(...)" for main kernel
void print_abort_routine() const override
abort routine
void print_instance_struct_transfer_routines(const std::vector< std::string > &ptr_members) override
define helper functions for copying the instance struct to the device
void print_backend_includes() override
common includes : standard c++, coreneuron and backend specific
bool nrn_cur_reduction_loop_required() override
if reduction block in nrn_cur required
void print_dt_update_to_device() const override
update dt from host to device
void print_net_send_buf_count_update_to_device() const override
update NetSendBuffer_t count from host to device
void print_net_send_buf_count_update_to_host() const override
update NetSendBuffer_t count from device to host
void print_instance_struct_transfer_routine_declarations() override
declare helper functions for copying the instance struct to the device
void print_net_init_acc_serial_annotation_block_begin() override
start of annotation "acc kernels" for net_init kernel
void print_net_send_buffering_cnt_update() const override
print atomic update of NetSendBuffer_t cnt
void print_newtonspace_transfer_to_device() const override
transfer newtonspace structure to device
void print_nrn_cur_matrix_shadow_update() override
update to matrix elements with/without shadow vectors
void print_instance_struct_copy_to_device() override
call helper function for copying the instance struct to the device
void print_nrn_cur_matrix_shadow_reduction() override
reduction to matrix elements from shadow vectors
void print_net_send_buf_update_to_host() const override
update NetSendBuffer_t from device to host
void print_instance_struct_delete_from_device() override
call helper function that deletes the instance struct from the device
void print_net_send_buffering_grow() override
Replace default implementation by a no-op since the buffer cannot be grown up during gpu execution.
void print_net_init_acc_serial_annotation_block_end() override
end of annotation "acc kernels" for net_init kernel
std::string backend_name() const override
name of the code generation backend
void print_parallel_iteration_hint(BlockType type, const ast::Block *block) override
ivdep like annotation for channel iterations
void print_rhs_d_shadow_variables() override
setup method for setting matrix shadow vectors
void print_global_variable_device_update_annotation() override
update global variable from host to the device
void print_deriv_advance_flag_transfer_to_device() const override
update derivimplicit advance flag on the gpu device
void print_memory_allocation_routine() const override
memory allocation routine
void print_kernel_data_present_annotation_block_end() override
end of annotation like "acc enter data"
void print_device_atomic_capture_annotation() const override
print atomic capture pragma
void print_device_stream_wait() const override
Print the code to synchronise/wait on stream specific to NrnThread.
void print_atomic_reduction_pragma() override
atomic update pragma for reduction statements
void print_fast_imem_calculation() override
fast membrane current calculation
Visitor for printing C++ code compatible with legacy api of CoreNEURON
Visitor for printing C++ code compatible with legacy api of CoreNEURON
BlockType
Helper to represent various block types.
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
short type
Definition: cabvars.h:10