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

daisytuner / sdfglib / 17655994367

11 Sep 2025 08:06PM UTC coverage: 60.451% (+1.1%) from 59.335%
17655994367

Pull #219

github

web-flow
Merge 769d2cc0b into 6c1992b40
Pull Request #219: stdlib Library Nodes and ConstantNodes

457 of 1629 new or added lines in 81 files covered. (28.05%)

93 existing lines in 35 files now uncovered.

9382 of 15520 relevant lines covered (60.45%)

107.26 hits per line

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

74.36
/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(
21✔
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));
21✔
26
    if (dispatcher) {
21✔
27
        return dispatcher(language_extension, sdfg, node, instrumentation_plan);
21✔
28
    }
29

30
    throw std::runtime_error("Unsupported control flow node: " + std::string(typeid(node).name()));
×
31
};
21✔
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,
13✔
49
           StructuredSDFG& sdfg,
50
           structured_control_flow::ControlFlowNode& node,
51
           InstrumentationPlan& instrumentation) {
52
            return std::make_unique<SequenceDispatcher>(
11✔
53
                language_extension, sdfg, static_cast<structured_control_flow::Sequence&>(node), instrumentation
11✔
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_Alloca.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::AllocaNodeDispatcher>(
×
NEW
163
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::AllocaNode&>(node)
×
164
            );
165
        }
166
    );
167
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
168
        stdlib::LibraryNodeType_Calloc.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::CallocNodeDispatcher>(
×
NEW
174
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::CallocNode&>(node)
×
175
            );
176
        }
177
    );
178
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
179
        stdlib::LibraryNodeType_Fprintf.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::FprintfNodeDispatcher>(
×
NEW
185
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::FprintfNode&>(node)
×
186
            );
187
        }
188
    );
189
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
190
        stdlib::LibraryNodeType_Fputc.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::FputcNodeDispatcher>(
×
NEW
196
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::FputcNode&>(node)
×
197
            );
198
        }
199
    );
200
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
201
        stdlib::LibraryNodeType_Free.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::FreeNodeDispatcher>(
×
NEW
207
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::FreeNode&>(node)
×
208
            );
209
        }
210
    );
211
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
212
        stdlib::LibraryNodeType_FWrite.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::FWriteNodeDispatcher>(
×
NEW
218
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::FWriteNode&>(node)
×
219
            );
220
        }
221
    );
222
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
223
        stdlib::LibraryNodeType_Malloc.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::MallocNodeDispatcher>(
×
NEW
229
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::MallocNode&>(node)
×
230
            );
231
        }
232
    );
233
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
234
        stdlib::LibraryNodeType_Memcpy.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::MemcpyNodeDispatcher>(
×
NEW
240
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::MemcpyNode&>(node)
×
241
            );
242
        }
243
    );
244
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
245
        stdlib::LibraryNodeType_Memmove.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
246
        [](LanguageExtension& language_extension,
2✔
247
           const Function& function,
248
           const data_flow::DataFlowGraph& data_flow_graph,
249
           const data_flow::LibraryNode& node) {
NEW
250
            return std::make_unique<stdlib::MemmoveNodeDispatcher>(
×
NEW
251
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::MemmoveNode&>(node)
×
252
            );
253
        }
254
    );
255
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
256
        stdlib::LibraryNodeType_Memset.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
257
        [](LanguageExtension& language_extension,
2✔
258
           const Function& function,
259
           const data_flow::DataFlowGraph& data_flow_graph,
260
           const data_flow::LibraryNode& node) {
NEW
261
            return std::make_unique<stdlib::MemsetNodeDispatcher>(
×
NEW
262
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::MemsetNode&>(node)
×
263
            );
264
        }
265
    );
266
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
267
        stdlib::LibraryNodeType_Rand.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
268
        [](LanguageExtension& language_extension,
2✔
269
           const Function& function,
270
           const data_flow::DataFlowGraph& data_flow_graph,
271
           const data_flow::LibraryNode& node) {
NEW
272
            return std::make_unique<stdlib::RandNodeDispatcher>(
×
NEW
273
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::RandNode&>(node)
×
274
            );
275
        }
276
    );
277
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
278
        stdlib::LibraryNodeType_Srand.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
279
        [](LanguageExtension& language_extension,
2✔
280
           const Function& function,
281
           const data_flow::DataFlowGraph& data_flow_graph,
282
           const data_flow::LibraryNode& node) {
NEW
283
            return std::make_unique<stdlib::SrandNodeDispatcher>(
×
NEW
284
                language_extension, function, data_flow_graph, dynamic_cast<const stdlib::SrandNode&>(node)
×
285
            );
286
        }
287
    );
288

289
    // CallNode
290
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
291
        data_flow::LibraryNodeType_Call.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
292
        [](LanguageExtension& language_extension,
2✔
293
           const Function& function,
294
           const data_flow::DataFlowGraph& data_flow_graph,
295
           const data_flow::LibraryNode& node) {
NEW
296
            return std::make_unique<data_flow::CallNodeDispatcher>(
×
NEW
297
                language_extension, function, data_flow_graph, dynamic_cast<const data_flow::CallNode&>(node)
×
298
            );
299
        }
300
    );
301

302
    // BarrierLocal
303
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
304
        data_flow::LibraryNodeType_BarrierLocal.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
305
        [](LanguageExtension& language_extension,
3✔
306
           const Function& function,
307
           const data_flow::DataFlowGraph& data_flow_graph,
308
           const data_flow::LibraryNode& node) {
309
            return std::make_unique<data_flow::BarrierLocalNodeDispatcher>(
1✔
310
                language_extension, function, data_flow_graph, dynamic_cast<const data_flow::BarrierLocalNode&>(node)
1✔
311
            );
312
        }
313
    );
314

315
    // Metadata
316
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
317
        data_flow::LibraryNodeType_Metadata.value() + "::" + data_flow::ImplementationType_NONE.value(),
2✔
318
        [](LanguageExtension& language_extension,
2✔
319
           const Function& function,
320
           const data_flow::DataFlowGraph& data_flow_graph,
321
           const data_flow::LibraryNode& node) {
322
            return std::make_unique<data_flow::MetadataDispatcher>(
×
323
                language_extension, function, data_flow_graph, dynamic_cast<const data_flow::MetadataNode&>(node)
×
324
            );
325
        }
326
    );
327

328
    // Math
329

330
    // Dot - BLAS
331
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
332
        math::blas::LibraryNodeType_DOT.value() + "::" + math::blas::ImplementationType_BLAS.value(),
2✔
333
        [](LanguageExtension& language_extension,
2✔
334
           const Function& function,
335
           const data_flow::DataFlowGraph& data_flow_graph,
336
           const data_flow::LibraryNode& node) {
337
            return std::make_unique<math::blas::DotNodeDispatcher_BLAS>(
×
338
                language_extension, function, data_flow_graph, dynamic_cast<const math::blas::DotNode&>(node)
×
339
            );
340
        }
341
    );
342
    // Dot - CUBLAS
343
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
344
        math::blas::LibraryNodeType_DOT.value() + "::" + math::blas::ImplementationType_CUBLAS.value(),
2✔
345
        [](LanguageExtension& language_extension,
2✔
346
           const Function& function,
347
           const data_flow::DataFlowGraph& data_flow_graph,
348
           const data_flow::LibraryNode& node) {
349
            return std::make_unique<math::blas::DotNodeDispatcher_CUBLAS>(
×
350
                language_extension, function, data_flow_graph, dynamic_cast<const math::blas::DotNode&>(node)
×
351
            );
352
        }
353
    );
354

355
    // GEMM - BLAS
356
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
357
        math::blas::LibraryNodeType_GEMM.value() + "::" + math::blas::ImplementationType_BLAS.value(),
2✔
358
        [](LanguageExtension& language_extension,
2✔
359
           const Function& function,
360
           const data_flow::DataFlowGraph& data_flow_graph,
361
           const data_flow::LibraryNode& node) {
362
            return std::make_unique<math::blas::GEMMNodeDispatcher_BLAS>(
×
363
                language_extension, function, data_flow_graph, dynamic_cast<const math::blas::GEMMNode&>(node)
×
364
            );
365
        }
366
    );
367
    // GEMM - CUBLAS
368
    LibraryNodeDispatcherRegistry::instance().register_library_node_dispatcher(
4✔
369
        math::blas::LibraryNodeType_GEMM.value() + "::" + math::blas::ImplementationType_CUBLAS.value(),
2✔
370
        [](LanguageExtension& language_extension,
2✔
371
           const Function& function,
372
           const data_flow::DataFlowGraph& data_flow_graph,
373
           const data_flow::LibraryNode& node) {
374
            return std::make_unique<math::blas::GEMMNodeDispatcher_CUBLAS>(
×
375
                language_extension, function, data_flow_graph, dynamic_cast<const math::blas::GEMMNode&>(node)
×
376
            );
377
        }
378
    );
379
}
2✔
380

381
} // namespace codegen
382
} // 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