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

daisytuner / sdfglib / 15512392058

07 Jun 2025 10:47PM UTC coverage: 62.261% (+4.8%) from 57.416%
15512392058

push

github

web-flow
Merge pull request #63 from daisytuner/schedules

Schedules

152 of 194 new or added lines in 24 files covered. (78.35%)

39 existing lines in 7 files now uncovered.

7467 of 11993 relevant lines covered (62.26%)

127.08 hits per line

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

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

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

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

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

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

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

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

NEW
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;
×
NEW
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

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