docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
structured_sdfg_builder.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <utility>
5
8#include "sdfg/function.h"
9#include "sdfg/sdfg.h"
19#include "sdfg/types/scalar.h"
20
21using namespace sdfg::control_flow;
22using namespace sdfg::structured_control_flow;
23
24namespace sdfg {
25namespace builder {
26
27template<typename T>
30
31 ConditionalDeleter(bool should_delete = true) : should_delete_(should_delete) {
32 }
33
34 void operator()(T* ptr) const {
35 if (should_delete_) {
36 delete ptr;
37 }
38 }
39};
40
45private:
46 std::unique_ptr<StructuredSDFG, ConditionalDeleter<StructuredSDFG>> structured_sdfg_;
47
49
50 std::unordered_set<const control_flow::State*>
51 determine_loop_nodes(SDFG& sdfg, const control_flow::State& start, const control_flow::State& end) const;
52
53 structured_control_flow::While* current_traverse_loop_;
54
55 void traverse(SDFG& sdfg);
56
57 void structure_region(
58 SDFG& sdfg,
59 Sequence& scope,
60 const State* entry,
61 const State* exit,
62 const std::unordered_set<const InterstateEdge*>& continues,
63 const std::unordered_set<const InterstateEdge*>& breaks,
64 const std::unordered_map<const control_flow::State*, const control_flow::State*>& pdom_tree,
65 std::unordered_set<const control_flow::State*>& visited,
66 bool is_loop_body = false
67 );
68
69 void add_dataflow(const data_flow::DataFlowGraph& from, Block& to);
70
71 static constexpr int32_t INSERT_AT_END = -10;
72
73 template<typename T, typename... Args>
74 T& insert_node_internal(Sequence& parent, int32_t insert_idx, const DebugInfo& debug_info, Args&&... args) {
75 auto child = std::unique_ptr<T>(
76 new T(this->new_element_id_batch(T::REQUIRED_ELEMENT_IDS), debug_info, &parent, std::forward<Args>(args)...)
77 );
78 auto& new_child = *child;
79
80 if (insert_idx == INSERT_AT_END) {
81 parent.children_.push_back(std::move(child));
82 } else {
83 parent.children_.insert(parent.children_.begin() + insert_idx, std::move(child));
84 }
85
86 return new_child;
87 }
88
89 Block& insert_block_internal(
90 Sequence& parent, int32_t insert_idx, const data_flow::DataFlowGraph* import_from, const DebugInfo& debug_info
91 );
92
93protected:
94 Function& function() const override;
95
96public:
97 using InsertionPoint = int32_t;
98
103
109 StructuredSDFGBuilder(std::unique_ptr<StructuredSDFG>& sdfg);
110
111 StructuredSDFGBuilder(const std::string& name, FunctionType type);
112
113 StructuredSDFGBuilder(const std::string& name, FunctionType type, const types::IType& return_type);
114
116
118
124 std::unique_ptr<StructuredSDFG> move();
125
126 void rename_container(const std::string& old_name, const std::string& new_name) const override;
127
129 void rename_containers(const std::vector<std::pair<std::string, std::string>>& renames) const;
130
131 Element* find_element_by_id(const size_t& element_id) const;
132
138 virtual void
139 replace_symbols(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override;
140 virtual void replace_symbols(const symbolic::ExpressionMapping& replacements) override;
141
142 Sequence& add_sequence(Sequence& parent, const DebugInfo& debug_info = DebugInfo());
143
144 Sequence& add_sequence_before(Sequence& parent, ControlFlowNode& block, const DebugInfo& debug_info = DebugInfo());
145
146 Sequence& add_sequence_after(Sequence& parent, ControlFlowNode& block, const DebugInfo& debug_info = DebugInfo());
147
148 Sequence& add_sequence_at(Sequence& parent, InsertionPoint insertion_point, const DebugInfo& debug_info = DebugInfo());
149
151
152 void remove_child(Sequence& parent, size_t index);
153
155
156 void move_child(Sequence& source, size_t source_index, Sequence& target);
157
158 void move_child(Sequence& source, size_t source_index, Sequence& target, size_t target_index);
159
160 void move_children(Sequence& source, Sequence& target);
161
162 void move_children(Sequence& source, Sequence& target, size_t target_index);
163
165
167 add_assignments(Sequence& parent, const Assignments& assignments, const DebugInfo& debug_info = DebugInfo());
168
170 Sequence& parent,
171 ControlFlowNode& child,
172 const Assignments& assignments,
173 const DebugInfo& debug_info = DebugInfo()
174 );
175
177 Sequence& parent,
178 ControlFlowNode& child,
179 const Assignments& assignments,
180 const DebugInfo& debug_info = DebugInfo()
181 );
182
184 Sequence& parent,
185 InsertionPoint insertion_point,
186 const Assignments& assignments,
187 const DebugInfo& debug_info = DebugInfo()
188 );
189
190 Block& add_block(Sequence& parent, const DebugInfo& debug_info = DebugInfo());
191
196 Sequence& parent, const data_flow::DataFlowGraph& data_flow_graph, const DebugInfo& debug_info = DebugInfo()
197 );
198
199 Block& add_block_before(Sequence& parent, ControlFlowNode& child, const DebugInfo& debug_info = DebugInfo());
200
202 Sequence& parent,
203 ControlFlowNode& child,
204 data_flow::DataFlowGraph& data_flow_graph,
205 const DebugInfo& debug_info = DebugInfo()
206 );
207
208 Block& add_block_after(Sequence& parent, ControlFlowNode& child, const DebugInfo& debug_info = DebugInfo());
209
211 Sequence& parent,
212 ControlFlowNode& child,
213 data_flow::DataFlowGraph& data_flow_graph,
214 const DebugInfo& debug_info = DebugInfo()
215 );
216
217 Block& add_block_at(Sequence& parent, InsertionPoint insertion_point, const DebugInfo& debug_info = DebugInfo());
218
219 IfElse& add_if_else(Sequence& parent, const DebugInfo& debug_info = DebugInfo());
220
221 IfElse& add_if_else_before(Sequence& parent, ControlFlowNode& child, const DebugInfo& debug_info = DebugInfo());
222
223 IfElse& add_if_else_after(Sequence& parent, ControlFlowNode& child, const DebugInfo& debug_info = DebugInfo());
224
225 Sequence& add_case(IfElse& scope, const sdfg::symbolic::Condition cond, const DebugInfo& debug_info = DebugInfo());
226
227 void remove_case(IfElse& scope, size_t i, const DebugInfo& debug_info = DebugInfo());
228
229 While& add_while(Sequence& parent, const DebugInfo& debug_info = DebugInfo());
230
232 Sequence& parent,
233 const symbolic::Symbol indvar,
234 const symbolic::Condition condition,
235 const symbolic::Expression init,
236 const symbolic::Expression update,
237 const DebugInfo& debug_info = DebugInfo()
238 );
239
241 Sequence& parent,
242 ControlFlowNode& child,
243 const symbolic::Symbol indvar,
244 const symbolic::Condition condition,
245 const symbolic::Expression init,
246 const symbolic::Expression update,
247 const DebugInfo& debug_info = DebugInfo()
248 );
249
251 Sequence& parent,
252 ControlFlowNode& child,
253 const symbolic::Symbol indvar,
254 const symbolic::Condition condition,
255 const symbolic::Expression init,
256 const symbolic::Expression update,
257 const DebugInfo& debug_info = DebugInfo()
258 );
259
261 Sequence& parent,
262 InsertionPoint insertion_point,
263 const symbolic::Symbol indvar,
264 const symbolic::Condition condition,
265 const symbolic::Expression init,
266 const symbolic::Expression update,
267 const ScheduleType& schedule_type,
268 const DebugInfo& debug_info = DebugInfo()
269 );
270
272 Sequence& parent,
273 const symbolic::Symbol indvar,
274 const symbolic::Condition condition,
275 const symbolic::Expression init,
276 const symbolic::Expression update,
277 const ScheduleType& schedule_type,
278 const DebugInfo& debug_info = DebugInfo()
279 );
280
282 Sequence& parent,
283 ControlFlowNode& child,
284 const symbolic::Symbol indvar,
285 const symbolic::Condition condition,
286 const symbolic::Expression init,
287 const symbolic::Expression update,
288 const ScheduleType& schedule_type,
289 const DebugInfo& debug_info = DebugInfo()
290 );
291
293 Sequence& parent,
294 ControlFlowNode& child,
295 const symbolic::Symbol indvar,
296 const symbolic::Condition condition,
297 const symbolic::Expression init,
298 const symbolic::Expression update,
299 const ScheduleType& schedule_type,
300 const DebugInfo& debug_info = DebugInfo()
301 );
302
304 Sequence& parent,
305 InsertionPoint insertion_point,
306 const symbolic::Symbol indvar,
307 const symbolic::Condition condition,
308 const symbolic::Expression init,
309 const symbolic::Expression update,
310 const ScheduleType& schedule_type,
311 const DebugInfo& debug_info = DebugInfo()
312 );
313
315 Sequence& parent,
316 const symbolic::Symbol indvar,
317 const symbolic::Condition condition,
318 const symbolic::Expression init,
319 const symbolic::Expression update,
320 const std::vector<structured_control_flow::ReductionInfo>& reductions,
321 const ScheduleType& schedule_type,
322 const DebugInfo& debug_info = DebugInfo()
323 );
324
326 Sequence& parent,
327 ControlFlowNode& child,
328 const symbolic::Symbol indvar,
329 const symbolic::Condition condition,
330 const symbolic::Expression init,
331 const symbolic::Expression update,
332 const std::vector<structured_control_flow::ReductionInfo>& reductions,
333 const ScheduleType& schedule_type,
334 const DebugInfo& debug_info = DebugInfo()
335 );
336
338 Sequence& parent,
339 ControlFlowNode& child,
340 const symbolic::Symbol indvar,
341 const symbolic::Condition condition,
342 const symbolic::Expression init,
343 const symbolic::Expression update,
344 const std::vector<structured_control_flow::ReductionInfo>& reductions,
345 const ScheduleType& schedule_type,
346 const DebugInfo& debug_info = DebugInfo()
347 );
348
349 Continue& add_continue(Sequence& parent, const DebugInfo& debug_info = DebugInfo());
350
351 Break& add_break(Sequence& parent, const DebugInfo& debug_info = DebugInfo());
352
353 Return& add_return(Sequence& parent, const std::string& data, const DebugInfo& debug_info = DebugInfo());
354
356 Sequence& parent, const std::string& data, const types::IType& type, const DebugInfo& debug_info = DebugInfo()
357 );
358
360 Sequence& parent,
361 While& loop,
362 const symbolic::Symbol indvar,
363 const symbolic::Condition condition,
364 const symbolic::Expression init,
365 const symbolic::Expression update
366 );
367
368 Map& convert_for(Sequence& parent, For& loop);
369
371 Sequence& parent, For& loop, const std::vector<structured_control_flow::ReductionInfo>& reductions
372 );
373
374 // Demotes a Reduce to a plain Map, preserving its schedule (e.g. a grid-parallel
375 // reduction whose merge is taken over by an atomic writeback).
377
378 void update_if_else_condition(IfElse& if_else, size_t branch, const symbolic::Condition cond);
379
381 StructuredLoop& loop,
382 const symbolic::Symbol indvar,
383 const symbolic::Condition condition,
384 const symbolic::Expression init,
385 const symbolic::Expression update
386 );
387
396 void update_schedule_type(StructuredLoop& loop, const ScheduleType& schedule_type, bool keep_nest_annotations = true);
397
399 void remove_schedule_property(StructuredLoop& loop, const std::string& key);
400
401 /***** Section: Dataflow Graph *****/
402
404 structured_control_flow::Block& block, const std::string& data, const DebugInfo& debug_info = DebugInfo()
405 );
406
409 const std::string& data,
410 const types::IType& type,
411 const DebugInfo& debug_info = DebugInfo()
412 );
413
416 const data_flow::TaskletCode code,
417 const std::string& output,
418 const std::vector<std::string>& inputs,
419 const DebugInfo& debug_info = DebugInfo()
420 );
421
425 const std::string& src_conn,
427 const std::string& dst_conn,
428 const data_flow::Subset& subset,
429 const types::IType& base_type,
430 const DebugInfo& debug_info
431 );
432
437 const std::string& dst_conn,
438 const data_flow::Subset& subset,
439 const types::IType& base_type,
440 const DebugInfo& debug_info = DebugInfo()
441 );
442
446 const std::string& src_conn,
448 const data_flow::Subset& subset,
449 const types::IType& base_type,
450 const DebugInfo& debug_info = DebugInfo()
451 );
452
457 const std::string& dst_conn,
458 const data_flow::Subset& subset,
459 const DebugInfo& debug_info = DebugInfo()
460 );
461
465 const std::string& src_conn,
467 const data_flow::Subset& subset,
468 const DebugInfo& debug_info = DebugInfo()
469 );
470
475 const data_flow::Subset& subset,
476 const types::IType& base_type,
477 const DebugInfo& debug_info = DebugInfo()
478 );
479
484 bool derefs_src,
485 const types::IType& base_type,
486 const DebugInfo& debug_info = DebugInfo()
487 );
488
489 template<typename T, typename... Args>
491 add_library_node(structured_control_flow::Block& block, const DebugInfo& debug_info, Args... arguments) {
492 static_assert(std::is_base_of<data_flow::LibraryNode, T>::value, "T must be a subclass of data_flow::LibraryNode");
493
494 auto& dataflow = block.dataflow();
495 auto vertex = boost::add_vertex(dataflow.graph_);
496 dataflow.invalidate_topological_order();
497 auto node =
498 std::unique_ptr<T>(new T(this->new_element_id(), debug_info, vertex, dataflow, std::move(arguments)...));
499 auto res = dataflow.nodes_.insert({vertex, std::move(node)});
500
501 return static_cast<data_flow::LibraryNode&>(*(res.first->second));
502 }
503
505 auto& dataflow = block.dataflow();
506 auto vertex = boost::add_vertex(dataflow.graph_);
507 dataflow.invalidate_topological_order();
508 auto node_clone = node.clone(this->new_element_id(), vertex, dataflow);
509 auto res = dataflow.nodes_.insert({vertex, std::move(node_clone)});
510 return *res.first->second;
511 };
512
514
516
522 structured_control_flow::Block& block, data_flow::Memlet& edge, const std::string& data, const types::IType& type
523 );
524
534
540
555 const data_flow::DataFlowNode& node,
556 const std::unordered_set<const data_flow::DataFlowNode*>& ignore_side_effects
557 );
558
560
562
568};
569
570} // namespace builder
571} // namespace sdfg
Definition element.h:30
Definition element.h:159
Definition function.h:43
Definition sdfg.h:34
Definition structured_sdfg.h:30
Definition function_builder.h:12
size_t new_element_id_batch(size_t batch) const
data_flow::DataFlowNode & copy_node(structured_control_flow::Block &block, const data_flow::DataFlowNode &node)
Definition structured_sdfg_builder.h:504
void move_children(Sequence &source, Sequence &target)
Reduce & add_reduce_before(Sequence &parent, ControlFlowNode &child, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const std::vector< structured_control_flow::ReductionInfo > &reductions, const ScheduleType &schedule_type, const DebugInfo &debug_info=DebugInfo())
void update_loop(StructuredLoop &loop, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update)
AssignmentBlock & add_assignments_before(Sequence &parent, ControlFlowNode &child, const Assignments &assignments, const DebugInfo &debug_info=DebugInfo())
void update_schedule_type(StructuredLoop &loop, const ScheduleType &schedule_type, bool keep_nest_annotations=true)
Replace the schedule type of a loop.
Return & add_constant_return(Sequence &parent, const std::string &data, const types::IType &type, const DebugInfo &debug_info=DebugInfo())
Reduce & add_reduce_after(Sequence &parent, ControlFlowNode &child, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const std::vector< structured_control_flow::ReductionInfo > &reductions, const ScheduleType &schedule_type, const DebugInfo &debug_info=DebugInfo())
std::unique_ptr< StructuredSDFG > move()
AssignmentBlock & add_assignments_at(Sequence &parent, InsertionPoint insertion_point, const Assignments &assignments, const DebugInfo &debug_info=DebugInfo())
Block & add_block(Sequence &parent, const data_flow::DataFlowGraph &data_flow_graph, const DebugInfo &debug_info=DebugInfo())
Block & add_block_at(Sequence &parent, InsertionPoint insertion_point, const DebugInfo &debug_info=DebugInfo())
Block & add_block_after(Sequence &parent, ControlFlowNode &child, const DebugInfo &debug_info=DebugInfo())
data_flow::LibraryNode & add_library_node(structured_control_flow::Block &block, const DebugInfo &debug_info, Args... arguments)
Definition structured_sdfg_builder.h:491
IfElse & add_if_else(Sequence &parent, const DebugInfo &debug_info=DebugInfo())
Sequence & add_sequence_after(Sequence &parent, ControlFlowNode &block, const DebugInfo &debug_info=DebugInfo())
void update_if_else_condition(IfElse &if_else, size_t branch, const symbolic::Condition cond)
Block & add_block_after(Sequence &parent, ControlFlowNode &child, data_flow::DataFlowGraph &data_flow_graph, const DebugInfo &debug_info=DebugInfo())
Block & add_block(Sequence &parent, const DebugInfo &debug_info=DebugInfo())
void remove_schedule_property(StructuredLoop &loop, const std::string &key)
Remove a single property (if present) from the schedule type of a loop.
data_flow::Memlet & add_memlet(structured_control_flow::Block &block, data_flow::DataFlowNode &src, const std::string &src_conn, data_flow::DataFlowNode &dst, const std::string &dst_conn, const data_flow::Subset &subset, const types::IType &base_type, const DebugInfo &debug_info)
data_flow::Memlet & add_computational_memlet(structured_control_flow::Block &block, data_flow::CodeNode &src, const std::string &src_conn, data_flow::AccessNode &dst, const data_flow::Subset &subset, const types::IType &base_type, const DebugInfo &debug_info=DebugInfo())
data_flow::ConstantNode & add_constant(structured_control_flow::Block &block, const std::string &data, const types::IType &type, const DebugInfo &debug_info=DebugInfo())
StructuredSDFGBuilder(const std::string &name, FunctionType type, const types::IType &return_type)
StructuredSDFGBuilder(const std::string &name, FunctionType type)
Sequence & add_sequence_before(Sequence &parent, ControlFlowNode &block, const DebugInfo &debug_info=DebugInfo())
data_flow::Memlet & add_computational_memlet(structured_control_flow::Block &block, data_flow::AccessNode &src, data_flow::Tasklet &dst, const std::string &dst_conn, const data_flow::Subset &subset, const DebugInfo &debug_info=DebugInfo())
Function & function() const override
For & add_for_at(Sequence &parent, InsertionPoint insertion_point, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const ScheduleType &schedule_type, const DebugInfo &debug_info=DebugInfo())
While & add_while(Sequence &parent, const DebugInfo &debug_info=DebugInfo())
data_flow::Memlet & add_computational_memlet(structured_control_flow::Block &block, data_flow::Tasklet &src, const std::string &src_conn, data_flow::AccessNode &dst, const data_flow::Subset &subset, const DebugInfo &debug_info=DebugInfo())
void merge_siblings(data_flow::AccessNode &in_node)
Element * find_element_by_id(const size_t &element_id) const
data_flow::AccessNode & add_access(structured_control_flow::Block &block, const std::string &data, const DebugInfo &debug_info=DebugInfo())
void move_child(Sequence &source, size_t source_index, Sequence &target)
void move_children(Sequence &source, Sequence &target, size_t target_index)
Return & add_return(Sequence &parent, const std::string &data, const DebugInfo &debug_info=DebugInfo())
Block & add_block_before(Sequence &parent, ControlFlowNode &child, data_flow::DataFlowGraph &data_flow_graph, const DebugInfo &debug_info=DebugInfo())
Map & convert_for(Sequence &parent, For &loop)
Break & add_break(Sequence &parent, const DebugInfo &debug_info=DebugInfo())
Sequence & add_case(IfElse &scope, const sdfg::symbolic::Condition cond, const DebugInfo &debug_info=DebugInfo())
For & convert_while(Sequence &parent, While &loop, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update)
AssignmentBlock & add_assignments_after(Sequence &parent, ControlFlowNode &child, const Assignments &assignments, const DebugInfo &debug_info=DebugInfo())
Map & add_map_at(Sequence &parent, InsertionPoint insertion_point, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const ScheduleType &schedule_type, const DebugInfo &debug_info=DebugInfo())
AssignmentBlock & add_assignments(Sequence &parent, const Assignments &assignments, const DebugInfo &debug_info=DebugInfo())
void clear_code_node_legacy(structured_control_flow::Block &block, const data_flow::CodeNode &node)
Removes a code node and all its input and output edges.
For & add_for_before(Sequence &parent, ControlFlowNode &child, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const DebugInfo &debug_info=DebugInfo())
Continue & add_continue(Sequence &parent, const DebugInfo &debug_info=DebugInfo())
void move_child(Sequence &source, size_t source_index, Sequence &target, size_t target_index)
For & add_for_after(Sequence &parent, ControlFlowNode &child, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const DebugInfo &debug_info=DebugInfo())
void remove_from_parent(ControlFlowNode &child)
Reduce & add_reduce(Sequence &parent, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const std::vector< structured_control_flow::ReductionInfo > &reductions, const ScheduleType &schedule_type, const DebugInfo &debug_info=DebugInfo())
data_flow::Memlet & add_reference_memlet(structured_control_flow::Block &block, data_flow::AccessNode &src, data_flow::AccessNode &dst, const data_flow::Subset &subset, const types::IType &base_type, const DebugInfo &debug_info=DebugInfo())
int clear_ptr_borrow_edge(Block &block, const data_flow::Memlet &edge)
void remove_node(structured_control_flow::Block &block, const data_flow::DataFlowNode &node)
void rename_container(const std::string &old_name, const std::string &new_name) const override
Sequence & add_sequence(Sequence &parent, const DebugInfo &debug_info=DebugInfo())
int clear_node(structured_control_flow::Block &block, const data_flow::DataFlowNode &node)
Shorthand for clear_node with the node itself being the only one to ignore side-effects on.
StructuredSDFGBuilder(StructuredSDFG &sdfg)
To modify an existing SDFG.
int32_t InsertionPoint
Definition structured_sdfg_builder.h:97
Map & add_map_before(Sequence &parent, ControlFlowNode &child, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const ScheduleType &schedule_type, const DebugInfo &debug_info=DebugInfo())
Block & add_block_before(Sequence &parent, ControlFlowNode &child, const DebugInfo &debug_info=DebugInfo())
Map & add_map(Sequence &parent, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const ScheduleType &schedule_type, const DebugInfo &debug_info=DebugInfo())
void remove_children(Sequence &parent)
data_flow::Memlet & add_computational_memlet(structured_control_flow::Block &block, data_flow::AccessNode &src, data_flow::CodeNode &dst, const std::string &dst_conn, const data_flow::Subset &subset, const types::IType &base_type, const DebugInfo &debug_info=DebugInfo())
void rename_containers(const std::vector< std::pair< std::string, std::string > > &renames) const
Applies several renames with a single tree traversal; old names must be distinct and not renamed targ...
Reduce & convert_for_to_reduce(Sequence &parent, For &loop, const std::vector< structured_control_flow::ReductionInfo > &reductions)
For & add_for(Sequence &parent, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const DebugInfo &debug_info=DebugInfo())
virtual void replace_symbols(const symbolic::ExpressionMapping &replacements) override
void remove_memlet(structured_control_flow::Block &block, const data_flow::Memlet &edge)
virtual void replace_symbols(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
Replace symbolic expressions on the whole SDFG.
data_flow::Memlet & add_dereference_memlet(structured_control_flow::Block &block, data_flow::AccessNode &src, data_flow::AccessNode &dst, bool derefs_src, const types::IType &base_type, const DebugInfo &debug_info=DebugInfo())
Map & convert_reduce_to_map(Sequence &parent, Reduce &reduce)
data_flow::Tasklet & add_tasklet(structured_control_flow::Block &block, const data_flow::TaskletCode code, const std::string &output, const std::vector< std::string > &inputs, const DebugInfo &debug_info=DebugInfo())
void clear_access_node_legacy(structured_control_flow::Block &block, const data_flow::AccessNode &node)
Removes a code node and maybe some of its inputs as well.
int clear_node(structured_control_flow::Block &block, const data_flow::DataFlowNode &node, const std::unordered_set< const data_flow::DataFlowNode * > &ignore_side_effects)
New function to remove all unneeded edges and nodes transitively.
StructuredSDFG & subject() const
void remove_case(IfElse &scope, size_t i, const DebugInfo &debug_info=DebugInfo())
StructuredSDFGBuilder(std::unique_ptr< StructuredSDFG > &sdfg)
Will take ownership of the SDFG Increases compatibility with legacy code.
void merge_sinks(structured_control_flow::Block &block)
Walks all sink nodes of a block's dataflow graph and merges access nodes that refer to the same conta...
IfElse & add_if_else_after(Sequence &parent, ControlFlowNode &child, const DebugInfo &debug_info=DebugInfo())
Sequence & add_sequence_at(Sequence &parent, InsertionPoint insertion_point, const DebugInfo &debug_info=DebugInfo())
data_flow::Memlet & replace_memlet_src_with_constant(structured_control_flow::Block &block, data_flow::Memlet &edge, const std::string &data, const types::IType &type)
Replaces the source of a computational read memlet with a new ConstantNode carrying data/type.
void remove_child(Sequence &parent, size_t index)
Map & add_map_after(Sequence &parent, ControlFlowNode &child, const symbolic::Symbol indvar, const symbolic::Condition condition, const symbolic::Expression init, const symbolic::Expression update, const ScheduleType &schedule_type, const DebugInfo &debug_info=DebugInfo())
IfElse & add_if_else_before(Sequence &parent, ControlFlowNode &child, const DebugInfo &debug_info=DebugInfo())
A state in a Stateful DataFlow Graph (SDFG).
Definition state.h:38
Node representing access to a data container in the dataflow graph.
Definition access_node.h:84
Base class for computational nodes with inputs and outputs.
Definition code_node.h:88
Node representing a constant literal value in the dataflow graph.
Definition access_node.h:205
Definition data_flow_graph.h:29
Abstract base class for all dataflow graph nodes.
Definition data_flow_node.h:106
virtual std::unique_ptr< DataFlowNode > clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph &parent) const =0
Clone this node for graph transformations.
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
const data_flow::DataFlowGraph & dataflow() const
Access the dataflow graph (const version).
Represents a break statement that exits the innermost loop.
Definition while.h:93
Represents a continue statement that skips to the next loop iteration.
Definition while.h:128
Base class for all structured control flow nodes in a StructuredSDFG.
Definition control_flow_node.h:44
Represents a traditional for-loop with sequential execution.
Definition for.h:43
Represents a conditional if-else control flow node with multiple cases.
Definition if_else.h:47
Represents a parallel map loop with configurable scheduling.
Definition map.h:47
Represents a loop with an associative/commutative reduction carried dependency.
Definition reduce.h:106
Represents a return statement that exits the function with a value.
Definition return.h:32
Represents a schedule type for Map nodes.
Definition structured_loop.h:31
A sequential container of control flow nodes.
Definition sequence.h:52
Base class for structured loop constructs.
Definition structured_loop.h:244
Represents a while-loop with condition-controlled iteration.
Definition while.h:37
Abstract base interface for all types in the sdfglib type system.
Definition type.h:625
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
SymEngine::RCP< const SymEngine::Symbol > Symbol
Reference-counted pointer to a SymEngine Symbol.
Definition symbolic.h:71
SymEngine::RCP< const SymEngine::Boolean > Condition
Reference-counted pointer to a boolean condition expression.
Definition symbolic.h:86
SymEngine::map_basic_basic ExpressionMapping
Definition symbolic.h:109
Library node definitions for calling functions beyond simple instructions.
Definition function_builder.h:10
Definition interstate_edge.h:22
symbolic::SymbolMap Assignments
Type alias for symbol assignments on interstate edges.
Definition interstate_edge.h:30
symbolic::MultiExpression Subset
Type alias for a subset specification (array of symbolic expressions).
Definition memlet.h:103
TaskletCode
Operation codes for tasklet computations.
Definition tasklet.h:94
Definition language_extension.h:18
Definition analysis.h:7
StringEnum FunctionType
Definition function.h:37
Scalar (primitive) type representation.
Definition structured_sdfg_builder.h:28
ConditionalDeleter(bool should_delete=true)
Definition structured_sdfg_builder.h:31
bool should_delete_
Definition structured_sdfg_builder.h:29
void operator()(T *ptr) const
Definition structured_sdfg_builder.h:34