docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
tasklet.h
Go to the documentation of this file.
1
69
70#pragma once
71
73#include "sdfg/exceptions.h"
74#include "sdfg/graph/graph.h"
76
77namespace sdfg {
78
79namespace builder {
80class FunctionBuilder;
81class SDFGBuilder;
83} // namespace builder
84
85namespace data_flow {
86
154
161constexpr size_t arity(TaskletCode c) {
162 switch (c) {
165 return 1;
166 // Integer Relational Ops
186 return 2;
187 // Comparisions
198 return 2;
199 // Floating Point
201 return 1;
207 return 2;
208 // Comparisions
223 return 2;
225 return 3;
226 };
227 throw InvalidSDFGException("Invalid tasklet code");
228};
229
235constexpr bool is_unsigned(TaskletCode c) {
236 switch (c) {
247 return true;
248 default:
249 return false;
250 }
251};
252
258constexpr bool is_integer(TaskletCode c) {
259 switch (c) {
260 // Operations
281 // Comparisions
292 return true;
293 default:
294 return false;
295 }
296}
297
304 switch (c) {
305 // Operations
313 // Comparisions
328 return true;
329 default:
330 return false;
331 }
332};
333
348class Tasklet : public CodeNode {
352
353private:
354 TaskletCode code_;
355
366 Tasklet(
367 size_t element_id,
368 const DebugInfo& debug_info,
369 const graph::Vertex vertex,
370 DataFlowGraph& parent,
371 const TaskletCode code,
372 const std::string& output,
373 const std::vector<std::string>& inputs
374 );
375
376public:
377 Tasklet(const Tasklet& data_node) = delete;
378 Tasklet& operator=(const Tasklet&) = delete;
379
380 ElementType type_id() const override {
382 }
383
384 static bool classof(const Element& element) {
385 return element.type_id() == ElementType::Tasklet;
386 }
387
393 void validate(const Function& function) const override;
394
395 [[nodiscard]] bool side_effect() const override {
396 return false;
397 }
398
404
409 bool is_assign() const;
410
416 bool is_trivial(const Function& function) const;
417
423 bool is_cast(const Function& function) const;
424
430 bool is_zext(const Function& function) const;
431
437 bool is_sext(const Function& function) const;
438
444 bool is_trunc(const Function& function) const;
445
451 bool is_fptoui(const Function& function) const;
452
458 bool is_fptosi(const Function& function) const;
459
465 bool is_uitofp(const Function& function) const;
466
472 bool is_sitofp(const Function& function) const;
473
479 bool is_fpext(const Function& function) const;
480
486 bool is_fptrunc(const Function& function) const;
487
492 const std::string& output() const;
493
501 virtual std::unique_ptr<DataFlowNode>
502 clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph& parent) const override;
503
509 void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override;
510 void replace(const symbolic::ExpressionMapping& replacements) override;
511
514};
515} // namespace data_flow
516} // namespace sdfg
Definition element.h:30
Element(size_t element_id, const DebugInfo &debug_info)
size_t element_id() const
const DebugInfo & debug_info() const
virtual ElementType type_id() const =0
Returns the type of the element.
Definition function.h:43
Definition exceptions.h:8
Definition function_builder.h:12
Definition sdfg_builder.h:13
Note: Even though the class references unique_ptr, it will never delete an SDFG it has a reference to...
Definition structured_sdfg_builder.h:44
CodeNode(size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, DataFlowGraph &parent, const std::vector< std::string > &outputs, const std::vector< std::string > &inputs)
Protected constructor for code nodes.
const std::vector< std::string > & inputs() const
Get input connector names (const).
Definition data_flow_graph.h:29
graph::Vertex vertex() const
Get the graph vertex for this node.
Edge in the dataflow graph representing data movement.
Definition memlet.h:131
bool is_assign() const
Check if this is an assignment operation.
void validate(const Function &function) const override
Validate the tasklet.
const std::string & output() const
Get the output connector name (single output).
bool is_trunc(const Function &function) const
Check if this is a truncate cast.
Tasklet(const Tasklet &data_node)=delete
EdgeRemoveOption can_remove_in_edge(const data_flow::DataFlowGraph &graph, const Memlet *memlet) const override
bool side_effect() const override
Check if this node has side effects Side effect on dflow nodes is broad.
Definition tasklet.h:395
bool is_sitofp(const Function &function) const
Check if this is a signed-int-to-float cast.
bool is_fpext(const Function &function) const
Check if this is a float precision extension cast.
ElementType type_id() const override
Returns the type of the element.
Definition tasklet.h:380
bool is_sext(const Function &function) const
Check if this is a sign-extend cast.
static bool classof(const Element &element)
Definition tasklet.h:384
void replace(const symbolic::ExpressionMapping &replacements) override
bool is_fptrunc(const Function &function) const
Check if this is a float precision truncation cast.
TaskletCode code() const
Get the operation code.
Tasklet & operator=(const Tasklet &)=delete
bool is_zext(const Function &function) const
Check if this is a zero-extend cast.
EdgeRemoveOption can_remove_out_edge(const data_flow::DataFlowGraph &graph, const Memlet *memlet) const override
Is the edge in question removable, or will this make the node its an output on invalid?
virtual std::unique_ptr< DataFlowNode > clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph &parent) const override
Clone this tasklet for graph transformations.
void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
Replace symbolic expressions in this tasklet.
bool is_fptosi(const Function &function) const
Check if this is a float-to-signed-int cast.
bool is_uitofp(const Function &function) const
Check if this is an unsigned-int-to-float cast.
bool is_trivial(const Function &function) const
Check if this is a trivial (no-op) assignment.
bool is_cast(const Function &function) const
Check if this is a type cast.
bool is_fptoui(const Function &function) const
Check if this is a float-to-unsigned-int cast.
Base class for computational nodes in the dataflow graph.
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
SymEngine::map_basic_basic ExpressionMapping
Definition symbolic.h:109
Definition function_builder.h:10
Definition access_node.h:67
EdgeRemoveOption
Definition data_flow_node.h:71
constexpr bool is_integer(TaskletCode c)
Check if a tasklet operation is an integer operation.
Definition tasklet.h:258
constexpr bool is_floating_point(TaskletCode c)
Check if a tasklet operation is a floating-point operation.
Definition tasklet.h:303
constexpr bool is_unsigned(TaskletCode c)
Check if a tasklet operation is unsigned.
Definition tasklet.h:235
constexpr size_t arity(TaskletCode c)
Get the number of inputs for a tasklet operation.
Definition tasklet.h:161
TaskletCode
Operation codes for tasklet computations.
Definition tasklet.h:94
@ fp_fma
Floating-point fused multiply-add.
Definition tasklet.h:104
@ fp_mul
Floating-point multiplication.
Definition tasklet.h:101
@ fp_add
Floating-point addition.
Definition tasklet.h:99
@ int_ucmp
Unsigned comparison (-1, 0, 1).
Definition tasklet.h:140
@ int_udiv
Unsigned integer division.
Definition tasklet.h:127
@ fp_ole
Floating-point ordered less or equal.
Definition tasklet.h:110
@ fp_rem
Floating-point remainder (fmod semantics).
Definition tasklet.h:103
@ int_umax
Unsigned maximum.
Definition tasklet.h:139
@ int_smin
Signed minimum.
Definition tasklet.h:135
@ int_uge
Unsigned greater or equal.
Definition tasklet.h:148
@ int_xor
Bitwise XOR.
Definition tasklet.h:131
@ fp_uno
Floating-point unordered (at least one operand is NaN).
Definition tasklet.h:119
@ int_eq
Integer equal.
Definition tasklet.h:142
@ int_urem
Unsigned integer remainder.
Definition tasklet.h:128
@ int_or
Bitwise OR.
Definition tasklet.h:130
@ int_ule
Unsigned less or equal.
Definition tasklet.h:150
@ fp_une
Floating-point unordered not equal.
Definition tasklet.h:114
@ assign
Assignment/copy operation (can be cast if types differ).
Definition tasklet.h:95
@ fp_one
Floating-point ordered not equal.
Definition tasklet.h:107
@ fp_ord
Floating-point ordered (neither operand is NaN).
Definition tasklet.h:112
@ int_umin
Unsigned minimum.
Definition tasklet.h:138
@ int_lshr
Logical shift right (zero-extend).
Definition tasklet.h:134
@ int_shl
Shift left.
Definition tasklet.h:132
@ fp_div
Floating-point division.
Definition tasklet.h:102
@ int_abs
Integer absolute value.
Definition tasklet.h:152
@ fp_oge
Floating-point ordered greater or equal.
Definition tasklet.h:108
@ int_ult
Unsigned less than.
Definition tasklet.h:151
@ fp_ule
Floating-point unordered less or equal.
Definition tasklet.h:118
@ fp_ult
Floating-point unordered less than.
Definition tasklet.h:117
@ fp_ugt
Floating-point unordered greater than.
Definition tasklet.h:115
@ fp_ueq
Floating-point unordered equal.
Definition tasklet.h:113
@ fp_uge
Floating-point unordered greater or equal.
Definition tasklet.h:116
@ fp_oeq
Floating-point ordered equal.
Definition tasklet.h:106
@ int_smax
Signed maximum.
Definition tasklet.h:136
@ fp_sub
Floating-point subtraction.
Definition tasklet.h:100
@ int_ugt
Unsigned greater than.
Definition tasklet.h:149
@ int_and
Bitwise AND.
Definition tasklet.h:129
@ fp_neg
Floating-point negation.
Definition tasklet.h:98
@ int_sle
Signed less or equal.
Definition tasklet.h:146
@ fp_olt
Floating-point ordered less than.
Definition tasklet.h:111
@ int_mul
Integer multiplication.
Definition tasklet.h:124
@ int_sge
Signed greater or equal.
Definition tasklet.h:144
@ int_add
Integer addition.
Definition tasklet.h:122
@ int_sdiv
Signed integer division.
Definition tasklet.h:125
@ int_sgt
Signed greater than.
Definition tasklet.h:145
@ int_ashr
Arithmetic shift right (sign-extend).
Definition tasklet.h:133
@ int_srem
Signed integer remainder.
Definition tasklet.h:126
@ int_ne
Integer not equal.
Definition tasklet.h:143
@ fp_ogt
Floating-point ordered greater than.
Definition tasklet.h:109
@ int_sub
Integer subtraction.
Definition tasklet.h:123
@ int_scmp
Signed comparison (-1, 0, 1).
Definition tasklet.h:137
@ int_slt
Signed less than.
Definition tasklet.h:147
Definition graph.h:22
boost::graph_traits< Graph >::vertex_descriptor Vertex
Definition graph.h:25
Definition analysis.h:7
ElementType
Definition element.h:72
@ Tasklet
Definition element.h:77
Symbolic system for integer-based symbol analysis.