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

daisytuner / docc / 21720639245

05 Feb 2026 04:56PM UTC coverage: 66.643% (+0.2%) from 66.484%
21720639245

Pull #502

github

web-flow
Merge 1a224a3d1 into cb356f32d
Pull Request #502: Scheduler streamlining

177 of 200 new or added lines in 23 files covered. (88.5%)

5 existing lines in 3 files now uncovered.

23219 of 34841 relevant lines covered (66.64%)

380.43 hits per line

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

83.16
/opt/src/passes/scheduler/loop_scheduling_pass.cpp
1
#include "sdfg/passes/scheduler/loop_scheduling_pass.h"
2
#include "sdfg/passes/offloading/data_transfer_minimization_pass.h"
3
#include "sdfg/passes/scheduler/loop_scheduler.h"
4
#include "sdfg/passes/scheduler/scheduler_registry.h"
5
#include "sdfg/structured_control_flow/map.h"
6

7
namespace sdfg {
8
namespace passes {
9
namespace scheduler {
10

11
bool LoopSchedulingPass::run_pass_target(
12
    builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager, const std::string& target
13
) {
13✔
14
    auto& loop_analysis = analysis_manager.get<analysis::LoopAnalysis>();
13✔
15
    auto& flop_analysis = analysis_manager.get<analysis::FlopAnalysis>();
13✔
16

17
    // Initialize queue with outermost loops
18
    std::list<structured_control_flow::ControlFlowNode*> queue;
13✔
19
    std::unordered_map<structured_control_flow::ControlFlowNode*, SchedulerLoopInfo> scheduling_info_map;
13✔
20
    for (auto& loop : loop_analysis.outermost_loops()) {
13✔
21
        queue.push_back(loop);
13✔
22

23
        SchedulerLoopInfo info;
13✔
24
        info.loop_info = loop_analysis.loop_info(loop);
13✔
25
        info.flop = flop_analysis.get(loop);
13✔
26
        scheduling_info_map[loop] = info;
13✔
27
    }
13✔
28
    if (queue.empty()) {
13✔
NEW
29
        return false;
×
NEW
30
    }
×
31

32

33
    auto scheduler = SchedulerRegistry::instance().get_loop_scheduler(target);
13✔
34
    if (!scheduler) {
13✔
NEW
35
        throw std::runtime_error("Unsupported scheduling target: " + target);
×
NEW
36
    }
×
37

38
    // filter by compatible types, ensure that a scheduler does not encounter maps with incompatible schedule types
39
    for (int i = 0; i < queue.size(); i++) {
26✔
40
        auto loop = queue.front();
13✔
41
        queue.pop_front();
13✔
42

43
        auto descendants = loop_analysis.descendants(loop);
13✔
44

45
        bool found_incompatible = false;
13✔
46
        for (auto descendant : descendants) {
22✔
47
            if (auto map_node = dynamic_cast<structured_control_flow::Map*>(descendant)) {
22✔
48
                auto compatible_schedules = scheduler->compatible_types();
19✔
49
                if (compatible_schedules.find(map_node->schedule_type().category()) == compatible_schedules.end()) {
19✔
NEW
50
                    found_incompatible = true;
×
NEW
51
                    break;
×
NEW
52
                }
×
53
            }
19✔
54
        }
22✔
55

56
        if (!found_incompatible) {
13✔
57
            queue.push_back(loop);
13✔
58
        }
13✔
59
    }
13✔
60

61
    // Scheduling state machine
62
    bool applied = false;
13✔
63
    while (!queue.empty()) {
42✔
64
        auto loop = queue.front();
29✔
65
        queue.pop_front();
29✔
66

67
        auto scheduling_info = scheduling_info_map.at(loop);
29✔
68
        scheduling_info_map.erase(loop);
29✔
69

70
        SchedulerAction action;
29✔
71
        if (auto while_loop = dynamic_cast<structured_control_flow::While*>(loop)) {
29✔
72
            action = scheduler->schedule(builder, analysis_manager, *while_loop);
4✔
73
        } else if (auto structured_loop = dynamic_cast<structured_control_flow::StructuredLoop*>(loop)) {
25✔
74
            action = scheduler->schedule(builder, analysis_manager, *structured_loop);
25✔
75
        } else {
25✔
NEW
76
            throw InvalidSDFGException("LoopScheduler encountered non-loop in loop analysis.");
×
NEW
77
        }
×
78

79
        auto& loop_analysis2 = analysis_manager.get<analysis::LoopAnalysis>();
29✔
80
        auto& flop_analysis2 = analysis_manager.get<analysis::FlopAnalysis>();
29✔
81

82
        switch (action) {
29✔
83
            case SchedulerAction::NEXT: {
19✔
84
                applied = true;
19✔
85
                break;
19✔
NEW
86
            }
×
87
            case SchedulerAction::CHILDREN: {
10✔
88
                auto children = loop_analysis2.children(loop);
10✔
89
                if (children.empty()) {
10✔
NEW
90
                    continue;
×
NEW
91
                }
×
92
                for (auto& child : children) {
16✔
93
                    queue.push_front(child);
16✔
94

95
                    SchedulerLoopInfo info;
16✔
96
                    info.loop_info = loop_analysis2.loop_info(child);
16✔
97
                    info.flop = flop_analysis2.get(child);
16✔
98
                    scheduling_info_map[child] = info;
16✔
99
                }
16✔
100
                break;
10✔
101
            }
10✔
102
        }
29✔
103
    }
29✔
104

105
    return applied;
13✔
106
}
13✔
107

108
bool LoopSchedulingPass::run_pass(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) {
13✔
109
    if (targets_.empty()) {
13✔
NEW
110
        return false;
×
NEW
111
    }
×
112
    if (targets_.size() == 1 && targets_[0] == "none") {
13✔
NEW
113
        return false;
×
NEW
114
    }
×
115

116
    bool applied = false;
13✔
117
    for (const auto& target : targets_) {
13✔
118
        bool target_applied = run_pass_target(builder, analysis_manager, target);
13✔
119
        applied = applied || target_applied;
13✔
120
        analysis_manager.invalidate_all();
13✔
121
    }
13✔
122

123
    if (applied) {
13✔
124
        DataTransferMinimizationPass dtm_pass;
13✔
125
        dtm_pass.run(builder, analysis_manager);
13✔
126
    }
13✔
127

128
    return applied;
13✔
129
}
13✔
130

131
} // namespace scheduler
132
} // namespace passes
133
} // 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