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

daisytuner / sdfglib / 15512041711

07 Jun 2025 09:59PM UTC coverage: 57.416% (+0.1%) from 57.315%
15512041711

push

github

web-flow
Merge pull request #44 from daisytuner/StructuredLoops

Add Structured Loops

51 of 102 new or added lines in 20 files covered. (50.0%)

10 existing lines in 8 files now uncovered.

7618 of 13268 relevant lines covered (57.42%)

116.01 hits per line

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

51.04
/src/structured_sdfg.cpp
1
#include "sdfg/structured_sdfg.h"
2

3
#include "sdfg/builder/structured_sdfg_builder.h"
4
#include "sdfg/data_flow/access_node.h"
5
#include "sdfg/data_flow/tasklet.h"
6
#include "sdfg/deepcopy/structured_sdfg_deep_copy.h"
7
#include "sdfg/element.h"
8
#include "sdfg/structured_control_flow/control_flow_node.h"
9
#include "sdfg/structured_control_flow/for.h"
10
#include "sdfg/structured_control_flow/sequence.h"
11
#include "sdfg/structured_control_flow/structured_loop.h"
12

13
namespace sdfg {
14

15
StructuredSDFG::StructuredSDFG(const std::string& name, FunctionType type) : Function(name, type) {
446✔
16
    this->root_ = std::unique_ptr<structured_control_flow::Sequence>(
446✔
17
        new structured_control_flow::Sequence(DebugInfo()));
446✔
18
};
446✔
19

20
const structured_control_flow::Sequence& StructuredSDFG::root() const { return *this->root_; };
5✔
21

22
structured_control_flow::Sequence& StructuredSDFG::root() { return *this->root_; };
1,916✔
23

24
std::unique_ptr<StructuredSDFG> StructuredSDFG::clone() const {
2✔
25
    builder::StructuredSDFGBuilder builder(this->name_, this->type_);
2✔
26
    auto& new_sdfg = builder.subject();
2✔
27

28
    for (auto& structure : this->structures_) {
3✔
29
        new_sdfg.structures_.insert({structure.first, structure.second->clone()});
1✔
30
    }
31

32
    for (auto& container : this->containers_) {
8✔
33
        new_sdfg.containers_.insert({container.first, container.second->clone()});
6✔
34
    }
35

36
    for (auto& arg : this->arguments_) {
4✔
37
        new_sdfg.arguments_.push_back(arg);
2✔
38
    }
39

40
    for (auto& ext : this->externals_) {
3✔
41
        new_sdfg.externals_.push_back(ext);
1✔
42
    }
43

44
    for (auto& entry : this->metadata_) {
2✔
45
        new_sdfg.metadata_[entry.first] = entry.second;
×
46
    }
47

48
    for (auto& assumption : this->assumptions_) {
7✔
49
        new_sdfg.assumptions_.insert({assumption.first, assumption.second});
5✔
50
    }
51

52
    deepcopy::StructuredSDFGDeepCopy copier(builder, new_sdfg.root(), *this->root_);
2✔
53
    auto mapping = copier.insert();
2✔
54

55
    return builder.move();
2✔
56
};
2✔
57

58
size_t StructuredSDFG::num_nodes() const {
×
59
    size_t count = 0;
×
60
    std::set<const ControlFlowNode*> to_visit = {&this->root()};
×
61
    while (!to_visit.empty()) {
×
62
        auto current = *to_visit.begin();
×
63
        to_visit.erase(to_visit.begin());
×
64
        // if instance of block, add children to to_visit
65
        if (auto block = dynamic_cast<const structured_control_flow::Block*>(current)) {
×
66
            count += block->dataflow().nodes().size();
×
NEW
67
        } else if (auto sloop_node =
×
NEW
68
                       dynamic_cast<const structured_control_flow::StructuredLoop*>(current)) {
×
NEW
69
            to_visit.insert(&sloop_node->root());
×
70
        } else if (auto condition_node =
×
71
                       dynamic_cast<const structured_control_flow::IfElse*>(current)) {
×
72
            for (size_t i = 0; i < condition_node->size(); i++) {
×
73
                to_visit.insert(&condition_node->at(i).first);
×
74
            }
×
75
        } else if (auto while_node = dynamic_cast<const structured_control_flow::While*>(current)) {
×
76
            to_visit.insert(&while_node->root());
×
77
        } else if (auto sequence_node =
×
78
                       dynamic_cast<const structured_control_flow::Sequence*>(current)) {
×
79
            for (size_t i = 0; i < sequence_node->size(); i++) {
×
80
                to_visit.insert(&sequence_node->at(i).first);
×
81
            }
×
82
        } else if (dynamic_cast<const structured_control_flow::Return*>(current)) {
×
83
            continue;
×
84
        } else if (auto map_node = dynamic_cast<const structured_control_flow::Map*>(current)) {
×
85
            to_visit.insert(&map_node->root());
×
86
        }
×
87
    }
88
    return count;
×
89
};
×
90

91
const DebugInfo StructuredSDFG::debug_info() const {
5✔
92
    DebugInfo info;
5✔
93
    std::set<const ControlFlowNode*> to_visit = {&this->root()};
5✔
94
    while (!to_visit.empty()) {
15✔
95
        auto current = *to_visit.begin();
10✔
96
        to_visit.erase(to_visit.begin());
10✔
97
        info = DebugInfo::merge(info, current->debug_info());
10✔
98

99
        // if instance of block, add children to to_visit
100
        if (auto block = dynamic_cast<const structured_control_flow::Block*>(current)) {
10✔
101
            for (auto& node : block->dataflow().nodes()) {
5✔
102
                info = DebugInfo::merge(info, node.debug_info());
×
103
            }
104
            for (auto& edge : block->dataflow().edges()) {
5✔
105
                info = DebugInfo::merge(info, edge.debug_info());
×
106
            }
107
        } else if (auto sloop_node =
10✔
108
                       dynamic_cast<const structured_control_flow::StructuredLoop*>(current)) {
5✔
NEW
109
            info = DebugInfo::merge(info, sloop_node->debug_info());
×
NEW
110
            to_visit.insert(&sloop_node->root());
×
111
        } else if (auto condition_node =
5✔
112
                       dynamic_cast<const structured_control_flow::IfElse*>(current)) {
5✔
113
            info = DebugInfo::merge(info, condition_node->debug_info());
×
114
            for (size_t i = 0; i < condition_node->size(); i++) {
×
115
                to_visit.insert(&condition_node->at(i).first);
×
116
            }
×
117
        } else if (auto while_node = dynamic_cast<const structured_control_flow::While*>(current)) {
5✔
118
            info = DebugInfo::merge(info, while_node->debug_info());
×
119
            to_visit.insert(&while_node->root());
×
120
        } else if (auto sequence_node =
5✔
121
                       dynamic_cast<const structured_control_flow::Sequence*>(current)) {
5✔
122
            info = DebugInfo::merge(info, sequence_node->debug_info());
5✔
123
            for (size_t i = 0; i < sequence_node->size(); i++) {
10✔
124
                to_visit.insert(&sequence_node->at(i).first);
5✔
125
                info = DebugInfo::merge(info, sequence_node->at(i).second.debug_info());
5✔
126
            }
5✔
127
        } else if (auto return_node =
5✔
128
                       dynamic_cast<const structured_control_flow::Return*>(current)) {
×
129
            info = DebugInfo::merge(info, return_node->debug_info());
×
130
        } else if (auto map_node = dynamic_cast<const structured_control_flow::Map*>(current)) {
×
131
            info = DebugInfo::merge(info, map_node->debug_info());
×
132
            to_visit.insert(&map_node->root());
×
133
        }
×
134
    }
135
    return info;
5✔
136
};
5✔
137

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