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

daisytuner / sdfglib / 15187766828

22 May 2025 01:23PM UTC coverage: 60.482% (+0.003%) from 60.479%
15187766828

push

github

web-flow
Merge pull request #28 from daisytuner/sdfg-metadata

adds metadata to SDFGs

21 of 37 new or added lines in 6 files covered. (56.76%)

1 existing line in 1 file now uncovered.

8023 of 13265 relevant lines covered (60.48%)

102.83 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/serializer/json_serializer.h"
9
#include "sdfg/structured_control_flow/control_flow_node.h"
10
#include "sdfg/structured_control_flow/for.h"
11
#include "sdfg/structured_control_flow/sequence.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_; };
17✔
22

23
structured_control_flow::Sequence& StructuredSDFG::root() { return *this->root_; };
1,816✔
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✔
NEW
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();
×
68
        } else if (auto for_node = dynamic_cast<const structured_control_flow::For*>(current)) {
×
69
            to_visit.insert(&for_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 (auto kernel_node =
×
83
                       dynamic_cast<const structured_control_flow::Kernel*>(current)) {
×
84
            to_visit.insert(&kernel_node->root());
×
85
        } else if (dynamic_cast<const structured_control_flow::Return*>(current)) {
×
86
            continue;
×
87
        }
88
    }
89
    return count;
×
90
};
×
91

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

100
        // if instance of block, add children to to_visit
101
        if (auto block = dynamic_cast<const structured_control_flow::Block*>(current)) {
10✔
102
            for (auto& node : block->dataflow().nodes()) {
5✔
103
                info = DebugInfo::merge(info, node.debug_info());
×
104
            }
105
            for (auto& edge : block->dataflow().edges()) {
5✔
106
                info = DebugInfo::merge(info, edge.debug_info());
×
107
            }
108
        } else if (auto for_node = dynamic_cast<const structured_control_flow::For*>(current)) {
10✔
109
            info = DebugInfo::merge(info, for_node->debug_info());
×
110
            to_visit.insert(&for_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 kernel_node =
5✔
128
                       dynamic_cast<const structured_control_flow::Kernel*>(current)) {
×
129
            info = DebugInfo::merge(info, kernel_node->debug_info());
×
130
            to_visit.insert(&kernel_node->root());
×
131
        } else if (auto return_node =
×
132
                       dynamic_cast<const structured_control_flow::Return*>(current)) {
×
133
            info = DebugInfo::merge(info, return_node->debug_info());
×
134
        }
×
135
    }
136
    return info;
5✔
137
};
5✔
138

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