docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
code_node.h File Reference

Base class for computational nodes in the dataflow graph. More...

Go to the source code of this file.

Classes

class  sdfg::data_flow::CodeNode
 Base class for computational nodes with inputs and outputs. More...

Namespaces

namespace  sdfg
namespace  sdfg::builder
namespace  sdfg::data_flow

Detailed Description

Base class for computational nodes in the dataflow graph.

Code nodes represent computational operations in the SDFG dataflow graph. They are abstract nodes that have inputs and outputs connected via memlets. Code nodes include tasklets (simple operations) and library nodes (complex operations).

Key Concepts

Code Node

A CodeNode is the base class for all computational nodes. It defines:

  • Input connectors: Named inputs that receive data via memlets
  • Output connectors: Named outputs that send data via memlets
  • Connection interface for memlets

Input/Output Connectors

Connectors are named strings that identify specific inputs and outputs. For example, a binary operation might have inputs "_in1" and "_in2" and output "_out". Memlets connect access nodes to these connectors.

Derived Classes

  • Tasklet: Simple operations like addition, multiplication, assignment
  • LibraryNode: Complex operations like BLAS calls, reductions, custom functions

Example Usage

Creating a code node (via Tasklet):

// Create a binary addition tasklet
auto& tasklet = builder.add_tasklet(
state,
TaskletCode::fp_add,
"_out", // output connector
{"_in1", "_in2"} // input connectors
);
// Connect inputs and output
builder.add_computational_memlet(state, a_node, tasklet, "_in1", {});
builder.add_computational_memlet(state, b_node, tasklet, "_in2", {});
builder.add_computational_memlet(state, tasklet, "_out", result_node, {});

Accessing inputs and outputs:

const auto& inputs = tasklet.inputs(); // Get all input connector names
const auto& outputs = tasklet.outputs(); // Get all output connector names
std::string first_input = tasklet.input(0); // Get first input by index
bool is_const = tasklet.has_constant_input(0); // Check if input is constant
See also
DataFlowNode for the base class
Tasklet for simple operations
LibraryNode for complex operations
Memlet for edge connections