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

daisytuner / sdfglib / 17656823807

11 Sep 2025 08:42PM UTC coverage: 60.447% (+1.1%) from 59.335%
17656823807

Pull #219

github

web-flow
Merge d5416236f into 6c1992b40
Pull Request #219: stdlib Library Nodes and ConstantNodes

460 of 1635 new or added lines in 81 files covered. (28.13%)

93 existing lines in 35 files now uncovered.

9385 of 15526 relevant lines covered (60.45%)

107.21 hits per line

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

89.47
/src/sdfg.cpp
1
#include "sdfg/sdfg.h"
2

3
#include "sdfg/codegen/language_extensions/c_language_extension.h"
4
#include "sdfg/element.h"
5
#include "sdfg/symbolic/symbolic.h"
6

7
namespace sdfg {
8

9
SDFG::SDFG(const std::string& name, FunctionType type, const types::IType& return_type)
50✔
10
    : Function(name, type, return_type), start_state_(nullptr) {};
50✔
11

12
SDFG::SDFG(const std::string& name, FunctionType type) : SDFG(name, type, types::Scalar(types::PrimitiveType::Void)) {};
50✔
13

14
void SDFG::validate() const {
13✔
15
    // Call parent validate
16
    Function::validate();
13✔
17

18
    // Validate states and edges
19
    for (auto& state : this->states()) {
30✔
20
        state.validate(*this);
17✔
21
    }
22
    for (auto& edge : this->edges()) {
29✔
23
        edge.validate(*this);
16✔
24
    }
25

26
    for (auto& term : this->terminal_states()) {
17✔
27
        if (!dynamic_cast<const control_flow::ReturnState*>(&term)) {
4✔
NEW
28
            throw InvalidSDFGException("Terminal state is not a valid State");
×
29
        }
30
    }
31
};
13✔
32

NEW
33
size_t SDFG::num_terminal_states() const {
×
NEW
34
    return std::distance(this->terminal_states().begin(), this->terminal_states().end());
×
35
};
36

37
size_t SDFG::in_degree(const control_flow::State& state) const {
15✔
38
    return boost::in_degree(state.vertex(), this->graph_);
15✔
39
};
40

41
size_t SDFG::out_degree(const control_flow::State& state) const {
53✔
42
    return boost::out_degree(state.vertex(), this->graph_);
53✔
43
};
44

45
bool SDFG::is_adjacent(const control_flow::State& src, const control_flow::State& dst) const {
6✔
46
    return boost::edge(src.vertex(), dst.vertex(), this->graph_).second;
6✔
47
};
48

49
const control_flow::InterstateEdge& SDFG::edge(const control_flow::State& src, const control_flow::State& dst) const {
4✔
50
    auto e = boost::edge(src.vertex(), dst.vertex(), this->graph_);
4✔
51
    if (!e.second) {
4✔
52
        throw InvalidSDFGException("Edge does not exist");
×
53
    }
54
    return *this->edges_.at(e.first);
4✔
55
};
×
56

57
const control_flow::State& SDFG::start_state() const {
6✔
58
    if (this->start_state_ == nullptr) {
6✔
59
        throw InvalidSDFGException("Start state not set");
×
60
    }
61
    return *this->start_state_;
6✔
62
};
×
63

64
std::unordered_map<const control_flow::State*, const control_flow::State*> SDFG::dominator_tree() const {
1✔
65
    auto dom_tree_ = graph::dominator_tree(this->graph_, this->start_state_->vertex());
1✔
66

67
    std::unordered_map<const control_flow::State*, const control_flow::State*> dom_tree;
1✔
68
    for (auto& entry : dom_tree_) {
6✔
69
        control_flow::State* first = this->states_.at(entry.first).get();
5✔
70
        control_flow::State* second = nullptr;
5✔
71
        if (entry.second != boost::graph_traits<graph::Graph>::null_vertex()) {
5✔
72
            second = this->states_.at(entry.second).get();
4✔
73
        }
4✔
74
        dom_tree.insert({first, second});
5✔
75
    }
76

77
    return dom_tree;
1✔
78
};
1✔
79

80
std::unordered_map<const control_flow::State*, const control_flow::State*> SDFG::post_dominator_tree() {
5✔
81
    auto pdom_tree_ = graph::post_dominator_tree(this->graph_);
5✔
82

83
    std::unordered_map<const control_flow::State*, const control_flow::State*> pdom_tree;
5✔
84
    for (auto& entry : pdom_tree_) {
27✔
85
        if (this->states_.find(entry.first) == this->states_.end()) {
22✔
86
            // This is the synthetic super-terminal, skip it
NEW
87
            continue;
×
88
        }
89

90
        control_flow::State* first = this->states_.at(entry.first).get();
22✔
91
        control_flow::State* second = nullptr;
22✔
92
        if (entry.second != boost::graph_traits<graph::Graph>::null_vertex() &&
39✔
93
            this->states_.find(entry.second) != this->states_.end()) {
17✔
94
            second = this->states_.at(entry.second).get();
17✔
95
        }
17✔
96
        pdom_tree.insert({first, second});
22✔
97
    }
98

99
    return pdom_tree;
5✔
100
};
5✔
101

102
std::list<const control_flow::InterstateEdge*> SDFG::back_edges() const {
4✔
103
    std::list<const control_flow::InterstateEdge*> bedges;
4✔
104
    for (const auto& edge : graph::back_edges(this->graph_, this->start_state_->vertex())) {
5✔
105
        bedges.push_back(this->edges_.find(edge)->second.get());
1✔
106
    }
107

108
    return bedges;
4✔
109
};
4✔
110

111
std::list<std::list<const control_flow::InterstateEdge*>> SDFG::
112
    all_simple_paths(const control_flow::State& src, const control_flow::State& dst) const {
1✔
113
    std::list<std::list<const control_flow::InterstateEdge*>> all_paths;
1✔
114

115
    std::list<std::list<graph::Edge>> all_paths_raw = graph::all_simple_paths(this->graph_, src.vertex(), dst.vertex());
1✔
116
    for (auto& path_raw : all_paths_raw) {
3✔
117
        std::list<const control_flow::InterstateEdge*> path;
2✔
118
        for (auto& edge : path_raw) {
8✔
119
            path.push_back(this->edges_.find(edge)->second.get());
6✔
120
        }
121
        all_paths.push_back(path);
2✔
122
    }
2✔
123

124
    return all_paths;
1✔
125
};
1✔
126

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

© 2025 Coveralls, Inc