docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
block_dispatcher.h
Go to the documentation of this file.
1
28
29#pragma once
30
33
34namespace sdfg {
35namespace codegen {
36
38private:
40
41public:
43 LanguageExtension& language_extension,
45 analysis::AnalysisManager& analysis_manager,
47 InstrumentationPlan& instrumentation_plan,
48 ArgCapturePlan& arg_capture_plan
49 );
50
52 PrettyPrinter& main_stream, PrettyPrinter& globals_stream, CodeSnippetFactory& library_snippet_factory
53 ) override;
54};
55
57private:
59
60public:
62 LanguageExtension& language_extension,
64 analysis::AnalysisManager& analysis_manager,
66 InstrumentationPlan& instrumentation_plan,
67 ArgCapturePlan& arg_capture_plan
68 );
69
71 PrettyPrinter& main_stream, PrettyPrinter& globals_stream, CodeSnippetFactory& library_snippet_factory
72 ) override;
73};
74
76private:
77 LanguageExtension& language_extension_;
78 const Function& function_;
79 const data_flow::DataFlowGraph& data_flow_graph_;
80 const InstrumentationPlan& instrumentation_plan_;
81
82 void dispatch_ref(PrettyPrinter& stream, const data_flow::Memlet& memlet);
83
84 void dispatch_deref_src(PrettyPrinter& stream, const data_flow::Memlet& memlet);
85
86 void dispatch_deref_dst(PrettyPrinter& stream, const data_flow::Memlet& memlet);
87
88 void dispatch_tasklet(PrettyPrinter& stream, const data_flow::Tasklet& tasklet);
89
90 void dispatch_library_node(
91 PrettyPrinter& stream,
92 PrettyPrinter& globals_stream,
93 CodeSnippetFactory& library_snippet_factory,
94 const data_flow::LibraryNode& libnode
95 );
96
97public:
99 LanguageExtension& language_extension,
100 const Function& function,
101 const data_flow::DataFlowGraph& data_flow_graph,
102 const InstrumentationPlan& instrumentation_plan
103 );
104
105 void dispatch(PrettyPrinter& stream, PrettyPrinter& globals_stream, CodeSnippetFactory& library_snippet_factory);
106};
107
114
128
130 const std::string* local_name;
131 std::unique_ptr<types::IType> out_type;
132 bool used;
133
134 DispatchOutput(const std::string* local_name, std::unique_ptr<types::IType> out_type, bool used)
135 : local_name(local_name), out_type(std::move(out_type)), used(used) {
136 }
137};
138
164protected:
169
170public:
179 LanguageExtension& language_extension,
180 const Function& function,
181 const data_flow::DataFlowGraph& data_flow_graph,
182 const data_flow::LibraryNode& node
183 );
184
185 virtual ~LibraryNodeDispatcher() = default;
186
192 virtual bool begin_node(PrettyPrinter& stream) {
193 return false;
194 }
195
201 virtual void end_node(PrettyPrinter& stream, bool has_declaration) {
202 }
203
210 virtual void
211 dispatch(PrettyPrinter& stream, PrettyPrinter& globals_stream, CodeSnippetFactory& library_snippet_factory);
212
226 virtual void
227 dispatch_code(PrettyPrinter& stream, PrettyPrinter& globals_stream, CodeSnippetFactory& library_snippet_factory) {
228 }
229
231 CodegenOutput& out, std::vector<DispatchInput>& inputs, std::vector<DispatchOutput>& outputs
232 );
233
239
240protected:
246
251 void pre_allocate_output(CodegenOutput& out, DispatchOutput& output, const std::string& var_name) const;
252
257 void register_output(DispatchOutput& output, const std::string& result_identifier) const;
258
270 void copy_output(CodegenOutput& out, const DispatchOutput& output, const data_flow::Memlet& oedge) const;
271};
272
273} // namespace codegen
274} // namespace sdfg
Definition function.h:43
Definition structured_sdfg.h:30
Definition analysis.h:53
Definition arg_capture_plan.h:36
AssignmentDispatcher(LanguageExtension &language_extension, StructuredSDFG &sdfg, analysis::AnalysisManager &analysis_manager, structured_control_flow::AssignmentBlock &node, InstrumentationPlan &instrumentation_plan, ArgCapturePlan &arg_capture_plan)
void dispatch_node(PrettyPrinter &main_stream, PrettyPrinter &globals_stream, CodeSnippetFactory &library_snippet_factory) override
BlockDispatcher(LanguageExtension &language_extension, StructuredSDFG &sdfg, analysis::AnalysisManager &analysis_manager, structured_control_flow::Block &node, InstrumentationPlan &instrumentation_plan, ArgCapturePlan &arg_capture_plan)
void dispatch_node(PrettyPrinter &main_stream, PrettyPrinter &globals_stream, CodeSnippetFactory &library_snippet_factory) override
Originally started out as a handler for additional source files, like hardware-accelerator kernels th...
Definition code_snippet_factory.h:69
DataFlowDispatcher(LanguageExtension &language_extension, const Function &function, const data_flow::DataFlowGraph &data_flow_graph, const InstrumentationPlan &instrumentation_plan)
void dispatch(PrettyPrinter &stream, PrettyPrinter &globals_stream, CodeSnippetFactory &library_snippet_factory)
Definition instrumentation_info.h:37
Definition instrumentation_plan.h:26
Definition language_extension.h:39
const data_flow::DataFlowGraph & data_flow_graph_
Containing dataflow graph.
Definition block_dispatcher.h:167
const Function & function_
Function context.
Definition block_dispatcher.h:166
virtual InstrumentationInfo instrumentation_info() const
Get instrumentation information for this node.
void pre_allocate_output(CodegenOutput &out, DispatchOutput &output, const std::string &var_name) const
Declare a variable of the type of the output and with the name "var_name".
virtual bool begin_node(PrettyPrinter &stream)
Begin code generation for the node.
Definition block_dispatcher.h:192
virtual void end_node(PrettyPrinter &stream, bool has_declaration)
End code generation for the node.
Definition block_dispatcher.h:201
void register_output(DispatchOutput &output, const std::string &result_identifier) const
The dispatcher as created an output that is identified by [result_identifier].
virtual void dispatch_code(PrettyPrinter &stream, PrettyPrinter &globals_stream, CodeSnippetFactory &library_snippet_factory)
Generate the operation-specific code.
Definition block_dispatcher.h:227
const data_flow::LibraryNode & node_
Library node being dispatched.
Definition block_dispatcher.h:168
virtual void dispatch_code_with_edges(CodegenOutput &out, std::vector< DispatchInput > &inputs, std::vector< DispatchOutput > &outputs)
LibraryNodeDispatcher(LanguageExtension &language_extension, const Function &function, const data_flow::DataFlowGraph &data_flow_graph, const data_flow::LibraryNode &node)
Construct a library node dispatcher.
LanguageExtension & language_extension_
Language extension for code generation.
Definition block_dispatcher.h:165
virtual void dispatch(PrettyPrinter &stream, PrettyPrinter &globals_stream, CodeSnippetFactory &library_snippet_factory)
Dispatch the library node to code.
virtual ~LibraryNodeDispatcher()=default
void copy_output(CodegenOutput &out, const DispatchOutput &output, const data_flow::Memlet &oedge) const
This is a temporary & hopefully short-lived workaround.
void require_locally_modifiable_var(CodegenOutput &out, DispatchInput &input) const
Ensure that [input] points to a local copy that can be changed without modifying the actual source of...
NodeDispatcher(LanguageExtension &language_extension, StructuredSDFG &sdfg, analysis::AnalysisManager &analysis_manager, structured_control_flow::ControlFlowNode &node, InstrumentationPlan &instrumentation_plan, ArgCapturePlan &arg_capture_plan)
Definition utils.h:16
Definition data_flow_graph.h:29
Base class for all library nodes in the dataflow graph.
Definition library_node.h:106
Edge in the dataflow graph representing data movement.
Definition memlet.h:131
Simple computational operation in the dataflow graph.
Definition tasklet.h:348
A control flow node representing a basic block with dataflow computations.
Definition block.h:42
Library node definitions for calling functions beyond simple instructions.
Definition argument_registry.h:10
Definition analysis.h:7
Dispatcher base class for code generation from control flow nodes.
Definition block_dispatcher.h:108
CodeSnippetFactory & library_snippet_factory
Definition block_dispatcher.h:111
LanguageExtension & language_extension
Definition block_dispatcher.h:112
PrettyPrinter & stream
Definition block_dispatcher.h:109
PrettyPrinter & globals_stream
Definition block_dispatcher.h:110
Short-lived container for an input into a dispatcher (based on dflow edges) references are only valid...
Definition block_dispatcher.h:119
bool is_locally_modifiable
Definition block_dispatcher.h:122
const std::string expr
Definition block_dispatcher.h:120
DispatchInput(std::string expr, const data_flow::Memlet &edge, bool is_locally_modifiable)
Definition block_dispatcher.h:124
const data_flow::Memlet & edge
Definition block_dispatcher.h:121
Definition block_dispatcher.h:129
DispatchOutput(const std::string *local_name, std::unique_ptr< types::IType > out_type, bool used)
Definition block_dispatcher.h:134
std::unique_ptr< types::IType > out_type
Definition block_dispatcher.h:131
bool used
Definition block_dispatcher.h:132
const std::string * local_name
Definition block_dispatcher.h:130