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

daisytuner / sdfglib / 17637380013

11 Sep 2025 07:29AM UTC coverage: 59.755% (+0.6%) from 59.145%
17637380013

push

github

web-flow
New debug info (#210)

* initial draft

* update data structure and construction logic

* finalize DebugInfo draft

* fix tests

* Update serializer and fix tests

* fix append bug

* update data structure

* sdfg builder update

* const ref vectors

* update implementation and partial tests

* compiling state

* update serializer interface

* update dot test

* reset interface to debug_info in json to maintain compatibility with tools

* first review batch

* second batch of changes

* merge fixes

777 of 1111 new or added lines in 46 files covered. (69.94%)

11 existing lines in 11 files now uncovered.

9755 of 16325 relevant lines covered (59.75%)

115.06 hits per line

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

0.0
/src/data_flow/library_nodes/math/ml/matmul.cpp
1
#include "sdfg/data_flow/library_nodes/math/ml/matmul.h"
2

3
#include "sdfg/analysis/analysis.h"
4
#include "sdfg/analysis/scope_analysis.h"
5
#include "sdfg/builder/structured_sdfg_builder.h"
6

7
namespace sdfg {
8
namespace math {
9
namespace ml {
10

11
MatMulNode::MatMulNode(
×
12
    size_t element_id, const DebugInfoRegion &debug_info, const graph::Vertex vertex, data_flow::DataFlowGraph &parent
13
)
14
    : MathNode(
×
15
          element_id,
×
16
          debug_info,
×
17
          vertex,
×
18
          parent,
×
19
          LibraryNodeType_MatMul,
20
          {"C"},
×
21
          {"A", "B"},
×
22
          data_flow::ImplementationType_NONE
23
      ) {}
×
24

25
void MatMulNode::validate(const Function &) const { /* TODO */ }
×
26

27
bool MatMulNode::expand(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) {
×
28
    auto &dataflow = this->get_parent();
×
29
    auto &block = static_cast<structured_control_flow::Block &>(*dataflow.get_parent());
×
30

31
    auto &scope_analysis = analysis_manager.get<analysis::ScopeAnalysis>();
×
32
    auto &parent = static_cast<structured_control_flow::Sequence &>(*scope_analysis.parent_scope(&block));
×
33
    int index = parent.index(block);
×
34
    auto &transition = parent.at(index).second;
×
35

36
    // Locate edges
37
    const data_flow::Memlet *iedge_A = nullptr;
×
38
    const data_flow::Memlet *iedge_B = nullptr;
×
39
    const data_flow::Memlet *oedge_C = nullptr;
×
40
    for (const auto &edge : dataflow.in_edges(*this)) {
×
41
        if (edge.dst_conn() == "A") {
×
42
            iedge_A = &edge;
×
43
        }
×
44
        if (edge.dst_conn() == "B") {
×
45
            iedge_B = &edge;
×
46
        }
×
47
    }
48
    for (const auto &edge : dataflow.out_edges(*this)) {
×
49
        if (edge.src_conn() == "C") {
×
50
            oedge_C = &edge;
×
51
        }
×
52
    }
53
    if (!iedge_A || !iedge_B || !oedge_C) return false;
×
54

55
    std::string A_name = static_cast<const data_flow::AccessNode &>(iedge_A->src()).data();
×
56
    std::string B_name = static_cast<const data_flow::AccessNode &>(iedge_B->src()).data();
×
57
    std::string C_name = static_cast<const data_flow::AccessNode &>(oedge_C->dst()).data();
×
58

59
    // Create new sequence before
NEW
60
    auto &new_sequence = builder.add_sequence_before(
×
NEW
61
        parent, block, transition.assignments(), builder.debug_info().get_region(block.debug_info().indices())
×
62
    );
UNCOV
63
    structured_control_flow::Sequence *last_scope = &new_sequence;
×
64

65
    // Create maps over output subset dims (parallel dims)
66
    data_flow::Subset domain_begin = {
×
67
        symbolic::integer(0),
×
68
        symbolic::integer(0),
×
69
        symbolic::integer(0),
×
70
    };
71
    data_flow::Subset domain_end = {
×
72
        oedge_C->end_subset()[0],
×
73
        oedge_C->end_subset()[1],
×
74
        iedge_A->end_subset()[1],
×
75
    };
76

77
    std::vector<symbolic::Expression> out_syms;
×
78
    structured_control_flow::Map *last_map = nullptr;
×
79
    for (size_t d = 0; d < domain_begin.size(); ++d) {
×
80
        std::string indvar_str = builder.find_new_name("_i");
×
81
        builder.add_container(indvar_str, types::Scalar(types::PrimitiveType::UInt64));
×
82
        auto indvar = symbolic::symbol(indvar_str);
×
83
        auto init = domain_begin[d];
×
84
        auto update = symbolic::add(indvar, symbolic::one());
×
85
        auto cond = symbolic::Lt(indvar, symbolic::add(domain_end[d], symbolic::one()));
×
86
        last_map = &builder.add_map(
×
87
            *last_scope,
×
88
            indvar,
89
            cond,
90
            init,
91
            update,
92
            structured_control_flow::ScheduleType_Sequential::create(),
×
93
            {},
×
NEW
94
            builder.debug_info().get_region(block.debug_info().indices())
×
95
        );
96
        last_scope = &last_map->root();
×
97
        out_syms.push_back(indvar);
×
98
    }
×
99

100
    // Create innermost block
101
    auto &code_block = builder.add_block(*last_scope);
×
NEW
102
    auto &tasklet = builder.add_tasklet(
×
NEW
103
        code_block,
×
104
        data_flow::TaskletCode::fma,
NEW
105
        "_out",
×
NEW
106
        {"_in1", "_in2", "_in3"},
×
NEW
107
        builder.debug_info().get_region(block.debug_info().indices())
×
108
    );
109

NEW
110
    auto &A_in = builder.add_access(code_block, A_name, builder.debug_info().get_region(block.debug_info().indices()));
×
NEW
111
    auto &B_in = builder.add_access(code_block, B_name, builder.debug_info().get_region(block.debug_info().indices()));
×
NEW
112
    auto &C_in = builder.add_access(code_block, C_name, builder.debug_info().get_region(block.debug_info().indices()));
×
NEW
113
    auto &C_out = builder.add_access(code_block, C_name, builder.debug_info().get_region(block.debug_info().indices()));
×
114

115
    builder.add_computational_memlet(
×
NEW
116
        code_block,
×
NEW
117
        A_in,
×
NEW
118
        tasklet,
×
NEW
119
        "_in1",
×
NEW
120
        {out_syms[0], out_syms[2]},
×
NEW
121
        iedge_A->base_type(),
×
NEW
122
        builder.debug_info().get_region(block.debug_info().indices())
×
123
    );
124
    builder.add_computational_memlet(
×
NEW
125
        code_block,
×
NEW
126
        B_in,
×
NEW
127
        tasklet,
×
NEW
128
        "_in2",
×
NEW
129
        {out_syms[1], out_syms[2]},
×
NEW
130
        iedge_B->base_type(),
×
NEW
131
        builder.debug_info().get_region(block.debug_info().indices())
×
132
    );
133
    builder.add_computational_memlet(
×
NEW
134
        code_block,
×
NEW
135
        C_in,
×
NEW
136
        tasklet,
×
NEW
137
        "_in3",
×
NEW
138
        {out_syms[0], out_syms[1]},
×
NEW
139
        oedge_C->base_type(),
×
NEW
140
        builder.debug_info().get_region(block.debug_info().indices())
×
141
    );
142
    builder.add_computational_memlet(
×
NEW
143
        code_block,
×
NEW
144
        tasklet,
×
NEW
145
        "_out",
×
NEW
146
        C_out,
×
NEW
147
        {out_syms[0], out_syms[1]},
×
NEW
148
        oedge_C->base_type(),
×
NEW
149
        builder.debug_info().get_region(block.debug_info().indices())
×
150
    );
151

152
    // Cleanup old block
153
    builder.remove_memlet(block, *iedge_A);
×
154
    builder.remove_memlet(block, *iedge_B);
×
155
    builder.remove_memlet(block, *oedge_C);
×
156
    builder.remove_node(block, *this);
×
157
    builder.remove_child(parent, index + 1);
×
158

159
    return true;
×
160
}
×
161

162
std::unique_ptr<data_flow::DataFlowNode> MatMulNode::
163
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph &parent) const {
×
164
    return std::unique_ptr<data_flow::DataFlowNode>(new MatMulNode(element_id, this->debug_info(), vertex, parent));
×
165
}
×
166

167
nlohmann::json MatMulNodeSerializer::serialize(const data_flow::LibraryNode &library_node) {
×
168
    const MatMulNode &node = static_cast<const MatMulNode &>(library_node);
×
169
    nlohmann::json j;
×
170

171
    j["code"] = node.code().value();
×
172

173
    return j;
×
174
}
×
175

176
data_flow::LibraryNode &MatMulNodeSerializer::deserialize(
×
177
    const nlohmann::json &j, builder::StructuredSDFGBuilder &builder, structured_control_flow::Block &parent
178
) {
179
    auto code = j["code"].get<std::string>();
×
180
    if (code != LibraryNodeType_MatMul.value()) {
×
181
        throw std::runtime_error("Invalid library node code");
×
182
    }
183

184
    sdfg::serializer::JSONSerializer serializer;
×
NEW
185
    DebugInfoRegion debug_info = serializer.json_to_debug_info_region(j["debug_info"], builder.debug_info());
×
186

187
    return builder.add_library_node<MatMulNode>(parent, debug_info);
×
188
}
×
189

190
} // namespace ml
191
} // namespace math
192
} // 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