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

daisytuner / sdfglib / 15612270835

12 Jun 2025 01:44PM UTC coverage: 60.871% (-0.8%) from 61.71%
15612270835

push

github

web-flow
Merge pull request #68 from daisytuner/loop-types

refactors symbolic analysis into polynomials, extreme values and cnf

638 of 862 new or added lines in 24 files covered. (74.01%)

334 existing lines in 20 files now uncovered.

6571 of 10795 relevant lines covered (60.87%)

100.35 hits per line

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

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

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

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

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

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

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

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