• 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

0.0
/src/analysis/loop_tree_analysis.cpp
1
#include "sdfg/analysis/loop_tree_analysis.h"
2

3
namespace sdfg {
4
namespace analysis {
5

NEW
6
LoopTreeAnalysis::LoopTreeAnalysis(StructuredSDFG& sdfg) : Analysis(sdfg) {}
×
7

NEW
8
void LoopTreeAnalysis::run(structured_control_flow::ControlFlowNode& scope,
×
9
                           structured_control_flow::ControlFlowNode* parent_loop) {
NEW
10
    std::list<structured_control_flow::ControlFlowNode*> queue = {&scope};
×
NEW
11
    while (!queue.empty()) {
×
NEW
12
        auto current = queue.front();
×
NEW
13
        queue.pop_front();
×
14

15
        // Loop detected
NEW
16
        if (auto while_stmt = dynamic_cast<structured_control_flow::While*>(current)) {
×
NEW
17
            this->loop_tree_[while_stmt] = parent_loop;
×
NEW
18
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(current)) {
×
NEW
19
            this->loop_tree_[for_stmt] = parent_loop;
×
NEW
20
        }
×
21

NEW
22
        if (dynamic_cast<structured_control_flow::Block*>(current)) {
×
NEW
23
            continue;
×
NEW
24
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(current)) {
×
NEW
25
            for (size_t i = 0; i < sequence_stmt->size(); i++) {
×
NEW
26
                queue.push_back(&sequence_stmt->at(i).first);
×
NEW
27
            }
×
NEW
28
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(current)) {
×
NEW
29
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
NEW
30
                queue.push_back(&if_else_stmt->at(i).first);
×
NEW
31
            }
×
NEW
32
        } else if (auto while_stmt = dynamic_cast<structured_control_flow::While*>(current)) {
×
NEW
33
            this->run(while_stmt->root(), while_stmt);
×
NEW
34
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(current)) {
×
NEW
35
            this->run(for_stmt->root(), for_stmt);
×
NEW
36
        } else if (dynamic_cast<structured_control_flow::Kernel*>(current)) {
×
NEW
37
            continue;
×
NEW
38
        } else if (dynamic_cast<structured_control_flow::Break*>(current)) {
×
NEW
39
            continue;
×
NEW
40
        } else if (dynamic_cast<structured_control_flow::Continue*>(current)) {
×
NEW
41
            continue;
×
NEW
42
        } else if (dynamic_cast<structured_control_flow::Return*>(current)) {
×
NEW
43
            continue;
×
44
        } else {
NEW
45
            throw std::runtime_error("Unsupported control flow node type");
×
46
        }
47
    }
NEW
48
}
×
49

NEW
50
void LoopTreeAnalysis::run(AnalysisManager& analysis_manager) {
×
NEW
51
    this->loop_tree_.clear();
×
NEW
52
    this->run(this->sdfg_.root(), nullptr);
×
NEW
53
}
×
54

55
const std::unordered_map<structured_control_flow::ControlFlowNode*,
56
                         structured_control_flow::ControlFlowNode*>&
NEW
57
LoopTreeAnalysis::loop_tree() const {
×
NEW
58
    return this->loop_tree_;
×
59
}
60

NEW
61
structured_control_flow::ControlFlowNode* LoopTreeAnalysis::parent_loop(
×
62
    structured_control_flow::ControlFlowNode* loop) const {
NEW
63
    return this->loop_tree_.at(loop);
×
64
}
65

NEW
66
const std::vector<structured_control_flow::ControlFlowNode*> LoopTreeAnalysis::outermost_loops()
×
67
    const {
NEW
68
    std::vector<structured_control_flow::ControlFlowNode*> outermost_loops_;
×
NEW
69
    for (const auto& [loop, parent] : this->loop_tree_) {
×
NEW
70
        if (parent == nullptr) {
×
NEW
71
            outermost_loops_.push_back(loop);
×
NEW
72
        }
×
73
    }
NEW
74
    return outermost_loops_;
×
NEW
75
}
×
76

77
}  // namespace analysis
78
}  // 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