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

daisytuner / sdfglib / 15120496827

19 May 2025 06:29PM UTC coverage: 63.542% (-0.07%) from 63.608%
15120496827

push

github

web-flow
Merge pull request #21 from daisytuner/errors

adds invalid sdfg exception

5 of 14 new or added lines in 3 files covered. (35.71%)

7 existing lines in 2 files now uncovered.

8650 of 13613 relevant lines covered (63.54%)

481.54 hits per line

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

88.54
/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)
100✔
10
    : Function(name),
50✔
11
      start_state_(nullptr){
50✔
12

13
      };
50✔
14

15
const DebugInfo SDFG::debug_info() const {
1✔
16
    DebugInfo info;
1✔
17
    for (auto& state : this->states()) {
1✔
18
        info = DebugInfo::merge(info, state.debug_info());
×
19
        for (auto& data_flow_node : state.dataflow().nodes()) {
×
20
            info = DebugInfo::merge(info, data_flow_node.debug_info());
×
21
        }
22
        for (auto& edge : state.dataflow().edges()) {
×
23
            info = DebugInfo::merge(info, edge.debug_info());
×
24
        }
25
    }
26
    for (auto& edges : this->edges()) {
1✔
27
        info = DebugInfo::merge(info, edges.debug_info());
×
28
    }
29
    return info;
1✔
30
};
1✔
31

32
size_t SDFG::in_degree(const control_flow::State& state) const {
15✔
33
    return boost::in_degree(state.vertex(), this->graph_);
15✔
34
};
35

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

40
bool SDFG::is_adjacent(const control_flow::State& src, const control_flow::State& dst) const {
6✔
41
    return boost::edge(src.vertex(), dst.vertex(), this->graph_).second;
6✔
42
};
43

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

53
const control_flow::State& SDFG::start_state() const {
6✔
54
    if (this->start_state_ == nullptr) {
6✔
NEW
55
        throw InvalidSDFGException("Start state not set");
×
56
    }
57
    return *this->start_state_;
6✔
UNCOV
58
};
×
59

60
std::unordered_map<const control_flow::State*, const control_flow::State*> SDFG::dominator_tree()
1✔
61
    const {
62
    auto dom_tree_ = graph::dominator_tree(this->graph_, this->start_state_->vertex());
1✔
63

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

74
    return dom_tree;
1✔
75
};
1✔
76

77
std::unordered_map<const control_flow::State*, const control_flow::State*>
78
SDFG::post_dominator_tree() const {
5✔
79
    auto terminal_state = this->terminal_states();
5✔
80
    assert(std::distance(terminal_state.begin(), terminal_state.end()) == 1);
5✔
81

82
    auto pdom_tree_ = graph::post_dominator_tree(this->graph_, (*terminal_state.begin()).vertex());
5✔
83

84
    std::unordered_map<const control_flow::State*, const control_flow::State*> pdom_tree;
5✔
85
    for (auto& entry : pdom_tree_) {
25✔
86
        control_flow::State* first = this->states_.at(entry.first).get();
20✔
87
        control_flow::State* second = nullptr;
20✔
88
        if (entry.second != boost::graph_traits<graph::Graph>::null_vertex()) {
20✔
89
            second = this->states_.at(entry.second).get();
15✔
90
        }
15✔
91
        pdom_tree.insert({first, second});
20✔
92
    }
93

94
    return pdom_tree;
5✔
95
};
5✔
96

97
std::list<const control_flow::InterstateEdge*> SDFG::back_edges() const {
4✔
98
    std::list<const control_flow::InterstateEdge*> bedges;
4✔
99
    for (const auto& edge : graph::back_edges(this->graph_, this->start_state_->vertex())) {
5✔
100
        bedges.push_back(this->edges_.find(edge)->second.get());
1✔
101
    }
102

103
    return bedges;
4✔
104
};
4✔
105

106
std::list<std::list<const control_flow::InterstateEdge*>> SDFG::all_simple_paths(
1✔
107
    const control_flow::State& src, const control_flow::State& dst) const {
108
    std::list<std::list<const control_flow::InterstateEdge*>> all_paths;
1✔
109

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

120
    return all_paths;
1✔
121
};
1✔
122

123
void SDFG::as_dot(std::ostream& f) const {
1✔
124
    std::map<graph::Graph::vertex_descriptor, size_t> node_ids;
1✔
125
    std::map<graph::Graph::vertex_descriptor, std::string> node_names;
1✔
126
    for (auto u : boost::make_iterator_range(boost::vertices(this->graph_))) {
6✔
127
        node_ids[u] = node_ids.size();
5✔
128
        node_names[u] = this->states_.at(u)->name();
5✔
129
    }
130

131
    codegen::CLanguageExtension lang_ext;
1✔
132
    std::map<graph::Graph::edge_descriptor, std::string> edge_names;
1✔
133
    for (auto u : boost::make_iterator_range(boost::edges(this->graph_))) {
6✔
134
        std::string desc = lang_ext.expression(this->edges_.at(u)->condition());
5✔
135
        desc += " ; ";
5✔
136
        for (auto& ass : this->edges_.at(u)->assignments()) {
5✔
137
            desc += lang_ext.expression(ass.first) + " = " + lang_ext.expression(ass.second) + ",";
×
138
        }
139
        edge_names[u] = desc;
5✔
140
    }
5✔
141

142
    boost::default_writer w;
143
    boost::write_graphviz(f, this->graph_,
2✔
144
                          boost::make_label_writer(boost::make_assoc_property_map(node_names)),
1✔
145
                          boost::make_label_writer(boost::make_assoc_property_map(edge_names)), w,
1✔
146
                          boost::make_assoc_property_map(node_ids));
1✔
147
};
1✔
148

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