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

daisytuner / sdfglib / 17589393671

09 Sep 2025 04:35PM UTC coverage: 61.094% (+1.9%) from 59.145%
17589393671

Pull #219

github

web-flow
Merge a2a473c0b into b8fdeb232
Pull Request #219: stdlib Library Nodes and ConstantNodes

424 of 1357 new or added lines in 74 files covered. (31.25%)

90 existing lines in 32 files now uncovered.

9307 of 15234 relevant lines covered (61.09%)

109.01 hits per line

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

76.47
/src/codegen/dispatchers/node_dispatcher_registry.cpp
1
#include "sdfg/codegen/dispatchers/node_dispatcher_registry.h"
2

3
#include "sdfg/codegen/dispatchers/block_dispatcher.h"
4
#include "sdfg/codegen/dispatchers/for_dispatcher.h"
5
#include "sdfg/codegen/dispatchers/if_else_dispatcher.h"
6
#include "sdfg/codegen/dispatchers/map_dispatcher.h"
7
#include "sdfg/codegen/dispatchers/sequence_dispatcher.h"
8
#include "sdfg/codegen/dispatchers/while_dispatcher.h"
9

10
#include "sdfg/data_flow/library_nodes/barrier_local_node.h"
11
#include "sdfg/data_flow/library_nodes/call_node.h"
12
#include "sdfg/data_flow/library_nodes/math/math.h"
13
#include "sdfg/data_flow/library_nodes/metadata_node.h"
14
#include "sdfg/data_flow/library_nodes/stdlib/stdlib.h"
15

16
namespace sdfg {
17
namespace codegen {
18

19
std::unique_ptr<NodeDispatcher> create_dispatcher(
24✔
20
    LanguageExtension& language_extension,
21
    StructuredSDFG& sdfg,
22
    structured_control_flow::ControlFlowNode& node,
23
    InstrumentationPlan& instrumentation_plan
24
) {
25
    auto dispatcher = NodeDispatcherRegistry::instance().get_dispatcher(typeid(node));
24✔
26
    if (dispatcher) {
24✔
27
        return dispatcher(language_extension, sdfg, node, instrumentation_plan);
24✔
28
    }
29

30
    throw std::runtime_error("Unsupported control flow node: " + std::string(typeid(node).name()));
×
31
};
24✔
32

33
void register_default_dispatchers() {
2✔
34
    /* Control flow dispatchers */
35
    NodeDispatcherRegistry::instance().register_dispatcher(
4✔
36
        typeid(structured_control_flow::Block),
2✔
37
        [](LanguageExtension& language_extension,
6✔
38
           StructuredSDFG& sdfg,
39
           structured_control_flow::ControlFlowNode& node,
40
           InstrumentationPlan& instrumentation) {
41
            return std::make_unique<BlockDispatcher>(
4✔
42
                language_extension, sdfg, static_cast<structured_control_flow::Block&>(node), instrumentation
4✔
43
            );
44
        }
45
    );
46
    NodeDispatcherRegistry::instance().register_dispatcher(
4✔
47
        typeid(structured_control_flow::Sequence),
2✔
48
        [](LanguageExtension& language_extension,
16✔
49
           StructuredSDFG& sdfg,
50
           structured_control_flow::ControlFlowNode& node,
51
           InstrumentationPlan& instrumentation) {
52
            return std::make_unique<SequenceDispatcher>(
14✔
53
                language_extension, sdfg, static_cast<structured_control_flow::Sequence&>(node), instrumentation
14✔
54
            );
55
        }
56
    );
57
    NodeDispatcherRegistry::instance().register_dispatcher(
4✔
58
        typeid(structured_control_flow::IfElse),
2✔
59
        [](LanguageExtension& language_extension,
3✔
60
           StructuredSDFG& sdfg,
61
           structured_control_flow::ControlFlowNode& node,
62
           InstrumentationPlan& instrumentation) {
63
            return std::make_unique<IfElseDispatcher>(
1✔
64
                language_extension, sdfg, static_cast<structured_control_flow::IfElse&>(node), instrumentation
1✔
65
            );
66
        }
67
    );
68
    NodeDispatcherRegistry::instance().register_dispatcher(
4✔
69
        typeid(structured_control_flow::While),
2✔
70
        [](LanguageExtension& language_extension,
3✔
71
           StructuredSDFG& sdfg,
72
           structured_control_flow::ControlFlowNode& node,
73
           InstrumentationPlan& instrumentation) {
74
            return std::make_unique<WhileDispatcher>(
1✔
75
                language_extension, sdfg, static_cast<structured_control_flow::While&>(node), instrumentation
1✔
76
            );
77
        }
78
    );
79
    NodeDispatcherRegistry::instance().register_dispatcher(
4✔
80
        typeid(structured_control_flow::For),
2✔
81
        [](LanguageExtension& language_extension,
3✔
82
           StructuredSDFG& sdfg,
83
           structured_control_flow::ControlFlowNode& node,
84
           InstrumentationPlan& instrumentation) {
85
            return std::make_unique<ForDispatcher>(
1✔
86
                language_extension, sdfg, static_cast<structured_control_flow::For&>(node), instrumentation
1✔
87
            );
88
        }
89
    );
90
    NodeDispatcherRegistry::instance().register_dispatcher(
4✔
91
        typeid(structured_control_flow::Map),
2✔
92
        [](LanguageExtension& language_extension,
2✔
93
           StructuredSDFG& sdfg,
94
           structured_control_flow::ControlFlowNode& node,
95
           InstrumentationPlan& instrumentation) {
96
            return std::make_unique<MapDispatcher>(
×
97
                language_extension, sdfg, static_cast<structured_control_flow::Map&>(node), instrumentation
×
98
            );
99
        }
100
    );
101
    NodeDispatcherRegistry::instance().register_dispatcher(
4✔
102
        typeid(structured_control_flow::Return),
2✔
103
        [](LanguageExtension& language_extension,
3✔
104
           StructuredSDFG& sdfg,
105
           structured_control_flow::ControlFlowNode& node,
106
           InstrumentationPlan& instrumentation) {
107
            return std::make_unique<ReturnDispatcher>(
1✔
108
                language_extension, sdfg, static_cast<structured_control_flow::Return&>(node), instrumentation
1✔
109
            );
110
        }
111
    );
112
    NodeDispatcherRegistry::instance().register_dispatcher(
4✔
113
        typeid(structured_control_flow::Break),
2✔
114
        [](LanguageExtension& language_extension,
3✔
115
           StructuredSDFG& sdfg,
116
           structured_control_flow::ControlFlowNode& node,
117
           InstrumentationPlan& instrumentation) {
118
            return std::make_unique<BreakDispatcher>(
1✔
119
                language_extension, sdfg, static_cast<structured_control_flow::Break&>(node), instrumentation
1✔
120
            );
121
        }
122
    );
123
    NodeDispatcherRegistry::instance().register_dispatcher(
4✔
124
        typeid(structured_control_flow::Continue),
2✔
125
        [](LanguageExtension& language_extension,
3✔
126
           StructuredSDFG& sdfg,
127
           structured_control_flow::ControlFlowNode& node,
128
           InstrumentationPlan& instrumentation) {
129
            return std::make_unique<ContinueDispatcher>(
1✔
130
                language_extension, sdfg, static_cast<structured_control_flow::Continue&>(node), instrumentation
1✔
131
            );
132
        }
133
    );
134

135
    /* Map dispatchers */
136
    MapDispatcherRegistry::instance().register_map_dispatcher(
4✔
137
        structured_control_flow::ScheduleType_Sequential::value(),
2✔
138
        [](LanguageExtension& language_extension,
3✔
139
           StructuredSDFG& sdfg,
140
           structured_control_flow::Map& node,
141
           InstrumentationPlan& instrumentation) {
142
            return std::make_unique<SequentialMapDispatcher>(language_extension, sdfg, node, instrumentation);
1✔
143
        }
144
    );
145
    MapDispatcherRegistry::instance().register_map_dispatcher(
4✔
146
        structured_control_flow::ScheduleType_CPU_Parallel::value(),
2✔
147
        [](LanguageExtension& language_extension,
2✔
148
           StructuredSDFG& sdfg,
149
           structured_control_flow::Map& node,
150
           InstrumentationPlan& instrumentation) {
151
            return std::make_unique<CPUParallelMapDispatcher>(language_extension, sdfg, node, instrumentation);
×
152
        }
153
    );
154

155
    // stdlib
156
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
157
        stdlib::LibraryNodeType_Calloc.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
158
        [](LanguageExtension& language_extension,
2✔
159
           const Function& function,
160
           const data_flow::DataFlowGraph& data_flow_graph,
161
           const data_flow::LibraryNode& node) {
NEW
162
            return std::make_unique<stdlib::CallocNodeDispatcher>(
×
NEW
163
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::CallocNode&>(node)
×
164
            );
165
        }
166
    );
167
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
168
        stdlib::LibraryNodeType_Fprintf.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
169
        [](LanguageExtension& language_extension,
2✔
170
           const Function& function,
171
           const data_flow::DataFlowGraph& data_flow_graph,
172
           const data_flow::LibraryNode& node) {
NEW
173
            return std::make_unique<stdlib::FprintfNodeDispatcher>(
×
NEW
174
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::FprintfNode&>(node)
×
175
            );
176
        }
177
    );
178
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
179
        stdlib::LibraryNodeType_FPutc.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
180
        [](LanguageExtension& language_extension,
2✔
181
           const Function& function,
182
           const data_flow::DataFlowGraph& data_flow_graph,
183
           const data_flow::LibraryNode& node) {
NEW
184
            return std::make_unique<stdlib::FPutcNodeDispatcher>(
×
NEW
185
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::FPutcNode&>(node)
×
186
            );
187
        }
188
    );
189
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
190
        stdlib::LibraryNodeType_Free.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
191
        [](LanguageExtension& language_extension,
2✔
192
           const Function& function,
193
           const data_flow::DataFlowGraph& data_flow_graph,
194
           const data_flow::LibraryNode& node) {
NEW
195
            return std::make_unique<stdlib::FreeNodeDispatcher>(
×
NEW
196
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::FreeNode&>(node)
×
197
            );
198
        }
199
    );
200
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
201
        stdlib::LibraryNodeType_FWrite.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
202
        [](LanguageExtension& language_extension,
2✔
203
           const Function& function,
204
           const data_flow::DataFlowGraph& data_flow_graph,
205
           const data_flow::LibraryNode& node) {
NEW
206
            return std::make_unique<stdlib::FWriteNodeDispatcher>(
×
NEW
207
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::FWriteNode&>(node)
×
208
            );
209
        }
210
    );
211
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
212
        stdlib::LibraryNodeType_Malloc.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
213
        [](LanguageExtension& language_extension,
2✔
214
           const Function& function,
215
           const data_flow::DataFlowGraph& data_flow_graph,
216
           const data_flow::LibraryNode& node) {
NEW
217
            return std::make_unique<stdlib::MallocNodeDispatcher>(
×
NEW
218
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::MallocNode&>(node)
×
219
            );
220
        }
221
    );
222
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
223
        stdlib::LibraryNodeType_Rand.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
224
        [](LanguageExtension& language_extension,
2✔
225
           const Function& function,
226
           const data_flow::DataFlowGraph& data_flow_graph,
227
           const data_flow::LibraryNode& node) {
NEW
228
            return std::make_unique<stdlib::RandNodeDispatcher>(
×
NEW
229
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::RandNode&>(node)
×
230
            );
231
        }
232
    );
233
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
234
        stdlib::LibraryNodeType_Srand.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
235
        [](LanguageExtension& language_extension,
2✔
236
           const Function& function,
237
           const data_flow::DataFlowGraph& data_flow_graph,
238
           const data_flow::LibraryNode& node) {
NEW
239
            return std::make_unique<stdlib::SrandNodeDispatcher>(
×
NEW
240
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::SrandNode&>(node)
×
241
            );
242
        }
243
    );
244

245
    // CallNode
246
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
247
        data_flow::LibraryNodeType_Call.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
248
        [](LanguageExtension& language_extension,
2✔
249
           const Function& function,
250
           const data_flow::DataFlowGraph& data_flow_graph,
251
           const data_flow::LibraryNode& node) {
NEW
252
            return std::make_unique<data_flow::CallNodeDispatcher>(
×
NEW
253
                language_extension, function, data_flow_graph, dynamic_cast<const data_flow::CallNode&>(node)
×
254
            );
255
        }
256
    );
257

258
    // BarrierLocal
259
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
260
        data_flow::LibraryNodeType_BarrierLocal.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
261
        [](LanguageExtension& language_extension,
3✔
262
           const Function& function,
263
           const data_flow::DataFlowGraph& data_flow_graph,
264
           const data_flow::LibraryNode& node) {
265
            return std::make_unique<data_flow::BarrierLocalNodeDispatcher>(
1✔
266
                language_extension, function, data_flow_graph, dynamic_cast<const data_flow::BarrierLocalNode&>(node)
1✔
267
            );
268
        }
269
    );
270

271
    // Metadata
272
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
273
        data_flow::LibraryNodeType_Metadata.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
274
        [](LanguageExtension& language_extension,
2✔
275
           const Function& function,
276
           const data_flow::DataFlowGraph& data_flow_graph,
277
           const data_flow::LibraryNode& node) {
278
            return std::make_unique<data_flow::MetadataDispatcher>(
×
279
                language_extension, function, data_flow_graph, dynamic_cast<const data_flow::MetadataNode&>(node)
×
280
            );
281
        }
282
    );
283

284
    // Math
285

286
    // Dot - BLAS
287
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
288
        math::blas::LibraryNodeType_DOT.value() + "::" + math::blas::ImplementationType_BLAS.value(),
2✔
289
        [](LanguageExtension& language_extension,
2✔
290
           const Function& function,
291
           const data_flow::DataFlowGraph& data_flow_graph,
292
           const data_flow::LibraryNode& node) {
293
            return std::make_unique<math::blas::DotNodeDispatcher_BLAS>(
×
294
                language_extension, function, data_flow_graph, dynamic_cast<const math::blas::DotNode&>(node)
×
295
            );
296
        }
297
    );
298
    // Dot - CUBLAS
299
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
300
        math::blas::LibraryNodeType_DOT.value() + "::" + math::blas::ImplementationType_CUBLAS.value(),
2✔
301
        [](LanguageExtension& language_extension,
2✔
302
           const Function& function,
303
           const data_flow::DataFlowGraph& data_flow_graph,
304
           const data_flow::LibraryNode& node) {
305
            return std::make_unique<math::blas::DotNodeDispatcher_CUBLAS>(
×
306
                language_extension, function, data_flow_graph, dynamic_cast<const math::blas::DotNode&>(node)
×
307
            );
308
        }
309
    );
310

311
    // GEMM - BLAS
312
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
313
        math::blas::LibraryNodeType_GEMM.value() + "::" + math::blas::ImplementationType_BLAS.value(),
2✔
314
        [](LanguageExtension& language_extension,
2✔
315
           const Function& function,
316
           const data_flow::DataFlowGraph& data_flow_graph,
317
           const data_flow::LibraryNode& node) {
318
            return std::make_unique<math::blas::GEMMNodeDispatcher_BLAS>(
×
319
                language_extension, function, data_flow_graph, dynamic_cast<const math::blas::GEMMNode&>(node)
×
320
            );
321
        }
322
    );
323
    // GEMM - CUBLAS
324
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
325
        math::blas::LibraryNodeType_GEMM.value() + "::" + math::blas::ImplementationType_CUBLAS.value(),
2✔
326
        [](LanguageExtension& language_extension,
2✔
327
           const Function& function,
328
           const data_flow::DataFlowGraph& data_flow_graph,
329
           const data_flow::LibraryNode& node) {
330
            return std::make_unique<math::blas::GEMMNodeDispatcher_CUBLAS>(
×
331
                language_extension, function, data_flow_graph, dynamic_cast<const math::blas::GEMMNode&>(node)
×
332
            );
333
        }
334
    );
335
}
2✔
336

337
} // namespace codegen
338
} // 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