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

daisytuner / sdfglib / 15827874660

23 Jun 2025 03:03PM UTC coverage: 64.193% (+0.4%) from 63.824%
15827874660

push

github

web-flow
Merge pull request #100 from daisytuner/transformations

new definition of map and adapts transformations

148 of 194 new or added lines in 13 files covered. (76.29%)

45 existing lines in 4 files now uncovered.

8193 of 12763 relevant lines covered (64.19%)

136.04 hits per line

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

63.95
/src/visualizer/dot_visualizer.cpp
1
#include "sdfg/visualizer/dot_visualizer.h"
2

3
#include <cstddef>
4
#include <string>
5
#include <utility>
6

7
#include "sdfg/data_flow/access_node.h"
8
#include "sdfg/data_flow/memlet.h"
9
#include "sdfg/structured_control_flow/control_flow_node.h"
10
#include "sdfg/structured_control_flow/sequence.h"
11
#include "sdfg/structured_sdfg.h"
12

13
namespace sdfg {
14
namespace visualizer {
15

16
void DotVisualizer::visualizeBlock(StructuredSDFG& sdfg, structured_control_flow::Block& block) {
168✔
17
    this->stream_ << "subgraph cluster_" << block.element_id() << " {" << std::endl;
168✔
18
    this->stream_.setIndent(this->stream_.indent() + 4);
168✔
19
    this->stream_ << "style=filled;shape=box;fillcolor=white;color=black;label=\"\";" << std::endl;
168✔
20
    this->last_comp_name_cluster_ = "cluster_" + std::to_string(block.element_id());
168✔
21
    if (block.dataflow().nodes().empty()) {
168✔
22
        this->stream_ << block.element_id() << " [shape=point,style=invis,label=\"\"];"
×
23
                      << std::endl;
×
24
        this->stream_.setIndent(this->stream_.indent() - 4);
×
25
        this->stream_ << "}" << std::endl;
×
26
        this->last_comp_name_ = block.element_id();
×
27
        return;
×
28
    }
29
    this->last_comp_name_.clear();
168✔
30
    std::list<data_flow::DataFlowNode*> nodes = block.dataflow().topological_sort();
168✔
31
    for (data_flow::DataFlowNode* node : nodes) {
510✔
32
        if (const data_flow::Tasklet* tasklet = dynamic_cast<data_flow::Tasklet*>(node)) {
342✔
33
            this->stream_ << tasklet->element_id() << " [shape=octagon,label=\""
169✔
34
                          << tasklet->output().first << " = ";
169✔
35
            this->visualizeTasklet(*tasklet);
169✔
36
            this->stream_ << "\"];" << std::endl;
169✔
37
            for (data_flow::Memlet& iedge : block.dataflow().in_edges(*tasklet)) {
174✔
38
                data_flow::AccessNode const& src =
5✔
39
                    dynamic_cast<data_flow::AccessNode const&>(iedge.src());
5✔
40
                this->stream_ << src.element_id() << " -> " << tasklet->element_id()
5✔
41
                              << " [label=\"   " << iedge.dst_conn() << " = " << src.data();
5✔
42
                if (!symbolic::is_nv(symbolic::symbol(src.data()))) {
5✔
43
                    types::IType const& type = sdfg.type(src.data());
5✔
44
                    this->visualizeSubset(sdfg, type, iedge.subset());
5✔
45
                }
5✔
46
                this->stream_ << "   \"];" << std::endl;
5✔
47
            }
48
            for (data_flow::Memlet& oedge : block.dataflow().out_edges(*tasklet)) {
338✔
49
                data_flow::AccessNode const& dst =
169✔
50
                    dynamic_cast<data_flow::AccessNode const&>(oedge.dst());
169✔
51
                types::IType const& type = sdfg.type(dst.data());
169✔
52
                this->stream_ << tasklet->element_id() << " -> " << dst.element_id()
169✔
53
                              << " [label=\"   " << dst.data();
169✔
54
                this->visualizeSubset(sdfg, type, oedge.subset());
169✔
55
                this->stream_ << " = " << oedge.src_conn() << "   \"];" << std::endl;
169✔
56
            }
57
            if (this->last_comp_name_.empty()) this->last_comp_name_ = tasklet->element_id();
169✔
58
        } else if (const data_flow::AccessNode* access_node =
342✔
59
                       dynamic_cast<data_flow::AccessNode*>(node)) {
173✔
60
            bool source = false, sink = false;
173✔
61
            for (data_flow::Memlet& edge : block.dataflow().out_edges(*access_node)) {
173✔
62
                if ((source = (edge.src_conn() == "void"))) break;
5✔
63
            }
64
            for (data_flow::Memlet& edge : block.dataflow().in_edges(*access_node)) {
173✔
65
                if ((sink = (edge.dst_conn() == "void"))) break;
169✔
66
            }
67
            if (!source && !sink) continue;
173✔
68
            this->stream_ << access_node->element_id() << " [";
173✔
69
            if (!sdfg.is_internal(access_node->data())) this->stream_ << "penwidth=3.0,";
173✔
70
            if (sdfg.is_transient(access_node->data())) this->stream_ << "style=\"dashed,filled\",";
173✔
71
            this->stream_ << "label=\"" << access_node->data() << "\"];" << std::endl;
173✔
72
        } else if (const data_flow::LibraryNode* libnode =
173✔
73
                       dynamic_cast<data_flow::LibraryNode*>(node)) {
×
74
            this->stream_ << libnode->element_id() << " [shape=doubleoctagon,label=\""
×
75
                          << libnode->toStr() << "\"];" << std::endl;
×
76
            if (this->last_comp_name_.empty()) this->last_comp_name_ = libnode->element_id();
×
77
        }
×
78
    }
79
    this->stream_.setIndent(this->stream_.indent() - 4);
168✔
80
    this->stream_ << "}" << std::endl;
168✔
81
}
168✔
82

83
void DotVisualizer::visualizeSequence(StructuredSDFG& sdfg,
171✔
84
                                      structured_control_flow::Sequence& sequence) {
85
    std::string last_comp_name_tmp, last_comp_name_cluster_tmp;
171✔
86
    for (size_t i = 0; i < sequence.size(); ++i) {
342✔
87
        std::pair<structured_control_flow::ControlFlowNode&, structured_control_flow::Transition&>
88
            child = sequence.at(i);
171✔
89
        this->visualizeNode(sdfg, child.first);
171✔
90
        if ((i > 0) && !last_comp_name_tmp.empty() && !this->last_comp_name_.empty()) {
171✔
91
            this->stream_ << last_comp_name_tmp << " -> " << this->last_comp_name_ << " [";
×
92
            if (!last_comp_name_cluster_tmp.empty())
×
93
                this->stream_ << "ltail=\"" << last_comp_name_cluster_tmp << "\",";
×
94
            if (!this->last_comp_name_cluster_.empty())
×
95
                this->stream_ << "lhead=\"" << this->last_comp_name_cluster_ << "\",";
×
96
            this->stream_ << "minlen=3]"
×
97
                          << ";" << std::endl;
×
98
        }
×
99
        last_comp_name_tmp = this->last_comp_name_;
171✔
100
        this->last_comp_name_.clear();
171✔
101
        last_comp_name_cluster_tmp = this->last_comp_name_cluster_;
171✔
102
        this->last_comp_name_cluster_.clear();
171✔
103
    }
171✔
104
}
171✔
105

106
void DotVisualizer::visualizeIfElse(StructuredSDFG& sdfg,
1✔
107
                                    structured_control_flow::IfElse& if_else) {
108
    this->stream_ << "subgraph cluster_" << if_else.element_id() << " {" << std::endl;
1✔
109
    this->stream_.setIndent(this->stream_.indent() + 4);
1✔
110
    this->stream_ << "style=filled;shape=box;fillcolor=white;color=black;label=\"if:\";"
1✔
111
                  << std::endl
1✔
112
                  << if_else.element_id() << " [shape=point,style=invis,label=\"\"];" << std::endl;
1✔
113
    for (size_t i = 0; i < if_else.size(); ++i) {
3✔
114
        this->stream_ << "subgraph cluster_" << if_else.element_id() << "_" << std::to_string(i)
4✔
115
                      << " {" << std::endl;
2✔
116
        this->stream_.setIndent(this->stream_.indent() + 4);
2✔
117
        this->stream_ << "style=filled;shape=box;fillcolor=white;color=black;label=\""
4✔
118
                      << this->expression(if_else.at(i).second->__str__()) << "\";" << std::endl;
2✔
119
        this->visualizeSequence(sdfg, if_else.at(i).first);
2✔
120
        this->stream_.setIndent(this->stream_.indent() - 4);
2✔
121
        this->stream_ << "}" << std::endl;
2✔
122
    }
2✔
123
    this->stream_.setIndent(this->stream_.indent() - 4);
1✔
124
    this->stream_ << "}" << std::endl;
1✔
125
    this->last_comp_name_ = if_else.element_id();
1✔
126
    this->last_comp_name_cluster_ = "cluster_" + std::to_string(if_else.element_id());
1✔
127
}
1✔
128

129
void DotVisualizer::visualizeWhile(StructuredSDFG& sdfg,
×
130
                                   structured_control_flow::While& while_loop) {
131
    this->stream_ << "subgraph cluster_" << while_loop.element_id() << " {" << std::endl;
×
132
    this->stream_.setIndent(this->stream_.indent() + 4);
×
133
    this->stream_ << "style=filled;shape=box;fillcolor=white;color=black;label=\"while:\";"
×
134
                  << std::endl
×
135
                  << while_loop.element_id() << " [shape=point,style=invis,label=\"\"];"
×
136
                  << std::endl;
×
137
    this->visualizeSequence(sdfg, while_loop.root());
×
138
    this->stream_.setIndent(this->stream_.indent() - 4);
×
139
    this->stream_ << "}" << std::endl;
×
140
    this->last_comp_name_ = while_loop.element_id();
×
141
    this->last_comp_name_cluster_ = "cluster_" + std::to_string(while_loop.element_id());
×
142
}
×
143

144
void DotVisualizer::visualizeFor(StructuredSDFG& sdfg, structured_control_flow::For& loop) {
2✔
145
    this->stream_ << "subgraph cluster_" << loop.element_id() << " {" << std::endl;
2✔
146
    this->stream_.setIndent(this->stream_.indent() + 4);
2✔
147
    this->stream_ << "style=filled;shape=box;fillcolor=white;color=black;label=\"for: ";
2✔
148
    this->visualizeForBounds(loop.indvar(), loop.init(), loop.condition(), loop.update());
2✔
149
    this->stream_ << "\";" << std::endl
2✔
150
                  << loop.element_id() << " [shape=point,style=invis,label=\"\"];" << std::endl;
2✔
151
    this->visualizeSequence(sdfg, loop.root());
2✔
152
    this->stream_.setIndent(this->stream_.indent() - 4);
2✔
153
    this->stream_ << "}" << std::endl;
2✔
154
    this->last_comp_name_ = loop.element_id();
2✔
155
    this->last_comp_name_cluster_ = "cluster_" + std::to_string(loop.element_id());
2✔
156
}
2✔
157

158
void DotVisualizer::visualizeReturn(StructuredSDFG& sdfg,
×
159
                                    structured_control_flow::Return& return_node) {
160
    this->stream_ << return_node.element_id() << " [shape=cds,label=\" return  \"];" << std::endl;
×
161
    this->last_comp_name_ = return_node.element_id();
×
162
    this->last_comp_name_cluster_.clear();
×
163
}
×
164
void DotVisualizer::visualizeBreak(StructuredSDFG& sdfg,
×
165
                                   structured_control_flow::Break& break_node) {
166
    this->stream_ << break_node.element_id() << " [shape=cds,label=\" break  \"];" << std::endl;
×
167
    this->last_comp_name_ = break_node.element_id();
×
168
    this->last_comp_name_cluster_.clear();
×
169
}
×
170

171
void DotVisualizer::visualizeContinue(StructuredSDFG& sdfg,
×
172
                                      structured_control_flow::Continue& continue_node) {
173
    this->stream_ << continue_node.element_id() << " [shape=cds,label=\" continue  \"];"
×
174
                  << std::endl;
×
175
    this->last_comp_name_ = continue_node.element_id();
×
176
    this->last_comp_name_cluster_.clear();
×
177
}
×
178

179
void DotVisualizer::visualizeMap(StructuredSDFG& sdfg, structured_control_flow::Map& map_node) {
×
180
    this->stream_ << "subgraph cluster_" << map_node.element_id() << " {" << std::endl;
×
181
    this->stream_.setIndent(this->stream_.indent() + 4);
×
182
    this->stream_ << "style=filled;shape=box;fillcolor=white;color=black;label=\"map: ";
×
NEW
183
    this->visualizeForBounds(map_node.indvar(), map_node.init(), map_node.condition(),
×
NEW
184
                             map_node.update());
×
185
    this->stream_ << "\";" << std::endl
×
186
                  << map_node.element_id() << " [shape=point,style=invis,label=\"\"];" << std::endl;
×
187
    this->visualizeSequence(sdfg, map_node.root());
×
188
    this->stream_.setIndent(this->stream_.indent() - 4);
×
189
    this->stream_ << "}" << std::endl;
×
190
    this->last_comp_name_ = map_node.element_id();
×
191
    this->last_comp_name_cluster_ = "cluster_" + std::to_string(map_node.element_id());
×
192
}
×
193

194
void DotVisualizer::visualize() {
167✔
195
    this->stream_.clear();
167✔
196
    this->stream_ << "digraph " << this->sdfg_.name() << " {" << std::endl;
167✔
197
    this->stream_.setIndent(4);
167✔
198
    this->stream_ << "graph [compound=true];" << std::endl;
167✔
199
    this->stream_ << "subgraph cluster_" << this->sdfg_.name() << " {" << std::endl;
167✔
200
    this->stream_.setIndent(8);
167✔
201
    this->stream_ << "node [style=filled,fillcolor=white];" << std::endl
167✔
202
                  << "style=filled;color=lightblue;label=\"\";" << std::endl;
167✔
203
    this->visualizeSequence(this->sdfg_, this->sdfg_.root());
167✔
204
    this->stream_.setIndent(4);
167✔
205
    this->stream_ << "}" << std::endl;
167✔
206
    this->stream_.setIndent(0);
167✔
207
    this->stream_ << "}" << std::endl;
167✔
208
}
167✔
209

210
}  // namespace visualizer
211
}  // 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