• 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

81.15
/src/schedule.cpp
1
#include "sdfg/schedule.h"
2

3
#include "sdfg/builder/structured_sdfg_builder.h"
4
#include "sdfg/deepcopy/structured_sdfg_deep_copy.h"
5

6
namespace sdfg {
7

8
void Schedule::loop_tree(
163✔
9
    structured_control_flow::ControlFlowNode& root,
10
    structured_control_flow::ControlFlowNode* parent,
11
    std::unordered_map<structured_control_flow::ControlFlowNode*,
12
                       structured_control_flow::ControlFlowNode*>& tree) const {
13
    std::list<structured_control_flow::ControlFlowNode*> queue = {&root};
163✔
14
    while (!queue.empty()) {
580✔
15
        auto current = queue.front();
417✔
16
        queue.pop_front();
417✔
17
        if (auto for_loop = dynamic_cast<structured_control_flow::For*>(current)) {
417✔
18
            tree[for_loop] = parent;
138✔
19
        } else if (auto while_loop = dynamic_cast<structured_control_flow::While*>(current)) {
417✔
20
            tree[while_loop] = parent;
×
UNCOV
21
        }
×
22

23
        if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(current)) {
417✔
24
            for (size_t i = 0; i < sequence_stmt->size(); i++) {
417✔
25
                queue.push_back(&sequence_stmt->at(i).first);
254✔
26
            }
254✔
27
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(current)) {
417✔
28
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
29
                queue.push_back(&if_else_stmt->at(i).first);
×
UNCOV
30
            }
×
31
        } else if (auto while_stmt = dynamic_cast<structured_control_flow::While*>(current)) {
254✔
32
            this->loop_tree(while_stmt->root(), while_stmt, tree);
×
33
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(current)) {
254✔
34
            this->loop_tree(for_stmt->root(), for_stmt, tree);
138✔
35
        } else if (auto kern_stmt = dynamic_cast<structured_control_flow::Kernel*>(current)) {
254✔
36
            queue.push_back(&kern_stmt->root());
×
UNCOV
37
        }
×
38
    }
39
};
163✔
40

41
Schedule::Schedule(std::unique_ptr<StructuredSDFG>& sdfg)
118✔
42
    : assumptions_(),
59✔
43
      builder_(sdfg),
59✔
44
      analysis_manager_(builder_.subject(), assumptions_){
59✔
45

46
      };
59✔
47

48
Schedule::Schedule(std::unique_ptr<StructuredSDFG>& sdfg, const symbolic::Assumptions& assumptions)
90✔
49
    : assumptions_(assumptions),
45✔
50
      builder_(sdfg),
45✔
51
      analysis_manager_(builder_.subject(), assumptions_){
45✔
52

53
      };
45✔
54

55
symbolic::Assumptions& Schedule::assumptions() { return this->assumptions_; };
17✔
56

57
const symbolic::Assumptions& Schedule::assumptions() const { return this->assumptions_; };
×
58

59
builder::StructuredSDFGBuilder& Schedule::builder() { return this->builder_; };
501✔
60

61
const StructuredSDFG& Schedule::sdfg() const { return this->builder_.subject(); };
130✔
62

63
analysis::AnalysisManager& Schedule::analysis_manager() { return this->analysis_manager_; };
381✔
64

65
const LoopSchedule Schedule::loop_schedule(
1✔
66
    const structured_control_flow::ControlFlowNode* loop) const {
67
    if (this->loop_schedules_.find(loop) == this->loop_schedules_.end()) {
1✔
68
        return LoopSchedule::SEQUENTIAL;
1✔
69
    }
70
    return this->loop_schedules_.at(loop);
×
71
};
1✔
72

73
void Schedule::loop_schedule(const structured_control_flow::ControlFlowNode* loop,
1✔
74
                             const LoopSchedule schedule) {
75
    if (schedule == LoopSchedule::SEQUENTIAL) {
1✔
76
        if (this->loop_schedules_.find(loop) == this->loop_schedules_.end()) {
1✔
77
            return;
1✔
78
        }
79
        this->loop_schedules_.erase(loop);
×
80
        return;
×
81
    }
82
    this->loop_schedules_.insert_or_assign(loop, schedule);
×
83
};
1✔
84

85
std::unordered_map<structured_control_flow::ControlFlowNode*,
86
                   structured_control_flow::ControlFlowNode*>
87
Schedule::loop_tree() const {
25✔
88
    std::unordered_map<structured_control_flow::ControlFlowNode*,
25✔
89
                       structured_control_flow::ControlFlowNode*>
90
        loop_tree_;
25✔
91
    this->loop_tree(this->builder_.subject().root(), nullptr, loop_tree_);
25✔
92
    return loop_tree_;
25✔
93
};
25✔
94

95
/***** Allocation Management *****/
96

97
const structured_control_flow::ControlFlowNode* Schedule::allocation_lifetime(
17✔
98
    const std::string& container) const {
99
    if (this->allocation_lifetimes_.find(container) == this->allocation_lifetimes_.end()) {
17✔
100
        return &this->sdfg().root();
11✔
101
    }
102
    return this->allocation_lifetimes_.at(container);
6✔
103
};
17✔
104

105
void Schedule::allocation_lifetime(const std::string& container,
6✔
106
                                   const structured_control_flow::ControlFlowNode* node) {
107
    this->allocation_lifetimes_.insert_or_assign(container, node);
6✔
108
};
6✔
109

110
AllocationType Schedule::allocation_type(const std::string& container) const {
9✔
111
    if (this->allocation_types_.find(container) == this->allocation_types_.end()) {
9✔
112
        return AllocationType::DECLARE;
3✔
113
    }
114
    return this->allocation_types_.at(container);
6✔
115
};
9✔
116

117
void Schedule::allocation_type(const std::string& container, AllocationType allocation_type) {
6✔
118
    if (allocation_type == AllocationType::DECLARE) {
6✔
119
        if (this->allocation_types_.find(container) != this->allocation_types_.end()) {
1✔
120
            this->allocation_types_.erase(container);
×
UNCOV
121
        }
×
122
        return;
1✔
123
    }
124
    this->allocation_types_.insert_or_assign(container, allocation_type);
5✔
125
};
6✔
126

127
std::unordered_set<std::string> Schedule::node_allocations(
3✔
128
    const structured_control_flow::ControlFlowNode* node) const {
129
    std::unordered_set<std::string> allocated;
3✔
130
    if (node == &this->sdfg().root()) {
3✔
131
        for (auto& container : this->sdfg().containers()) {
5✔
132
            if (!this->sdfg().is_transient(container)) {
4✔
133
                continue;
2✔
134
            }
135
            if (this->allocation_lifetimes_.find(container) == this->allocation_lifetimes_.end()) {
2✔
136
                allocated.insert(container);
×
UNCOV
137
            }
×
138
        }
139
    } else {
1✔
140
        for (auto& [container, lifetime] : this->allocation_lifetimes_) {
6✔
141
            if (lifetime == node) {
4✔
142
                allocated.insert(container);
4✔
143
            }
4✔
144
        }
145
    }
146
    return allocated;
3✔
147
};
3✔
148

149
std::unordered_set<std::string> Schedule::allocations(
2✔
150
    const structured_control_flow::ControlFlowNode* node) const {
151
    std::unordered_set<std::string> allocated;
2✔
152

153
    std::list<const structured_control_flow::ControlFlowNode*> queue = {node};
2✔
154
    while (!queue.empty()) {
5✔
155
        auto current = queue.front();
3✔
156
        queue.pop_front();
3✔
157

158
        auto node_allocations = this->node_allocations(current);
3✔
159
        allocated.insert(node_allocations.begin(), node_allocations.end());
3✔
160

161
        if (auto sequence_stmt = dynamic_cast<const structured_control_flow::Sequence*>(current)) {
3✔
162
            for (size_t i = 0; i < sequence_stmt->size(); i++) {
2✔
163
                queue.push_front(&sequence_stmt->at(i).first);
1✔
164
            }
1✔
165
        } else if (auto if_else_stmt =
3✔
166
                       dynamic_cast<const structured_control_flow::IfElse*>(current)) {
2✔
167
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
168
                queue.push_front(&if_else_stmt->at(i).first);
×
UNCOV
169
            }
×
170
        } else if (auto while_stmt = dynamic_cast<const structured_control_flow::While*>(current)) {
2✔
171
            queue.push_front(&while_stmt->root());
×
172
        } else if (auto for_stmt = dynamic_cast<const structured_control_flow::For*>(current)) {
2✔
173
            queue.push_front(&for_stmt->root());
×
UNCOV
174
        }
×
175
    }
3✔
176

177
    return allocated;
2✔
178
};
2✔
179

180
}  // 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