• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / docc / 28809522800

06 Jul 2026 05:12PM UTC coverage: 62.882% (-0.08%) from 62.96%
28809522800

Pull #843

github

web-flow
Merge beb5b23d7 into 95ea95f1f
Pull Request #843: adds type_ids for Element classes and a human-readable element_type

413 of 587 new or added lines in 121 files covered. (70.36%)

74 existing lines in 6 files now uncovered.

40564 of 64508 relevant lines covered (62.88%)

961.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/sdfg/include/sdfg/data_flow/code_node.h
1
/**
2
 * @file code_node.h
3
 * @brief Base class for computational nodes in the dataflow graph
4
 *
5
 * Code nodes represent computational operations in the SDFG dataflow graph. They are
6
 * abstract nodes that have inputs and outputs connected via memlets. Code nodes include
7
 * tasklets (simple operations) and library nodes (complex operations).
8
 *
9
 * ## Key Concepts
10
 *
11
 * ### Code Node
12
 * A CodeNode is the base class for all computational nodes. It defines:
13
 * - Input connectors: Named inputs that receive data via memlets
14
 * - Output connectors: Named outputs that send data via memlets
15
 * - Connection interface for memlets
16
 *
17
 * ### Input/Output Connectors
18
 * Connectors are named strings that identify specific inputs and outputs.
19
 * For example, a binary operation might have inputs "_in1" and "_in2" and
20
 * output "_out". Memlets connect access nodes to these connectors.
21
 *
22
 * ### Derived Classes
23
 * - Tasklet: Simple operations like addition, multiplication, assignment
24
 * - LibraryNode: Complex operations like BLAS calls, reductions, custom functions
25
 *
26
 * ## Example Usage
27
 *
28
 * Creating a code node (via Tasklet):
29
 * @code
30
 * // Create a binary addition tasklet
31
 * auto& tasklet = builder.add_tasklet(
32
 *     state,
33
 *     TaskletCode::fp_add,
34
 *     "_out",              // output connector
35
 *     {"_in1", "_in2"}     // input connectors
36
 * );
37
 *
38
 * // Connect inputs and output
39
 * builder.add_computational_memlet(state, a_node, tasklet, "_in1", {});
40
 * builder.add_computational_memlet(state, b_node, tasklet, "_in2", {});
41
 * builder.add_computational_memlet(state, tasklet, "_out", result_node, {});
42
 * @endcode
43
 *
44
 * Accessing inputs and outputs:
45
 * @code
46
 * const auto& inputs = tasklet.inputs();   // Get all input connector names
47
 * const auto& outputs = tasklet.outputs(); // Get all output connector names
48
 * std::string first_input = tasklet.input(0);  // Get first input by index
49
 * bool is_const = tasklet.has_constant_input(0); // Check if input is constant
50
 * @endcode
51
 *
52
 * @see DataFlowNode for the base class
53
 * @see Tasklet for simple operations
54
 * @see LibraryNode for complex operations
55
 * @see Memlet for edge connections
56
 */
57

58
#pragma once
59

60
#include "sdfg/data_flow/data_flow_node.h"
61
#include "sdfg/graph/graph.h"
62
#include "sdfg/types/scalar.h"
63

64
namespace sdfg {
65

66
namespace builder {
67
class SDFGBuilder;
68
class StructuredSDFGBuilder;
69
} // namespace builder
70

71
namespace data_flow {
72

73
/**
74
 * @class CodeNode
75
 * @brief Base class for computational nodes with inputs and outputs
76
 *
77
 * CodeNode represents any computational operation in the dataflow graph.
78
 * It provides:
79
 * - Named input and output connectors
80
 * - Methods to query and modify connectors
81
 * - Detection of constant inputs
82
 * - Abstract cloning interface for graph transformations
83
 *
84
 * Derived classes must implement:
85
 * - validate(): Validate the node's configuration
86
 * - clone(): Create a copy of the node
87
 */
88
class CodeNode : public DataFlowNode {
89
    friend class sdfg::builder::SDFGBuilder;
90
    friend class sdfg::builder::StructuredSDFGBuilder;
91

92
protected:
93
    std::vector<std::string> outputs_; ///< Names of output connectors
94
    std::vector<std::string> inputs_; ///< Names of input connectors
95

96
    /**
97
     * @brief Protected constructor for code nodes
98
     * @param element_id Unique element identifier
99
     * @param debug_info Debug information for this node
100
     * @param vertex Graph vertex for this node
101
     * @param parent Parent dataflow graph
102
     * @param outputs Names of output connectors
103
     * @param inputs Names of input connectors
104
     */
105
    CodeNode(
106
        size_t element_id,
107
        const DebugInfo& debug_info,
108
        const graph::Vertex vertex,
109
        DataFlowGraph& parent,
110
        const std::vector<std::string>& outputs,
111
        const std::vector<std::string>& inputs
112
    );
113

114
public:
115
    /// Bitmask of all concrete ElementTypes that are CodeNodes.
116
    static constexpr ElementType TypeGroup = ElementType::Tasklet | ElementType::LibraryNode;
117

118
    /// LLVM-style RTTI predicate: true if \p element is a CodeNode.
NEW
119
    static bool classof(const Element& element) { return is_a(element.type_id(), TypeGroup); }
×
120

121
    CodeNode(const CodeNode& data_node) = delete;
122
    CodeNode& operator=(const CodeNode&) = delete;
123

124
    /**
125
     * @brief Validate the code node's configuration
126
     * @param function Function context for validation
127
     *
128
     * Ensures that:
129
     * - No two access nodes connect to the same data for inputs/outputs
130
     */
131
    void validate(const Function& function) const override;
132

133
    /**
134
     * @brief Get output connector names (const)
135
     * @return Const reference to vector of output connector names
136
     */
137
    const std::vector<std::string>& outputs() const;
138

139
    /**
140
     * @brief Get input connector names (const)
141
     * @return Const reference to vector of input connector names
142
     */
143
    const std::vector<std::string>& inputs() const;
144

145
    /**
146
     * @brief Get output connector names (mutable)
147
     * @return Mutable reference to vector of output connector names
148
     */
149
    std::vector<std::string>& outputs();
150

151
    /**
152
     * @brief Get input connector names (mutable)
153
     * @return Mutable reference to vector of input connector names
154
     */
155
    std::vector<std::string>& inputs();
156

157
    /**
158
     * @brief Get output connector name by index
159
     * @param index Index of the output connector
160
     * @return Name of the output connector at the given index
161
     */
162
    const std::string& output(size_t index) const;
163

164
    /**
165
     * @brief Get input connector name by index
166
     * @param index Index of the input connector
167
     * @return Name of the input connector at the given index
168
     */
169
    const std::string& input(size_t index) const;
170

171
    /**
172
     * @brief Check if an input is connected to a constant node
173
     * @param index Index of the input connector to check
174
     * @return True if the input is connected to a ConstantNode, false otherwise
175
     */
176
    bool has_constant_input(size_t index) const;
177
};
178
} // namespace data_flow
179
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc