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

daisytuner / sdfglib / 15044057891

15 May 2025 11:42AM UTC coverage: 59.37% (+1.8%) from 57.525%
15044057891

push

github

web-flow
Merge pull request #14 from daisytuner/sanitizers

enables sanitizer on unit tests

63 of 67 new or added lines in 47 files covered. (94.03%)

570 existing lines in 62 files now uncovered.

7356 of 12390 relevant lines covered (59.37%)

505.93 hits per line

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

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

15
        if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&node)) {
67✔
16
            auto& block = this->builder_.add_block(root, block_stmt->dataflow(),
98✔
17
                                                   trans.assignments(), block_stmt->debug_info());
49✔
18
            this->node_mapping[block_stmt] = &block;
49✔
19
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&node)) {
67✔
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)) {
18✔
25
            auto& new_scope =
2✔
26
                this->builder_.add_if_else(root, trans.assignments(), if_else_stmt->debug_info());
2✔
27
            this->node_mapping[if_else_stmt] = &new_scope;
2✔
28
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
6✔
29
                auto branch = if_else_stmt->at(i);
4✔
30
                auto& new_branch =
4✔
31
                    this->builder_.add_case(new_scope, branch.second, branch.first.debug_info());
4✔
32
                this->node_mapping[&branch.first] = &new_branch;
4✔
33
                this->append(new_branch, branch.first);
4✔
34
            }
4✔
35
        } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&node)) {
14✔
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)) {
12✔
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)) {
9✔
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)) {
8✔
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)) {
7✔
53
            auto& new_scope = this->builder_.add_for(
12✔
54
                root, for_stmt->indvar(), for_stmt->condition(), for_stmt->init(),
6✔
55
                for_stmt->update(), trans.assignments(), for_stmt->debug_info());
6✔
56
            this->node_mapping[for_stmt] = &new_scope;
6✔
57
            this->append(new_scope.root(), for_stmt->root());
6✔
58
        } else if (auto kern_stmt = dynamic_cast<structured_control_flow::Kernel*>(&node)) {
6✔
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());
×
UNCOV
69
        } else {
×
70
            throw std::runtime_error("Deep copy not implemented");
×
71
        }
72
    }
67✔
73
};
72✔
74

75
void StructuredSDFGDeepCopy::insert(structured_control_flow::Sequence& root,
71✔
76
                                    structured_control_flow::ControlFlowNode& source) {
77
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&source)) {
71✔
78
        auto& block =
18✔
79
            this->builder_.add_block(root, block_stmt->dataflow(), {}, block_stmt->debug_info());
18✔
80
        this->node_mapping[block_stmt] = &block;
18✔
81
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&source)) {
71✔
82
        auto& new_seq = this->builder_.add_sequence(root, {}, sequence_stmt->debug_info());
25✔
83
        this->node_mapping[sequence_stmt] = &new_seq;
25✔
84
        this->append(new_seq, *sequence_stmt);
25✔
85
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&source)) {
53✔
86
        auto& new_scope = this->builder_.add_if_else(root);
×
87
        this->node_mapping[if_else_stmt] = &new_scope;
×
88
        for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
89
            auto branch = if_else_stmt->at(i);
×
UNCOV
90
            auto& new_branch =
×
91
                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);
×
UNCOV
94
        }
×
95
    } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&source)) {
28✔
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)) {
28✔
100
        auto& new_scope = this->builder_.add_for(root, for_stmt->indvar(), for_stmt->condition(),
28✔
101
                                                 for_stmt->init(), for_stmt->update(), {},
28✔
102
                                                 for_stmt->debug_info());
28✔
103
        this->node_mapping[for_stmt] = &new_scope;
28✔
104
        this->append(new_scope.root(), for_stmt->root());
28✔
105
    } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&source)) {
28✔
106
        auto& new_cont = this->builder_.add_continue(root, cont_stmt->debug_info());
×
107
        this->node_mapping[cont_stmt] = &new_cont;
×
108
    } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&source)) {
×
109
        auto& new_br = this->builder_.add_break(root, br_stmt->debug_info());
×
110
        this->node_mapping[br_stmt] = &new_br;
×
111
    } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&source)) {
×
112
        auto& new_ret = this->builder_.add_return(root, {}, ret_stmt->debug_info());
×
113
        this->node_mapping[ret_stmt] = &new_ret;
×
114
    } else if (auto kern_stmt = dynamic_cast<structured_control_flow::Kernel*>(&source)) {
×
115
        auto& new_scope = this->builder_.add_kernel(
×
116
            root, kern_stmt->suffix(), DebugInfo(), kern_stmt->gridDim_x_init(),
×
117
            kern_stmt->gridDim_y_init(), kern_stmt->gridDim_z_init(), kern_stmt->blockDim_x_init(),
×
118
            kern_stmt->blockDim_y_init(), kern_stmt->blockDim_z_init(),
×
119
            kern_stmt->blockIdx_x_init(), kern_stmt->blockIdx_y_init(),
×
120
            kern_stmt->blockIdx_z_init(), kern_stmt->threadIdx_x_init(),
×
121
            kern_stmt->threadIdx_y_init(), kern_stmt->threadIdx_z_init());
×
122
        this->node_mapping[kern_stmt] = &new_scope;
×
123
        this->append(new_scope.root(), kern_stmt->root());
×
UNCOV
124
    } else {
×
125
        throw std::runtime_error("Deep copy not implemented");
×
126
    }
127
};
71✔
128

129
StructuredSDFGDeepCopy::StructuredSDFGDeepCopy(builder::StructuredSDFGBuilder& builder,
146✔
130
                                               structured_control_flow::Sequence& root,
131
                                               structured_control_flow::ControlFlowNode& source)
132
    : builder_(builder), root_(root), source_(source) {};
146✔
133

134
std::unordered_map<const structured_control_flow::ControlFlowNode*,
135
                   const structured_control_flow::ControlFlowNode*>
136
StructuredSDFGDeepCopy::copy() {
71✔
137
    this->node_mapping.clear();
71✔
138
    this->insert(this->root_, this->source_);
71✔
139
    return this->node_mapping;
71✔
140
};
141

142
std::unordered_map<const structured_control_flow::ControlFlowNode*,
143
                   const structured_control_flow::ControlFlowNode*>
144
StructuredSDFGDeepCopy::insert() {
2✔
145
    if (auto seq_source = dynamic_cast<structured_control_flow::Sequence*>(&this->source_)) {
2✔
146
        this->node_mapping.clear();
2✔
147
        this->append(this->root_, *seq_source);
2✔
148
        return this->node_mapping;
2✔
149
    } else {
150
        throw std::runtime_error("Source node must be a sequence");
×
151
    }
UNCOV
152
};
×
153

154
}  // namespace deepcopy
155
}  // 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