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

daisytuner / sdfglib / 16364596108

18 Jul 2025 07:14AM UTC coverage: 65.002% (+0.07%) from 64.93%
16364596108

Pull #150

github

web-flow
Merge 444c1cde1 into 2a19c1873
Pull Request #150: uses serializer for stable clone

16 of 23 new or added lines in 2 files covered. (69.57%)

5 existing lines in 1 file now uncovered.

8746 of 13455 relevant lines covered (65.0%)

176.2 hits per line

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

14.67
/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

9
#include "sdfg/serializer/json_serializer.h"
10

11
namespace sdfg {
12

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

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

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

22
std::unique_ptr<StructuredSDFG> StructuredSDFG::clone() const {
1✔
23
    serializer::JSONSerializer serializer;
1✔
24
    nlohmann::json j = serializer.serialize(*this);
1✔
25
    return serializer.deserialize(j);
1✔
26
};
1✔
27

28
size_t StructuredSDFG::num_nodes() const {
×
29
    size_t count = 0;
×
30
    std::set<const ControlFlowNode*> to_visit = {&this->root()};
×
31
    while (!to_visit.empty()) {
×
32
        auto current = *to_visit.begin();
×
33
        to_visit.erase(to_visit.begin());
×
34
        // if instance of block, add children to to_visit
35
        if (auto block = dynamic_cast<const structured_control_flow::Block*>(current)) {
×
36
            count += block->dataflow().nodes().size();
×
NEW
37
        } else if (auto sloop_node = dynamic_cast<const structured_control_flow::StructuredLoop*>(current)) {
×
38
            to_visit.insert(&sloop_node->root());
×
NEW
39
        } else if (auto condition_node = dynamic_cast<const structured_control_flow::IfElse*>(current)) {
×
40
            for (size_t i = 0; i < condition_node->size(); i++) {
×
41
                to_visit.insert(&condition_node->at(i).first);
×
42
            }
×
43
        } else if (auto while_node = dynamic_cast<const structured_control_flow::While*>(current)) {
×
44
            to_visit.insert(&while_node->root());
×
NEW
45
        } else if (auto sequence_node = dynamic_cast<const structured_control_flow::Sequence*>(current)) {
×
46
            for (size_t i = 0; i < sequence_node->size(); i++) {
×
47
                to_visit.insert(&sequence_node->at(i).first);
×
48
            }
×
49
        } else if (dynamic_cast<const structured_control_flow::Return*>(current)) {
×
50
            continue;
×
51
        } else if (auto map_node = dynamic_cast<const structured_control_flow::Map*>(current)) {
×
52
            to_visit.insert(&map_node->root());
×
53
        }
×
54
    }
55
    return count;
×
56
};
×
57

58
const DebugInfo StructuredSDFG::debug_info() const {
×
59
    DebugInfo info;
×
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
        info = DebugInfo::merge(info, current->debug_info());
×
65

66
        // if instance of block, add children to to_visit
67
        if (auto block = dynamic_cast<const structured_control_flow::Block*>(current)) {
×
68
            for (auto& node : block->dataflow().nodes()) {
×
69
                info = DebugInfo::merge(info, node.debug_info());
×
70
            }
71
            for (auto& edge : block->dataflow().edges()) {
×
72
                info = DebugInfo::merge(info, edge.debug_info());
×
73
            }
NEW
74
        } else if (auto sloop_node = dynamic_cast<const structured_control_flow::StructuredLoop*>(current)) {
×
75
            info = DebugInfo::merge(info, sloop_node->debug_info());
×
76
            to_visit.insert(&sloop_node->root());
×
NEW
77
        } else if (auto condition_node = dynamic_cast<const structured_control_flow::IfElse*>(current)) {
×
78
            info = DebugInfo::merge(info, condition_node->debug_info());
×
79
            for (size_t i = 0; i < condition_node->size(); i++) {
×
80
                to_visit.insert(&condition_node->at(i).first);
×
81
            }
×
82
        } else if (auto while_node = dynamic_cast<const structured_control_flow::While*>(current)) {
×
83
            info = DebugInfo::merge(info, while_node->debug_info());
×
84
            to_visit.insert(&while_node->root());
×
NEW
85
        } else if (auto sequence_node = dynamic_cast<const structured_control_flow::Sequence*>(current)) {
×
86
            info = DebugInfo::merge(info, sequence_node->debug_info());
×
87
            for (size_t i = 0; i < sequence_node->size(); i++) {
×
88
                to_visit.insert(&sequence_node->at(i).first);
×
89
                info = DebugInfo::merge(info, sequence_node->at(i).second.debug_info());
×
90
            }
×
NEW
91
        } else if (auto return_node = dynamic_cast<const structured_control_flow::Return*>(current)) {
×
92
            info = DebugInfo::merge(info, return_node->debug_info());
×
93
        } else if (auto map_node = dynamic_cast<const structured_control_flow::Map*>(current)) {
×
94
            info = DebugInfo::merge(info, map_node->debug_info());
×
95
            to_visit.insert(&map_node->root());
×
96
        }
×
97
    }
98
    return info;
×
99
};
×
100

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