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

daisytuner / sdfglib / 15656007340

14 Jun 2025 08:51PM UTC coverage: 13.234% (-49.9%) from 63.144%
15656007340

Pull #76

github

web-flow
Merge 9586c8161 into 413c53212
Pull Request #76: New Loop Dependency Analysis

361 of 465 new or added lines in 7 files covered. (77.63%)

6215 existing lines in 110 files now uncovered.

1612 of 12181 relevant lines covered (13.23%)

13.64 hits per line

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

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

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

UNCOV
84
void DotVisualizer::visualizeSequence(StructuredSDFG& sdfg,
×
85
                                      structured_control_flow::Sequence& sequence) {
UNCOV
86
    std::string last_comp_name_tmp, last_comp_name_cluster_tmp;
×
UNCOV
87
    for (size_t i = 0; i < sequence.size(); ++i) {
×
88
        std::pair<structured_control_flow::ControlFlowNode&, structured_control_flow::Transition&>
UNCOV
89
            child = sequence.at(i);
×
UNCOV
90
        this->visualizeNode(sdfg, child.first);
×
UNCOV
91
        if ((i > 0) && !last_comp_name_tmp.empty() && !this->last_comp_name_.empty()) {
×
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
        }
×
UNCOV
100
        last_comp_name_tmp = this->last_comp_name_;
×
UNCOV
101
        this->last_comp_name_.clear();
×
UNCOV
102
        last_comp_name_cluster_tmp = this->last_comp_name_cluster_;
×
UNCOV
103
        this->last_comp_name_cluster_.clear();
×
UNCOV
104
    }
×
UNCOV
105
}
×
106

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

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

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