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

daisytuner / sdfglib / 15341964399

30 May 2025 07:50AM UTC coverage: 58.563% (+0.01%) from 58.553%
15341964399

Pull #44

github

web-flow
Merge 57faf9c88 into ad9a83c5a
Pull Request #44: Add Structured Loops

45 of 95 new or added lines in 18 files covered. (47.37%)

1 existing line in 1 file now uncovered.

8210 of 14019 relevant lines covered (58.56%)

109.71 hits per line

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

48.08
/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) : Function(name) {
464✔
16
    size_t element_id = 0;
464✔
17
    this->root_ = std::unique_ptr<structured_control_flow::Sequence>(
464✔
18
        new structured_control_flow::Sequence(element_id, DebugInfo()));
464✔
19
};
464✔
20

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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