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

daisytuner / sdfglib / 15340968114

30 May 2025 06:47AM UTC coverage: 58.553% (+0.2%) from 58.324%
15340968114

push

github

web-flow
Add parallel Map node

* Introduce Map data structure

* Prepare infrastructure

* implement analysis support

* Add basic infrastructure

* visualizer/serializer

* include fix

* update from main

* remove default

* happens before test + fixes

* builder test

* dispatcher test

* visitor, copy and serializer tests

* for2map structures

* for2map conversion draft

* add tests

* Bug fixes

* small updates from feedback

* Visitor style pass implementation

* cleanup

* fixes linting errors

---------

Co-authored-by: Lukas Truemper <lukas.truemper@outlook.de>

258 of 381 new or added lines in 26 files covered. (67.72%)

17 existing lines in 14 files now uncovered.

8184 of 13977 relevant lines covered (58.55%)

109.83 hits per line

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

48.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

12
namespace sdfg {
13

14
StructuredSDFG::StructuredSDFG(const std::string& name) : Function(name) {
464✔
15
    size_t element_id = 0;
464✔
16
    this->root_ = std::unique_ptr<structured_control_flow::Sequence>(
464✔
17
        new structured_control_flow::Sequence(element_id, DebugInfo()));
464✔
18
};
464✔
19

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

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

24
std::unique_ptr<StructuredSDFG> StructuredSDFG::clone() const {
2✔
25
    builder::StructuredSDFGBuilder builder(this->name_);
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();
×
67
        } else if (auto for_node = dynamic_cast<const structured_control_flow::For*>(current)) {
×
68
            to_visit.insert(&for_node->root());
×
69
        } else if (auto condition_node =
×
70
                       dynamic_cast<const structured_control_flow::IfElse*>(current)) {
×
71
            for (size_t i = 0; i < condition_node->size(); i++) {
×
72
                to_visit.insert(&condition_node->at(i).first);
×
73
            }
×
74
        } else if (auto while_node = dynamic_cast<const structured_control_flow::While*>(current)) {
×
75
            to_visit.insert(&while_node->root());
×
76
        } else if (auto sequence_node =
×
77
                       dynamic_cast<const structured_control_flow::Sequence*>(current)) {
×
78
            for (size_t i = 0; i < sequence_node->size(); i++) {
×
79
                to_visit.insert(&sequence_node->at(i).first);
×
80
            }
×
81
        } else if (auto kernel_node =
×
82
                       dynamic_cast<const structured_control_flow::Kernel*>(current)) {
×
83
            to_visit.insert(&kernel_node->root());
×
84
        } else if (dynamic_cast<const structured_control_flow::Return*>(current)) {
×
85
            continue;
×
NEW
86
        } else if (auto map_node = dynamic_cast<const structured_control_flow::Map*>(current)) {
×
NEW
87
            to_visit.insert(&map_node->root());
×
UNCOV
88
        }
×
89
    }
90
    return count;
×
91
};
×
92

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

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

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

© 2025 Coveralls, Inc