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

daisytuner / sdfglib / 15340968114

30 May 2025 06:47AM UTC coverage: 58.553% (+0.2%) from 58.324%
15340968114

push

github

web-flow
Add parallel Map node

* Introduce Map data structure

* Prepare infrastructure

* implement analysis support

* Add basic infrastructure

* visualizer/serializer

* include fix

* update from main

* remove default

* happens before test + fixes

* builder test

* dispatcher test

* visitor, copy and serializer tests

* for2map structures

* for2map conversion draft

* add tests

* Bug fixes

* small updates from feedback

* Visitor style pass implementation

* cleanup

* fixes linting errors

---------

Co-authored-by: Lukas Truemper <lukas.truemper@outlook.de>

258 of 381 new or added lines in 26 files covered. (67.72%)

17 existing lines in 14 files now uncovered.

8184 of 13977 relevant lines covered (58.55%)

109.83 hits per line

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

55.8
/src/deepcopy/structured_sdfg_deep_copy.cpp
1
#include "sdfg/deepcopy/structured_sdfg_deep_copy.h"
2

3
#include "sdfg/element.h"
4

5
namespace sdfg {
6
namespace deepcopy {
7

8
void StructuredSDFGDeepCopy::append(structured_control_flow::Sequence& root,
37✔
9
                                    structured_control_flow::Sequence& source) {
10
    for (size_t i = 0; i < source.size(); i++) {
65✔
11
        auto child = source.at(i);
28✔
12
        auto& node = child.first;
28✔
13
        auto& trans = child.second;
28✔
14

15
        if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&node)) {
28✔
16
            auto& block = this->builder_.add_block(root, block_stmt->dataflow(),
26✔
17
                                                   trans.assignments(), block_stmt->debug_info());
13✔
18
            this->node_mapping[block_stmt] = &block;
13✔
19
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&node)) {
28✔
20
            auto& new_seq =
4✔
21
                this->builder_.add_sequence(root, trans.assignments(), sequence_stmt->debug_info());
4✔
22
            this->node_mapping[sequence_stmt] = &new_seq;
4✔
23
            this->append(new_seq, *sequence_stmt);
4✔
24
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&node)) {
15✔
25
            auto& new_scope =
1✔
26
                this->builder_.add_if_else(root, trans.assignments(), if_else_stmt->debug_info());
1✔
27
            this->node_mapping[if_else_stmt] = &new_scope;
1✔
28
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
3✔
29
                auto branch = if_else_stmt->at(i);
2✔
30
                auto& new_branch =
2✔
31
                    this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
2✔
32
                this->node_mapping[&branch.first] = &new_branch;
2✔
33
                this->append(new_branch, branch.first);
2✔
34
            }
2✔
35
        } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&node)) {
11✔
36
            auto& new_scope =
3✔
37
                this->builder_.add_while(root, trans.assignments(), loop_stmt->debug_info());
3✔
38
            this->node_mapping[loop_stmt] = &new_scope;
3✔
39
            this->append(new_scope.root(), loop_stmt->root());
3✔
40
        } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&node)) {
10✔
41
            auto& new_cont =
1✔
42
                this->builder_.add_continue(root, trans.assignments(), cont_stmt->debug_info());
1✔
43
            this->node_mapping[cont_stmt] = &new_cont;
1✔
44
        } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&node)) {
7✔
45
            auto& new_br =
1✔
46
                this->builder_.add_break(root, trans.assignments(), br_stmt->debug_info());
1✔
47
            this->node_mapping[br_stmt] = &new_br;
1✔
48
        } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&node)) {
6✔
49
            auto& new_ret =
1✔
50
                this->builder_.add_return(root, trans.assignments(), ret_stmt->debug_info());
1✔
51
            this->node_mapping[ret_stmt] = &new_ret;
1✔
52
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&node)) {
5✔
53
            auto& new_scope = this->builder_.add_for(
6✔
54
                root, for_stmt->indvar(), for_stmt->condition(), for_stmt->init(),
3✔
55
                for_stmt->update(), trans.assignments(), for_stmt->debug_info());
3✔
56
            this->node_mapping[for_stmt] = &new_scope;
3✔
57
            this->append(new_scope.root(), for_stmt->root());
3✔
58
        } else if (auto kern_stmt = dynamic_cast<structured_control_flow::Kernel*>(&node)) {
4✔
59
            auto& new_scope = this->builder_.add_kernel(
×
60
                root, kern_stmt->suffix(), DebugInfo(), kern_stmt->gridDim_x_init(),
×
61
                kern_stmt->gridDim_y_init(), kern_stmt->gridDim_z_init(),
×
62
                kern_stmt->blockDim_x_init(), kern_stmt->blockDim_y_init(),
×
63
                kern_stmt->blockDim_z_init(), kern_stmt->blockIdx_x_init(),
×
64
                kern_stmt->blockIdx_y_init(), kern_stmt->blockIdx_z_init(),
×
65
                kern_stmt->threadIdx_x_init(), kern_stmt->threadIdx_y_init(),
×
66
                kern_stmt->threadIdx_z_init());
×
67
            this->node_mapping[kern_stmt] = &new_scope;
×
68
            this->append(new_scope.root(), kern_stmt->root());
×
69
        } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&node)) {
1✔
70
            auto& new_scope =
1✔
71
                this->builder_.add_map(root, map_stmt->indvar(), map_stmt->num_iterations(),
2✔
72
                                       trans.assignments(), map_stmt->debug_info());
1✔
73
            this->node_mapping[map_stmt] = &new_scope;
1✔
74
            this->append(new_scope.root(), map_stmt->root());
1✔
75
        } else {
1✔
76
            throw std::runtime_error("Deep copy not implemented");
×
77
        }
78
    }
28✔
79
};
37✔
80

81
void StructuredSDFGDeepCopy::insert(structured_control_flow::Sequence& root,
22✔
82
                                    structured_control_flow::ControlFlowNode& source) {
83
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&source)) {
22✔
84
        auto& block =
×
85
            this->builder_.add_block(root, block_stmt->dataflow(), {}, block_stmt->debug_info());
×
86
        this->node_mapping[block_stmt] = &block;
×
87
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&source)) {
22✔
88
        auto& new_seq = this->builder_.add_sequence(root, {}, sequence_stmt->debug_info());
22✔
89
        this->node_mapping[sequence_stmt] = &new_seq;
22✔
90
        this->append(new_seq, *sequence_stmt);
22✔
91
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&source)) {
22✔
92
        auto& new_scope = this->builder_.add_if_else(root);
×
93
        this->node_mapping[if_else_stmt] = &new_scope;
×
94
        for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
95
            auto branch = if_else_stmt->at(i);
×
96
            auto& new_branch =
×
97
                this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
×
98
            this->node_mapping[&branch.first] = &new_branch;
×
99
            this->append(new_branch, branch.first);
×
100
        }
×
101
    } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&source)) {
×
102
        auto& new_scope = this->builder_.add_while(root, {}, loop_stmt->debug_info());
×
103
        this->node_mapping[loop_stmt] = &new_scope;
×
104
        this->append(new_scope.root(), loop_stmt->root());
×
105
    } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&source)) {
×
106
        auto& new_scope = this->builder_.add_for(root, for_stmt->indvar(), for_stmt->condition(),
×
107
                                                 for_stmt->init(), for_stmt->update(), {},
×
108
                                                 for_stmt->debug_info());
×
109
        this->node_mapping[for_stmt] = &new_scope;
×
110
        this->append(new_scope.root(), for_stmt->root());
×
111
    } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&source)) {
×
112
        auto& new_cont = this->builder_.add_continue(root, cont_stmt->debug_info());
×
113
        this->node_mapping[cont_stmt] = &new_cont;
×
114
    } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&source)) {
×
115
        auto& new_br = this->builder_.add_break(root, br_stmt->debug_info());
×
116
        this->node_mapping[br_stmt] = &new_br;
×
117
    } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&source)) {
×
118
        auto& new_ret = this->builder_.add_return(root, {}, ret_stmt->debug_info());
×
119
        this->node_mapping[ret_stmt] = &new_ret;
×
120
    } else if (auto kern_stmt = dynamic_cast<structured_control_flow::Kernel*>(&source)) {
×
121
        auto& new_scope = this->builder_.add_kernel(
×
122
            root, kern_stmt->suffix(), DebugInfo(), kern_stmt->gridDim_x_init(),
×
123
            kern_stmt->gridDim_y_init(), kern_stmt->gridDim_z_init(), kern_stmt->blockDim_x_init(),
×
124
            kern_stmt->blockDim_y_init(), kern_stmt->blockDim_z_init(),
×
125
            kern_stmt->blockIdx_x_init(), kern_stmt->blockIdx_y_init(),
×
126
            kern_stmt->blockIdx_z_init(), kern_stmt->threadIdx_x_init(),
×
127
            kern_stmt->threadIdx_y_init(), kern_stmt->threadIdx_z_init());
×
128
        this->node_mapping[kern_stmt] = &new_scope;
×
129
        this->append(new_scope.root(), kern_stmt->root());
×
NEW
130
    } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&source)) {
×
NEW
131
        auto& new_scope = this->builder_.add_map(
×
NEW
132
            root, map_stmt->indvar(), map_stmt->num_iterations(), {}, map_stmt->debug_info());
×
NEW
133
        this->node_mapping[map_stmt] = &new_scope;
×
NEW
134
        this->append(new_scope.root(), map_stmt->root());
×
135
    } else {
×
136
        throw std::runtime_error("Deep copy not implemented");
×
137
    }
138
};
22✔
139

140
StructuredSDFGDeepCopy::StructuredSDFGDeepCopy(builder::StructuredSDFGBuilder& builder,
48✔
141
                                               structured_control_flow::Sequence& root,
142
                                               structured_control_flow::ControlFlowNode& source)
143
    : builder_(builder), root_(root), source_(source) {};
48✔
144

145
std::unordered_map<const structured_control_flow::ControlFlowNode*,
146
                   const structured_control_flow::ControlFlowNode*>
147
StructuredSDFGDeepCopy::copy() {
22✔
148
    this->node_mapping.clear();
22✔
149
    this->insert(this->root_, this->source_);
22✔
150
    return this->node_mapping;
22✔
151
};
152

153
std::unordered_map<const structured_control_flow::ControlFlowNode*,
154
                   const structured_control_flow::ControlFlowNode*>
155
StructuredSDFGDeepCopy::insert() {
2✔
156
    if (auto seq_source = dynamic_cast<structured_control_flow::Sequence*>(&this->source_)) {
2✔
157
        this->node_mapping.clear();
2✔
158
        this->append(this->root_, *seq_source);
2✔
159
        return this->node_mapping;
2✔
160
    } else {
161
        throw std::runtime_error("Source node must be a sequence");
×
162
    }
163
};
×
164

165
}  // namespace deepcopy
166
}  // 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

© 2025 Coveralls, Inc