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

daisytuner / sdfglib / 15827874660

23 Jun 2025 03:03PM UTC coverage: 64.193% (+0.4%) from 63.824%
15827874660

push

github

web-flow
Merge pull request #100 from daisytuner/transformations

new definition of map and adapts transformations

148 of 194 new or added lines in 13 files covered. (76.29%)

45 existing lines in 4 files now uncovered.

8193 of 12763 relevant lines covered (64.19%)

136.04 hits per line

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

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

15
        if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&node)) {
54✔
16
            auto& block = this->builder_.add_block(root, block_stmt->dataflow(),
40✔
17
                                                   trans.assignments(), block_stmt->debug_info());
20✔
18
            this->node_mapping[block_stmt] = &block;
20✔
19
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&node)) {
54✔
20
            auto& new_seq =
10✔
21
                this->builder_.add_sequence(root, trans.assignments(), sequence_stmt->debug_info());
10✔
22
            this->node_mapping[sequence_stmt] = &new_seq;
10✔
23
            this->append(new_seq, *sequence_stmt);
10✔
24
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&node)) {
34✔
25
            auto& new_scope =
4✔
26
                this->builder_.add_if_else(root, trans.assignments(), if_else_stmt->debug_info());
4✔
27
            this->node_mapping[if_else_stmt] = &new_scope;
4✔
28
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
12✔
29
                auto branch = if_else_stmt->at(i);
8✔
30
                auto& new_branch =
8✔
31
                    this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
8✔
32
                this->node_mapping[&branch.first] = &new_branch;
8✔
33
                this->append(new_branch, branch.first);
8✔
34
            }
8✔
35
        } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&node)) {
24✔
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)) {
20✔
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)) {
17✔
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)) {
16✔
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)) {
15✔
53
            auto& new_scope = this->builder_.add_for(
10✔
54
                root, for_stmt->indvar(), for_stmt->condition(), for_stmt->init(),
5✔
55
                for_stmt->update(), trans.assignments(), for_stmt->debug_info());
5✔
56
            this->node_mapping[for_stmt] = &new_scope;
5✔
57
            this->append(new_scope.root(), for_stmt->root());
5✔
58
        } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&node)) {
14✔
59
            auto& new_scope = this->builder_.add_map(root, map_stmt->indvar(),
18✔
60
                                                     map_stmt->condition(), map_stmt->init(),
9✔
61
                                                     map_stmt->update(), map_stmt->schedule_type(),
9✔
62
                                                     trans.assignments(), map_stmt->debug_info());
9✔
63
            this->node_mapping[map_stmt] = &new_scope;
9✔
64
            this->append(new_scope.root(), map_stmt->root());
9✔
65
        } else {
9✔
66
            throw std::runtime_error("Deep copy not implemented");
×
67
        }
68
    }
54✔
69
};
75✔
70

71
void StructuredSDFGDeepCopy::insert(structured_control_flow::Sequence& root,
39✔
72
                                    structured_control_flow::ControlFlowNode& source) {
73
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&source)) {
39✔
74
        auto& block =
×
75
            this->builder_.add_block(root, block_stmt->dataflow(), {}, block_stmt->debug_info());
×
76
        this->node_mapping[block_stmt] = &block;
×
77
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&source)) {
39✔
78
        auto& new_seq = this->builder_.add_sequence(root, {}, sequence_stmt->debug_info());
39✔
79
        this->node_mapping[sequence_stmt] = &new_seq;
39✔
80
        this->append(new_seq, *sequence_stmt);
39✔
81
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&source)) {
39✔
82
        auto& new_scope = this->builder_.add_if_else(root);
×
83
        this->node_mapping[if_else_stmt] = &new_scope;
×
84
        for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
85
            auto branch = if_else_stmt->at(i);
×
86
            auto& new_branch =
×
87
                this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
×
88
            this->node_mapping[&branch.first] = &new_branch;
×
89
            this->append(new_branch, branch.first);
×
90
        }
×
91
    } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&source)) {
×
92
        auto& new_scope = this->builder_.add_while(root, {}, loop_stmt->debug_info());
×
93
        this->node_mapping[loop_stmt] = &new_scope;
×
94
        this->append(new_scope.root(), loop_stmt->root());
×
95
    } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&source)) {
×
96
        auto& new_scope = this->builder_.add_for(root, for_stmt->indvar(), for_stmt->condition(),
×
97
                                                 for_stmt->init(), for_stmt->update(), {},
×
98
                                                 for_stmt->debug_info());
×
99
        this->node_mapping[for_stmt] = &new_scope;
×
100
        this->append(new_scope.root(), for_stmt->root());
×
101
    } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&source)) {
×
102
        auto& new_cont = this->builder_.add_continue(root, cont_stmt->debug_info());
×
103
        this->node_mapping[cont_stmt] = &new_cont;
×
104
    } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&source)) {
×
105
        auto& new_br = this->builder_.add_break(root, br_stmt->debug_info());
×
106
        this->node_mapping[br_stmt] = &new_br;
×
107
    } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&source)) {
×
108
        auto& new_ret = this->builder_.add_return(root, {}, ret_stmt->debug_info());
×
109
        this->node_mapping[ret_stmt] = &new_ret;
×
110
    } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&source)) {
×
NEW
111
        auto& new_scope = this->builder_.add_map(
×
NEW
112
            root, map_stmt->indvar(), map_stmt->condition(), map_stmt->init(), map_stmt->update(),
×
NEW
113
            map_stmt->schedule_type(), {}, map_stmt->debug_info());
×
114
        this->node_mapping[map_stmt] = &new_scope;
×
115
        this->append(new_scope.root(), map_stmt->root());
×
116
    } else {
×
117
        throw std::runtime_error("Deep copy not implemented");
×
118
    }
119
};
39✔
120

121
StructuredSDFGDeepCopy::StructuredSDFGDeepCopy(builder::StructuredSDFGBuilder& builder,
80✔
122
                                               structured_control_flow::Sequence& root,
123
                                               structured_control_flow::ControlFlowNode& source)
124
    : builder_(builder), root_(root), source_(source) {};
80✔
125

126
std::unordered_map<const structured_control_flow::ControlFlowNode*,
127
                   const structured_control_flow::ControlFlowNode*>
128
StructuredSDFGDeepCopy::copy() {
39✔
129
    this->node_mapping.clear();
39✔
130
    this->insert(this->root_, this->source_);
39✔
131
    return this->node_mapping;
39✔
132
};
133

134
std::unordered_map<const structured_control_flow::ControlFlowNode*,
135
                   const structured_control_flow::ControlFlowNode*>
136
StructuredSDFGDeepCopy::insert() {
1✔
137
    if (auto seq_source = dynamic_cast<structured_control_flow::Sequence*>(&this->source_)) {
1✔
138
        this->node_mapping.clear();
1✔
139
        this->append(this->root_, *seq_source);
1✔
140
        return this->node_mapping;
1✔
141
    } else {
142
        throw std::runtime_error("Source node must be a sequence");
×
143
    }
144
};
×
145

146
}  // namespace deepcopy
147
}  // 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