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

daisytuner / sdfglib / 15142284085

20 May 2025 03:58PM UTC coverage: 60.528% (-0.02%) from 60.543%
15142284085

push

github

web-flow
Merge pull request #23 from daisytuner/loops

LoopTrees and Instrumentation Strategies

80 of 182 new or added lines in 17 files covered. (43.96%)

11 existing lines in 6 files now uncovered.

7928 of 13098 relevant lines covered (60.53%)

104.16 hits per line

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

77.78
/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
Schedule::Schedule(std::unique_ptr<StructuredSDFG>& sdfg)
54✔
9
    : assumptions_(),
27✔
10
      builder_(sdfg),
27✔
11
      analysis_manager_(builder_.subject(), assumptions_){
27✔
12

13
      };
27✔
14

15
Schedule::Schedule(std::unique_ptr<StructuredSDFG>& sdfg, const symbolic::Assumptions& assumptions)
430✔
16
    : assumptions_(assumptions),
215✔
17
      builder_(sdfg),
215✔
18
      analysis_manager_(builder_.subject(), assumptions_){
215✔
19

20
      };
215✔
21

22
symbolic::Assumptions& Schedule::assumptions() { return this->assumptions_; };
188✔
23

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

26
builder::StructuredSDFGBuilder& Schedule::builder() { return this->builder_; };
237✔
27

28
const StructuredSDFG& Schedule::sdfg() const { return this->builder_.subject(); };
1,405✔
29

30
analysis::AnalysisManager& Schedule::analysis_manager() { return this->analysis_manager_; };
52✔
31

32
LoopSchedule Schedule::loop_schedule(
9✔
33
    const structured_control_flow::ControlFlowNode* loop) const {
34
    if (this->loop_schedules_.find(loop) == this->loop_schedules_.end()) {
9✔
35
        return LoopSchedule::SEQUENTIAL;
9✔
36
    }
37
    return this->loop_schedules_.at(loop);
×
38
};
9✔
39

UNCOV
40
void Schedule::loop_schedule(const structured_control_flow::ControlFlowNode* loop,
×
41
                             const LoopSchedule schedule) {
UNCOV
42
    if (schedule == LoopSchedule::SEQUENTIAL) {
×
UNCOV
43
        if (this->loop_schedules_.find(loop) == this->loop_schedules_.end()) {
×
UNCOV
44
            return;
×
45
        }
46
        this->loop_schedules_.erase(loop);
×
47
        return;
×
48
    }
49
    this->loop_schedules_.insert_or_assign(loop, schedule);
×
UNCOV
50
};
×
51

52
/***** Allocation Management *****/
53

54
const structured_control_flow::ControlFlowNode* Schedule::allocation_lifetime(
15✔
55
    const std::string& container) const {
56
    if (this->allocation_lifetimes_.find(container) == this->allocation_lifetimes_.end()) {
15✔
57
        return &this->sdfg().root();
9✔
58
    }
59
    return this->allocation_lifetimes_.at(container);
6✔
60
};
15✔
61

62
void Schedule::allocation_lifetime(const std::string& container,
6✔
63
                                   const structured_control_flow::ControlFlowNode* node) {
64
    this->allocation_lifetimes_.insert_or_assign(container, node);
6✔
65
};
6✔
66

67
AllocationType Schedule::allocation_type(const std::string& container) const {
9✔
68
    if (this->allocation_types_.find(container) == this->allocation_types_.end()) {
9✔
69
        return AllocationType::DECLARE;
3✔
70
    }
71
    return this->allocation_types_.at(container);
6✔
72
};
9✔
73

74
void Schedule::allocation_type(const std::string& container, AllocationType allocation_type) {
6✔
75
    if (allocation_type == AllocationType::DECLARE) {
6✔
76
        if (this->allocation_types_.find(container) != this->allocation_types_.end()) {
1✔
77
            this->allocation_types_.erase(container);
×
78
        }
×
79
        return;
1✔
80
    }
81
    this->allocation_types_.insert_or_assign(container, allocation_type);
5✔
82
};
6✔
83

84
std::unordered_set<std::string> Schedule::node_allocations(
3✔
85
    const structured_control_flow::ControlFlowNode* node) const {
86
    std::unordered_set<std::string> allocated;
3✔
87
    if (node == &this->sdfg().root()) {
3✔
88
        for (auto& container : this->sdfg().containers()) {
5✔
89
            if (!this->sdfg().is_transient(container)) {
4✔
90
                continue;
2✔
91
            }
92
            if (this->allocation_lifetimes_.find(container) == this->allocation_lifetimes_.end()) {
2✔
93
                allocated.insert(container);
×
94
            }
×
95
        }
96
    } else {
1✔
97
        for (auto& [container, lifetime] : this->allocation_lifetimes_) {
6✔
98
            if (lifetime == node) {
4✔
99
                allocated.insert(container);
4✔
100
            }
4✔
101
        }
102
    }
103
    return allocated;
3✔
104
};
3✔
105

106
std::unordered_set<std::string> Schedule::allocations(
2✔
107
    const structured_control_flow::ControlFlowNode* node) const {
108
    std::unordered_set<std::string> allocated;
2✔
109

110
    std::list<const structured_control_flow::ControlFlowNode*> queue = {node};
2✔
111
    while (!queue.empty()) {
5✔
112
        auto current = queue.front();
3✔
113
        queue.pop_front();
3✔
114

115
        auto node_allocations = this->node_allocations(current);
3✔
116
        allocated.insert(node_allocations.begin(), node_allocations.end());
3✔
117

118
        if (auto sequence_stmt = dynamic_cast<const structured_control_flow::Sequence*>(current)) {
3✔
119
            for (size_t i = 0; i < sequence_stmt->size(); i++) {
2✔
120
                queue.push_front(&sequence_stmt->at(i).first);
1✔
121
            }
1✔
122
        } else if (auto if_else_stmt =
3✔
123
                       dynamic_cast<const structured_control_flow::IfElse*>(current)) {
2✔
124
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
125
                queue.push_front(&if_else_stmt->at(i).first);
×
126
            }
×
127
        } else if (auto while_stmt = dynamic_cast<const structured_control_flow::While*>(current)) {
2✔
128
            queue.push_front(&while_stmt->root());
×
129
        } else if (auto for_stmt = dynamic_cast<const structured_control_flow::For*>(current)) {
2✔
130
            queue.push_front(&for_stmt->root());
×
131
        }
×
132
    }
3✔
133

134
    return allocated;
2✔
135
};
2✔
136

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