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

daisytuner / docc / 27624328215

16 Jun 2026 02:20PM UTC coverage: 61.531% (+0.007%) from 61.524%
27624328215

Pull #768

github

web-flow
Merge 31310125d into eed4217da
Pull Request #768: Fix cuda rpc

3 of 4 new or added lines in 2 files covered. (75.0%)

13 existing lines in 1 file now uncovered.

36500 of 59320 relevant lines covered (61.53%)

1125.55 hits per line

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

81.25
/opt/src/passes/scheduler/loop_scheduling_pass.cpp
1
#include "sdfg/passes/scheduler/loop_scheduling_pass.h"
2

3
#include "sdfg/analysis/data_transfer_elimination_analysis.h"
4
#include "sdfg/passes/offloading/data_transfer_minimization_pass.h"
5
#include "sdfg/passes/scheduler/loop_scheduler.h"
6
#include "sdfg/passes/scheduler/scheduler_registry.h"
7
#include "sdfg/structured_control_flow/map.h"
8

9
namespace sdfg {
10
namespace passes {
11
namespace scheduler {
12

13
bool LoopSchedulingPass::run_pass_target(
14
    builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager, const std::string& target
15
) {
6✔
16
    auto scheduler = SchedulerRegistry::instance().get_loop_scheduler(target);
6✔
17
    if (!scheduler) {
6✔
18
        throw std::runtime_error("Unsupported scheduling target: " + target);
×
19
    }
×
20
    scheduler->set_report(report_);
6✔
21

22
    // ===== Phase 1: Find all applicable loops =====
23
    auto& loop_analysis = analysis_manager.get<analysis::LoopAnalysis>();
6✔
24
    auto& flop_analysis = analysis_manager.get<analysis::FlopAnalysis>();
6✔
25

26
    // Initialize queue with outermost loops
27
    std::list<structured_control_flow::ControlFlowNode*> queue;
6✔
28
    std::unordered_map<structured_control_flow::ControlFlowNode*, SchedulerLoopInfo> scheduling_info_map;
6✔
29
    for (auto& loop : loop_analysis.outermost_loops()) {
6✔
30
        queue.push_back(loop);
6✔
31

32
        SchedulerLoopInfo info;
6✔
33
        info.loop_info = loop_analysis.loop_info(loop);
6✔
34
        info.flop = flop_analysis.get(loop);
6✔
35
        scheduling_info_map[loop] = info;
6✔
36
    }
6✔
37
    if (queue.empty()) {
6✔
38
        return false;
×
39
    }
×
40

41
    // Filter by compatible types
42
    for (int i = 0; i < queue.size(); i++) {
12✔
43
        auto loop = queue.front();
6✔
44
        queue.pop_front();
6✔
45

46
        auto descendants = loop_analysis.descendants(loop);
6✔
47

48
        bool found_incompatible = false;
6✔
49
        for (auto descendant : descendants) {
10✔
50
            if (auto map_node = dynamic_cast<structured_control_flow::Map*>(descendant)) {
10✔
51
                auto compatible_schedules = scheduler->compatible_types();
10✔
52
                if (compatible_schedules.find(map_node->schedule_type().category()) == compatible_schedules.end()) {
10✔
53
                    found_incompatible = true;
×
54
                    break;
×
55
                }
×
56
            }
10✔
57
        }
10✔
58

59
        if (!found_incompatible) {
6✔
60
            queue.push_back(loop);
6✔
61
        }
6✔
62
    }
6✔
63

64
    // Traverse loop tree using scheduler's find() to collect applicable loops
65
    std::vector<structured_control_flow::StructuredLoop*> applicable_loops;
6✔
66
    while (!queue.empty()) {
18✔
67
        auto loop = queue.front();
12✔
68
        queue.pop_front();
12✔
69

70
        auto scheduling_info = scheduling_info_map.at(loop);
12✔
71
        scheduling_info_map.erase(loop);
12✔
72

73
        // Set the report context
74
        if (report_ && scheduling_info.loop_info.loopnest_index >= 0) {
12✔
UNCOV
75
            report_->in_outermost_loop(scheduling_info.loop_info.loopnest_index);
×
UNCOV
76
        }
×
77

78
        SchedulerAction action;
12✔
79
        if (auto while_loop = dynamic_cast<structured_control_flow::While*>(loop)) {
12✔
80
            action = scheduler->find(builder, analysis_manager, *while_loop, offload_unknown_sizes_);
4✔
81
        } else if (auto structured_loop = dynamic_cast<structured_control_flow::StructuredLoop*>(loop)) {
8✔
82
            action = scheduler->find(builder, analysis_manager, *structured_loop, offload_unknown_sizes_);
8✔
83
        } else {
8✔
UNCOV
84
            throw InvalidSDFGException("LoopScheduler encountered non-loop in loop analysis.");
×
UNCOV
85
        }
×
86

87
        switch (action) {
12✔
88
            case SchedulerAction::NEXT: {
8✔
89
                if (auto structured_loop = dynamic_cast<structured_control_flow::StructuredLoop*>(loop)) {
8✔
90
                    applicable_loops.push_back(structured_loop);
8✔
91
                }
8✔
92
                break;
8✔
UNCOV
93
            }
×
94
            case SchedulerAction::CHILDREN: {
4✔
95
                auto children = loop_analysis.children(loop);
4✔
96
                for (auto& child : children) {
6✔
97
                    queue.push_front(child);
6✔
98

99
                    SchedulerLoopInfo info;
6✔
100
                    info.loop_info = loop_analysis.loop_info(child);
6✔
101
                    info.flop = flop_analysis.get(child);
6✔
102
                    scheduling_info_map[child] = info;
6✔
103
                }
6✔
104
                break;
4✔
UNCOV
105
            }
×
106
        }
12✔
107
    }
12✔
108

109
    if (applicable_loops.empty()) {
6✔
UNCOV
110
        return false;
×
UNCOV
111
    }
×
112

113
    // ===== Phase 2: Pre-schedule (collapse + cleanup) =====
114
    scheduler->pre_schedule(builder, analysis_manager, applicable_loops);
6✔
115

116
    // ===== Phase 3: Apply scheduling transforms =====
117
    // Phase 3a: Collect loops where transform can be applied
118
    std::vector<structured_control_flow::StructuredLoop*> schedulable_loops;
6✔
119
    for (auto* loop : applicable_loops) {
8✔
120
        if (scheduler->can_apply_schedule(builder, analysis_manager, *loop, offload_unknown_sizes_)) {
8✔
121
            schedulable_loops.push_back(loop);
8✔
122
        }
8✔
123
    }
8✔
124

125
    if (schedulable_loops.empty()) {
6✔
UNCOV
126
        return false;
×
UNCOV
127
    }
×
128

129
    // Phase 3b: Apply transforms
130
    for (auto* loop : schedulable_loops) {
8✔
131
        scheduler->apply_schedule(builder, analysis_manager, *loop, offload_unknown_sizes_);
8✔
132
    }
8✔
133
    analysis_manager.preserve<sdfg::analysis::ArgumentsAnalysis>();
6✔
134

135
    // ===== Phase 4: Post-schedule =====
136
    scheduler->post_schedule(builder, analysis_manager, schedulable_loops);
6✔
137

138
    return true;
6✔
139
}
6✔
140

141
bool LoopSchedulingPass::run_pass(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) {
6✔
142
    if (targets_.empty()) {
6✔
UNCOV
143
        return false;
×
UNCOV
144
    }
×
145
    if (targets_.size() == 1 && targets_[0] == "none") {
6✔
UNCOV
146
        return false;
×
147
    }
×
148

149
    bool applied = false;
6✔
150
    for (const auto& target : targets_) {
6✔
151
        bool target_applied = run_pass_target(builder, analysis_manager, target);
6✔
152
        if (target_applied) {
6✔
153
            analysis_manager.invalidate_all();
6✔
154
        }
6✔
155
        applied = applied || target_applied;
6✔
156
    }
6✔
157

158
    return applied;
6✔
159
}
6✔
160

161
} // namespace scheduler
162
} // namespace passes
163
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc