docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
kernel_builder.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <vector>
6
15#include "sdfg/types/type.h"
16
17namespace sdfg {
18namespace fp_math {
19
24 std::shared_ptr<types::IType> base_type;
25};
26
34private:
37 DebugInfo debug_info_;
38
40 void connect(const KernelValue& value, data_flow::CodeNode& node, const std::string& connector);
41
42public:
44
46 return block_;
47 }
48
50 KernelValue read(data_flow::AccessNode& node, const data_flow::Subset& subset, const types::IType& base_type);
51
53 KernelValue read(const std::string& container, const data_flow::Subset& subset = {});
54
56
59
60 KernelValue op(data_flow::TaskletCode code, const std::vector<KernelValue>& inputs, types::PrimitiveType type);
61
63 cmath(math::cmath::CMathFunction function, const std::vector<KernelValue>& inputs, types::PrimitiveType type);
64
66 void store(
67 const KernelValue& value,
69 const data_flow::Subset& subset,
70 const types::IType& base_type
71 );
72
74 void store(const KernelValue& value, const std::string& container, const data_flow::Subset& subset = {});
75};
76
83private:
86 DebugInfo debug_info_;
87 std::vector<std::string> buffers_;
88
89public:
91
93 return builder_;
94 }
95
97 return scope_;
98 }
99
100 const DebugInfo& debug_info() const {
101 return debug_info_;
102 }
103
105 std::string scalar(const std::string& prefix, types::PrimitiveType type);
106
108 std::string buffer(const std::string& prefix, types::PrimitiveType type, const symbolic::Expression& count);
109
112 map(structured_control_flow::Sequence& scope, const std::string& prefix, const symbolic::Expression& bound);
113
116 for_loop(structured_control_flow::Sequence& scope, const std::string& prefix, const symbolic::Expression& bound);
117
121 const std::string& prefix,
122 const symbolic::Expression& bound,
124 const std::string& accumulator
125 );
126
128
130 void finish();
131};
132
133} // namespace fp_math
134} // namespace sdfg
Access nodes for reading/writing data in the dataflow graph.
Definition element.h:30
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
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
Builds the dataflow of one block from expressions.
Definition kernel_builder.h:33
KernelValue convert(const KernelValue &value, types::PrimitiveType type)
Converts value to type; a value already of that type is returned as is.
KernelValue constant(double value, types::PrimitiveType type)
void store(const KernelValue &value, data_flow::AccessNode &node, const data_flow::Subset &subset, const types::IType &base_type)
Assigns value, converted to the target's element type, to node at subset.
KernelValue op(data_flow::TaskletCode code, const std::vector< KernelValue > &inputs, types::PrimitiveType type)
BlockBuilder(builder::StructuredSDFGBuilder &builder, structured_control_flow::Block &block, DebugInfo debug_info)
structured_control_flow::Block & block()
Definition kernel_builder.h:45
KernelValue cmath(math::cmath::CMathFunction function, const std::vector< KernelValue > &inputs, types::PrimitiveType type)
KernelValue read(data_flow::AccessNode &node, const data_flow::Subset &subset, const types::IType &base_type)
Reads node at subset through a memlet of base_type.
KernelValue read(const std::string &container, const data_flow::Subset &subset={})
Reads a scalar container, or the element at subset of a pointer container.
void store(const KernelValue &value, const std::string &container, const data_flow::Subset &subset={})
Assigns value to a scalar container, or to the element at subset of a pointer container.
structured_control_flow::StructuredLoop & map(structured_control_flow::Sequence &scope, const std::string &prefix, const symbolic::Expression &bound)
A sequential map counting from zero up to bound in scope.
const DebugInfo & debug_info() const
Definition kernel_builder.h:100
structured_control_flow::StructuredLoop & reduce(structured_control_flow::Sequence &scope, const std::string &prefix, const symbolic::Expression &bound, structured_control_flow::ReductionOperation operation, const std::string &accumulator)
A reduction counting from zero up to bound in scope, combining into accumulator with operation.
structured_control_flow::Sequence & scope()
Definition kernel_builder.h:96
builder::StructuredSDFGBuilder & builder()
Definition kernel_builder.h:92
void finish()
Frees all buffers at the end of the scope.
KernelBuilder(builder::StructuredSDFGBuilder &builder, structured_control_flow::Sequence &scope, DebugInfo debug_info)
std::string scalar(const std::string &prefix, types::PrimitiveType type)
A new transient scalar.
structured_control_flow::StructuredLoop & for_loop(structured_control_flow::Sequence &scope, const std::string &prefix, const symbolic::Expression &bound)
A for loop counting from zero up to bound in scope.
BlockBuilder block(structured_control_flow::Sequence &scope)
std::string buffer(const std::string &prefix, types::PrimitiveType type, const symbolic::Expression &count)
A new transient buffer of count elements, allocated in the scope right away.
A control flow node representing a basic block with dataflow computations.
Definition block.h:42
A sequential container of control flow nodes.
Definition sequence.h:52
Base class for structured loop constructs.
Definition structured_loop.h:244
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
Definition function_builder.h:10
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 kernel_builder.h:18
CMathFunction
Enumeration of C math library functions.
Definition cmath_node.h:21
ReductionOperation
Associative and commutative reduction operators.
Definition reduce.h:29
PrimitiveType
Enumeration of all primitive data types supported by sdfglib.
Definition type.h:35
Definition analysis.h:7
A value in a block under construction: an access node with the subset and base type of the memlet rea...
Definition kernel_builder.h:21
data_flow::Subset subset
Definition kernel_builder.h:23
data_flow::AccessNode * node
Definition kernel_builder.h:22
std::shared_ptr< types::IType > base_type
Definition kernel_builder.h:24
Simple computational operations in the dataflow graph.
Core type system definitions for sdfglib.