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

daisytuner / sdfglib / 15044057891

15 May 2025 11:42AM UTC coverage: 59.37% (+1.8%) from 57.525%
15044057891

push

github

web-flow
Merge pull request #14 from daisytuner/sanitizers

enables sanitizer on unit tests

63 of 67 new or added lines in 47 files covered. (94.03%)

570 existing lines in 62 files now uncovered.

7356 of 12390 relevant lines covered (59.37%)

505.93 hits per line

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

52.59
/src/codegen/dispatchers/block_dispatcher.cpp
1
#include "sdfg/codegen/dispatchers/block_dispatcher.h"
2

3
namespace sdfg {
4
namespace codegen {
5

6
void DataFlowDispatcher::dispatch_tasklet(PrettyPrinter& stream,
2✔
7
                                          const data_flow::Tasklet& tasklet) {
8
    if (tasklet.is_conditional()) {
2✔
9
        stream << "if (" << language_extension_.expression(tasklet.condition()) << ") ";
×
UNCOV
10
    }
×
11
    stream << "{" << std::endl;
2✔
12
    stream.setIndent(stream.indent() + 4);
2✔
13

14
    // Connector declarations
15
    for (auto& iedge : this->data_flow_graph_.in_edges(tasklet)) {
6✔
16
        auto& src = dynamic_cast<const data_flow::AccessNode&>(iedge.src());
4✔
17

18
        const types::Scalar& conn_type = tasklet.input_type(iedge.dst_conn());
4✔
19
        stream << this->language_extension_.declaration(iedge.dst_conn(), conn_type);
4✔
20

21
        if (symbolic::is_nvptx(symbolic::symbol(src.data()))) {
4✔
22
            stream << " = " << src.data() << ";";
×
UNCOV
23
        } else {
×
24
            const types::IType& type = this->function_.type(src.data());
4✔
25
            stream << " = " << src.data()
8✔
26
                   << this->language_extension_.subset(function_, type, iedge.subset()) << ";";
4✔
27
        }
28
        stream << std::endl;
4✔
29
    }
30
    for (auto& oedge : this->data_flow_graph_.out_edges(tasklet)) {
4✔
31
        const types::Scalar& conn_type = tasklet.output_type(oedge.src_conn());
2✔
32
        stream << this->language_extension_.declaration(oedge.src_conn(), conn_type) << ";"
4✔
33
               << std::endl;
2✔
34
    }
35

36
    stream << std::endl;
2✔
37
    stream << tasklet.output(0).first << " = ";
2✔
38
    stream << this->language_extension_.tasklet(tasklet) << ";" << std::endl;
2✔
39
    stream << std::endl;
2✔
40

41
    // Write back
42
    for (auto& oedge : this->data_flow_graph_.out_edges(tasklet)) {
4✔
43
        auto& dst = dynamic_cast<const data_flow::AccessNode&>(oedge.dst());
2✔
44
        const types::IType& type = this->function_.type(dst.data());
2✔
45
        stream << dst.data() << this->language_extension_.subset(function_, type, oedge.subset())
4✔
46
               << " = ";
2✔
47
        stream << oedge.src_conn();
2✔
48
        stream << ";" << std::endl;
2✔
49
    }
50

51
    stream.setIndent(stream.indent() - 4);
2✔
52
    stream << "}" << std::endl;
2✔
53
};
2✔
54

55
void DataFlowDispatcher::dispatch_ref(PrettyPrinter& stream, const data_flow::Memlet& memlet) {
×
56
    stream << "{" << std::endl;
×
57
    stream.setIndent(stream.indent() + 4);
×
58

59
    auto dst_access_node = static_cast<const data_flow::AccessNode*>(&memlet.dst());
×
UNCOV
60
    auto dst_type =
×
61
        static_cast<const types::Pointer*>(&this->function_.type(dst_access_node->data()));
×
62

63
    stream << dst_access_node->data();
×
64

65
    // Case 1: Dereference dst
66
    if (memlet.dst_conn() == "void") {
×
67
        stream << this->language_extension_.subset(function_, *dst_type, memlet.subset());
×
68

UNCOV
69
        dst_type = static_cast<const types::Pointer*>(
×
70
            &types::infer_type(function_, *dst_type, memlet.subset()));
×
UNCOV
71
    }
×
72

73
    stream << " = ";
×
74

75
    // src is raw pointer
76
    auto src_access_node = static_cast<const data_flow::AccessNode*>(&memlet.src());
×
77
    if (symbolic::is_pointer(symbolic::symbol(src_access_node->data()))) {
×
78
        stream << language_extension_.expression(symbolic::symbol(src_access_node->data()));
×
UNCOV
79
    } else {
×
80
        auto src_type = &this->function_.type(src_access_node->data());
×
81

82
        // Case 2: Dereference src
83
        std::string rhs;
×
84
        if (memlet.src_conn() == "void") {
×
85
            rhs += "&";
×
86
            rhs += src_access_node->data();
×
87
            rhs += this->language_extension_.subset(function_, *src_type, memlet.subset());
×
88

89
            src_type = new types::Pointer(types::infer_type(function_, *src_type, memlet.subset()));
×
UNCOV
90
        } else {
×
91
            rhs = src_access_node->data();
×
92
        }
93

94
        if (*dst_type == *src_type) {
×
95
            stream << rhs;
×
UNCOV
96
        } else {
×
97
            stream << this->language_extension_.type_cast(rhs, *dst_type);
×
98
        }
99

100
        if (memlet.src_conn() == "void") {
×
101
            delete src_type;
×
UNCOV
102
        }
×
103
    }
×
104

105
    stream << ";";
×
106
    stream << std::endl;
×
107

108
    stream.setIndent(stream.indent() - 4);
×
109
    stream << "}" << std::endl;
×
110
};
×
111

112
void DataFlowDispatcher::dispatch_library_node(PrettyPrinter& stream,
1✔
113
                                               const data_flow::LibraryNode& libnode) {
114
    stream << "{" << std::endl;
1✔
115
    stream.setIndent(stream.indent() + 4);
1✔
116

117
    // Connector declarations
118
    for (auto& iedge : this->data_flow_graph_.in_edges(libnode)) {
1✔
119
        auto& src = dynamic_cast<const data_flow::AccessNode&>(iedge.src());
×
120

121
        const types::Scalar& conn_type = libnode.input_type(iedge.dst_conn());
×
122
        stream << this->language_extension_.declaration(iedge.dst_conn(), conn_type);
×
123

124
        if (symbolic::is_nvptx(symbolic::symbol(src.data()))) {
×
125
            stream << " = " << src.data() << ";";
×
UNCOV
126
        } else {
×
127
            const types::IType& type = this->function_.type(src.data());
×
128
            stream << " = " << src.data()
×
129
                   << this->language_extension_.subset(function_, type, iedge.subset()) << ";";
×
130
        }
131
        stream << std::endl;
×
132
    }
133
    for (auto& oedge : this->data_flow_graph_.out_edges(libnode)) {
1✔
134
        const types::Scalar& conn_type = libnode.output_type(oedge.src_conn());
×
135
        stream << this->language_extension_.declaration(oedge.src_conn(), conn_type) << ";"
×
136
               << std::endl;
×
137
    }
138

139
    stream << std::endl;
1✔
140
    stream << this->language_extension_.library_node(libnode);
1✔
141
    stream << std::endl;
1✔
142

143
    // Write back
144
    for (auto& oedge : this->data_flow_graph_.out_edges(libnode)) {
1✔
145
        auto& dst = dynamic_cast<const data_flow::AccessNode&>(oedge.dst());
×
146
        const types::IType& type = this->function_.type(dst.data());
×
147
        stream << dst.data() << this->language_extension_.subset(function_, type, oedge.subset())
×
148
               << " = ";
×
149
        stream << oedge.src_conn();
×
150
        stream << ";" << std::endl;
×
151
    }
152

153
    stream.setIndent(stream.indent() - 4);
1✔
154
    stream << "}" << std::endl;
1✔
155
};
1✔
156

157
DataFlowDispatcher::DataFlowDispatcher(LanguageExtension& language_extension, const Function& sdfg,
3✔
158
                                       const data_flow::DataFlowGraph& data_flow_graph)
159
    : language_extension_(language_extension),
3✔
160
      function_(sdfg),
3✔
161
      data_flow_graph_(data_flow_graph){
3✔
162

163
      };
3✔
164

165
void DataFlowDispatcher::dispatch(PrettyPrinter& stream) {
3✔
166
    // Dispatch code nodes in topological order
167
    auto nodes = this->data_flow_graph_.topological_sort();
3✔
168
    for (auto& node : nodes) {
12✔
169
        if (auto tasklet = dynamic_cast<const data_flow::Tasklet*>(node)) {
9✔
170
            this->dispatch_tasklet(stream, *tasklet);
2✔
171
        } else if (auto access_node = dynamic_cast<const data_flow::AccessNode*>(node)) {
9✔
172
            for (auto& edge : this->data_flow_graph_.out_edges(*access_node)) {
10✔
173
                if (edge.dst_conn() == "refs" || edge.src_conn() == "refs") {
4✔
174
                    this->dispatch_ref(stream, edge);
×
UNCOV
175
                }
×
176
            }
177
        } else if (auto libnode = dynamic_cast<const data_flow::LibraryNode*>(node)) {
7✔
178
            this->dispatch_library_node(stream, *libnode);
1✔
179
        }
1✔
180
    }
181
};
3✔
182

183
BlockDispatcher::BlockDispatcher(LanguageExtension& language_extension, Schedule& schedule,
8✔
184
                                 structured_control_flow::Block& node, bool instrumented)
185
    : NodeDispatcher(language_extension, schedule, node, instrumented),
8✔
186
      node_(node){
8✔
187

188
      };
8✔
189

190
void BlockDispatcher::dispatch_node(PrettyPrinter& main_stream, PrettyPrinter& globals_stream,
7✔
191
                                    PrettyPrinter& library_stream) {
192
    if (node_.dataflow().nodes().empty()) {
7✔
193
        return;
6✔
194
    }
195

196
    auto& sdfg = schedule_.sdfg();
1✔
197
    DataFlowDispatcher dispatcher(this->language_extension_, sdfg, node_.dataflow());
1✔
198
    dispatcher.dispatch(main_stream);
1✔
199
};
7✔
200

201
}  // namespace codegen
202
}  // 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