• 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

86.89
/src/passes/schedule/perfect_loop_distribution.cpp
1
#include "sdfg/passes/schedule/perfect_loop_distribution.h"
2

3
namespace sdfg {
4
namespace passes {
5

6
bool PerfectLoopDistribution::can_be_applied(Schedule& schedule,
274✔
7
                                             structured_control_flow::Sequence& parent,
8
                                             structured_control_flow::For& loop) {
9
    if (loop.root().size() == 1) {
274✔
10
        return false;
188✔
11
    }
12

13
    bool has_subloop = false;
86✔
14
    for (size_t i = 0; i < loop.root().size(); i++) {
206✔
15
        // skip blocks
16
        if (auto block = dynamic_cast<structured_control_flow::Block*>(&loop.root().at(i).first)) {
180✔
17
            continue;
120✔
18
        }
19
        if (auto subloop = dynamic_cast<structured_control_flow::For*>(&loop.root().at(i).first)) {
60✔
20
            has_subloop = true;
60✔
21
            break;
60✔
22
        }
23
        // if not a block or a loop, then we can't apply the transformation
24
        return false;
×
25
    }
26
    if (!has_subloop) {
86✔
27
        return false;
26✔
28
    }
29

30
    transformations::LoopDistribute loop_distribute(parent, loop);
60✔
31
    if (!loop_distribute.can_be_applied(schedule)) {
60✔
32
        return false;
14✔
33
    }
34

35
    return true;
46✔
36
};
274✔
37

38
void PerfectLoopDistribution::apply(Schedule& schedule, structured_control_flow::Sequence& parent,
46✔
39
                                    structured_control_flow::For& loop) {
40
    transformations::LoopDistribute loop_distribute(parent, loop);
46✔
41
    loop_distribute.apply(schedule);
46✔
42
};
46✔
43

44
PerfectLoopDistribution::PerfectLoopDistribution()
32✔
45
    : Pass(){
32✔
46

47
      };
32✔
48

49
std::string PerfectLoopDistribution::name() { return "PerfectLoopDistribution"; };
×
50

51
bool PerfectLoopDistribution::run_pass(Schedule& schedule) {
78✔
52
    bool applied = false;
78✔
53

54
    // Traverse structured SDFG
55
    auto& builder = schedule.builder();
78✔
56
    std::list<structured_control_flow::ControlFlowNode*> queue = {&builder.subject().root()};
78✔
57
    while (!queue.empty()) {
678✔
58
        auto current = queue.front();
646✔
59
        queue.pop_front();
646✔
60

61
        if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(current)) {
646✔
62
            for (size_t i = 0; i < sequence_stmt->size(); i++) {
678✔
63
                auto child = sequence_stmt->at(i);
446✔
64
                if (auto loop = dynamic_cast<structured_control_flow::For*>(&child.first)) {
446✔
65
                    if (this->can_be_applied(schedule, *sequence_stmt, *loop)) {
274✔
66
                        this->apply(schedule, *sequence_stmt, *loop);
46✔
67
                        applied = true;
46✔
68
                        break;
46✔
69
                    }
70
                }
228✔
71
            }
400✔
72
            if (applied) {
278✔
73
                break;
46✔
74
            }
75

76
            for (size_t i = 0; i < sequence_stmt->size(); i++) {
610✔
77
                queue.push_back(&sequence_stmt->at(i).first);
378✔
78
            }
378✔
79
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(current)) {
600✔
80
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
81
                queue.push_back(&if_else_stmt->at(i).first);
×
UNCOV
82
            }
×
83
        } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(current)) {
368✔
84
            queue.push_back(&loop_stmt->root());
×
85
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(current)) {
368✔
86
            queue.push_back(&for_stmt->root());
200✔
87
        } else if (auto kern_stmt = dynamic_cast<const structured_control_flow::Kernel*>(current)) {
368✔
88
            queue.push_back(&kern_stmt->root());
×
UNCOV
89
        }
×
90
    }
91

92
    return applied;
78✔
93
};
78✔
94

95
}  // namespace passes
96
}  // 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