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

daisytuner / sdfglib / 15704003944

17 Jun 2025 09:51AM UTC coverage: 64.576% (-0.4%) from 64.973%
15704003944

push

github

web-flow
Merge pull request #84 from daisytuner/element-ids

Use counter-based element ids

196 of 215 new or added lines in 29 files covered. (91.16%)

58 existing lines in 5 files now uncovered.

8041 of 12452 relevant lines covered (64.58%)

117.69 hits per line

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

63.58
/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✔
UNCOV
22
        this->stream_ << block.element_id() << " [shape=point,style=invis,label=\"\"];"
×
UNCOV
23
                      << std::endl;
×
UNCOV
24
        this->stream_.setIndent(this->stream_.indent() - 4);
×
UNCOV
25
        this->stream_ << "}" << std::endl;
×
UNCOV
26
        this->last_comp_name_ = block.element_id();
×
UNCOV
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
            this->visualizeLibraryNode(libnode->code());
×
76
            this->stream_ << "\"];" << std::endl;
×
77
            if (this->last_comp_name_.empty()) this->last_comp_name_ = libnode->element_id();
×
78
        }
×
79
    }
80
    this->stream_.setIndent(this->stream_.indent() - 4);
168✔
81
    this->stream_ << "}" << std::endl;
168✔
82
}
168✔
83

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

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

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

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

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

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

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

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

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