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

daisytuner / sdfglib / 17656823807

11 Sep 2025 08:42PM UTC coverage: 60.447% (+1.1%) from 59.335%
17656823807

Pull #219

github

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

460 of 1635 new or added lines in 81 files covered. (28.13%)

93 existing lines in 35 files now uncovered.

9385 of 15526 relevant lines covered (60.45%)

107.21 hits per line

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

51.13
/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, structured_control_flow::Sequence& source) {
18✔
9
    for (size_t i = 0; i < source.size(); i++) {
31✔
10
        auto child = source.at(i);
13✔
11
        auto& node = child.first;
13✔
12
        auto& trans = child.second;
13✔
13

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

77
void StructuredSDFGDeepCopy::
78
    insert(structured_control_flow::Sequence& root, structured_control_flow::ControlFlowNode& source) {
11✔
79
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&source)) {
11✔
80
        auto& block = this->builder_.add_block(root, block_stmt->dataflow(), {}, block_stmt->debug_info());
×
81
        this->node_mapping[block_stmt] = &block;
×
82
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&source)) {
11✔
83
        auto& new_seq = this->builder_.add_sequence(root, {}, sequence_stmt->debug_info());
11✔
84
        this->node_mapping[sequence_stmt] = &new_seq;
11✔
85
        this->append(new_seq, *sequence_stmt);
11✔
86
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&source)) {
11✔
87
        auto& new_scope = this->builder_.add_if_else(root);
×
88
        this->node_mapping[if_else_stmt] = &new_scope;
×
89
        for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
90
            auto branch = if_else_stmt->at(i);
×
91
            auto& new_branch = this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
×
92
            this->node_mapping[&branch.first] = &new_branch;
×
93
            this->append(new_branch, branch.first);
×
94
        }
×
95
    } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&source)) {
×
96
        auto& new_scope = this->builder_.add_while(root, {}, loop_stmt->debug_info());
×
97
        this->node_mapping[loop_stmt] = &new_scope;
×
98
        this->append(new_scope.root(), loop_stmt->root());
×
99
    } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&source)) {
×
100
        auto& new_scope = this->builder_.add_for(
×
101
            root,
×
102
            for_stmt->indvar(),
×
103
            for_stmt->condition(),
×
104
            for_stmt->init(),
×
105
            for_stmt->update(),
×
106
            {},
×
107
            for_stmt->debug_info()
×
108
        );
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)) {
×
NEW
118
        auto& new_ret =
×
NEW
119
            this->builder_.add_return(root, ret_stmt->data(), ret_stmt->unreachable(), {}, ret_stmt->debug_info());
×
120
        this->node_mapping[ret_stmt] = &new_ret;
×
121
    } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&source)) {
×
122
        auto& new_scope = this->builder_.add_map(
×
123
            root,
×
124
            map_stmt->indvar(),
×
125
            map_stmt->condition(),
×
126
            map_stmt->init(),
×
127
            map_stmt->update(),
×
128
            map_stmt->schedule_type(),
×
129
            {},
×
130
            map_stmt->debug_info()
×
131
        );
132
        this->node_mapping[map_stmt] = &new_scope;
×
133
        this->append(new_scope.root(), map_stmt->root());
×
134
    } else {
×
135
        throw std::runtime_error("Deep copy not implemented");
×
136
    }
137
};
11✔
138

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

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

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

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