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

daisytuner / sdfglib / 20603090460

30 Dec 2025 06:20PM UTC coverage: 39.276% (-0.3%) from 39.581%
20603090460

push

github

web-flow
Merge pull request #414 from daisytuner/blas-connectors

renames connectors of blas nodes

14694 of 48687 branches covered (30.18%)

Branch coverage included in aggregate %.

85 of 250 new or added lines in 11 files covered. (34.0%)

18 existing lines in 1 file now uncovered.

12557 of 20696 relevant lines covered (60.67%)

86.4 hits per line

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

22.87
/src/builder/function_builder.cpp
1
#include "sdfg/builder/function_builder.h"
2

3
namespace sdfg {
4
namespace builder {
5

6
void check_name(const std::string& name) {
1,471✔
7
    if (name.find(".") != std::string::npos) {
1,471!
8
        throw InvalidSDFGException("Container name " + name + " contains a dot");
×
9
    } else if (name.find(" ") != std::string::npos) {
1,471!
10
        throw InvalidSDFGException("Container name " + name + " contains a space");
×
11
    } else if (name.find("(") != std::string::npos) {
1,471!
12
        throw InvalidSDFGException("Container name " + name + " contains a parenthesis");
×
13
    } else if (name.find(")") != std::string::npos) {
1,471!
14
        throw InvalidSDFGException("Container name " + name + " contains a parenthesis");
×
15
    } else if (name.find("[") != std::string::npos) {
1,471!
16
        throw InvalidSDFGException("Container name " + name + " contains a bracket");
×
17
    } else if (name.find("]") != std::string::npos) {
1,471!
18
        throw InvalidSDFGException("Container name " + name + " contains a bracket");
×
19
    } else if (name.find("*") != std::string::npos) {
1,471!
20
        throw InvalidSDFGException("Container name " + name + " contains a star");
×
21
    } else if (name.find("&") != std::string::npos) {
1,471!
22
        throw InvalidSDFGException("Container name " + name + " contains a ampersand");
×
23
    } else if (name.find("!") != std::string::npos) {
1,471!
24
        throw InvalidSDFGException("Container name " + name + " contains a bang");
×
25
    } else if (name.find("~") != std::string::npos) {
1,471!
26
        throw InvalidSDFGException("Container name " + name + " contains a tilde");
×
27
    } else if (name.find("`") != std::string::npos) {
1,471!
28
        throw InvalidSDFGException("Container name " + name + " contains a backtick");
×
29
    } else if (name.find("\"") != std::string::npos) {
1,471!
30
        throw InvalidSDFGException("Container name " + name + " contains a quote");
×
31
    } else if (name.find("'") != std::string::npos) {
1,471!
32
        throw InvalidSDFGException("Container name " + name + " contains a single quote");
×
33
    } else if (name.find(";") != std::string::npos) {
1,471!
34
        throw InvalidSDFGException("Container name " + name + " contains a semicolon");
×
35
    } else if (name.find(":") != std::string::npos) {
1,471!
36
        throw InvalidSDFGException("Container name " + name + " contains a colon");
×
37
    } else if (name.find(",") != std::string::npos) {
1,471!
38
        throw InvalidSDFGException("Container name " + name + " contains a comma");
×
39
    } else if (name.find("=") != std::string::npos) {
1,471!
40
        throw InvalidSDFGException("Container name " + name + " contains a equal sign");
×
41
    } else if (name.find("+") != std::string::npos) {
1,471!
42
        throw InvalidSDFGException("Container name " + name + " contains a plus sign");
×
43
    } else if (name.find("-") != std::string::npos) {
1,471!
44
        throw InvalidSDFGException("Container name " + name + " contains a minus sign");
×
45
    } else if (name.find("/") != std::string::npos) {
1,471!
46
        throw InvalidSDFGException("Container name " + name + " contains a slash");
×
47
    } else if (name.find("%") != std::string::npos) {
1,471!
48
        throw InvalidSDFGException("Container name " + name + " contains a percent sign");
×
49
    } else if (name.find("^") != std::string::npos) {
1,471!
50
        throw InvalidSDFGException("Container name " + name + " contains a caret");
×
51
    } else if (name.find("|") != std::string::npos) {
1,471!
52
        throw InvalidSDFGException("Container name " + name + " contains a pipe");
×
53
    }
54
};
1,471✔
55

56
size_t FunctionBuilder::new_element_id() const { return ++this->function().element_counter_; };
7,128✔
57

58
void FunctionBuilder::set_element_counter(size_t element_counter) {
14✔
59
    this->function().element_counter_ = element_counter;
14✔
60
};
14✔
61

62
void FunctionBuilder::set_return_type(const types::IType& type) const { this->function().return_type_ = type.clone(); };
×
63

64
const types::IType& FunctionBuilder::
65
    add_container(const std::string& name, const types::IType& type, bool is_argument, bool is_external) const {
1,462✔
66
    if (is_argument && is_external) {
1,462!
67
        throw InvalidSDFGException("Container " + name + " cannot be both an argument and an external");
×
68
    }
69
    // Legal name
70
    check_name(name);
1,462✔
71

72
    auto res = this->function().containers_.insert({name, type.clone()});
1,462!
73
    if (!res.second) {
1,462!
NEW
74
        throw InvalidSDFGException("Container " + name + " already exists");
×
75
    }
76

77
    if (is_argument) {
1,462✔
78
        this->function().arguments_.push_back(name);
399✔
79
    }
399✔
80
    if (is_external) {
1,462✔
81
        this->function().externals_.push_back(name);
10✔
82
        this->function().externals_linkage_types_[name] = LinkageType_External;
10✔
83
    }
10✔
84
    if (type.is_symbol()) {
1,462✔
85
        auto sym = symbolic::symbol(name);
1,260✔
86
        this->function().assumptions_.insert({sym, symbolic::Assumption::create(sym, type)});
1,260!
87
    }
1,260✔
88

89
    return *(*res.first).second;
1,462✔
90
};
×
91

92
const types::IType& FunctionBuilder::
93
    add_external(const std::string& name, const types::IType& type, LinkageType linkage_type) const {
9✔
94
    check_name(name);
9✔
95

96
    auto res = this->function().containers_.insert({name, type.clone()});
9!
97
    if (!res.second) {
9!
NEW
98
        throw InvalidSDFGException("Container " + name + " already exists");
×
99
    }
100

101
    this->function().externals_.push_back(name);
9✔
102
    this->function().externals_linkage_types_[name] = linkage_type;
9✔
103

104
    return *(*res.first).second;
9✔
105
};
×
106

107
void FunctionBuilder::remove_container(const std::string& name) const {
6✔
108
    auto& function = this->function();
6✔
109
    if (!function.is_transient(name)) {
6✔
110
        throw InvalidSDFGException("Container " + name + " is not transient");
2!
111
    }
112
    if (this->function().containers_.find(name) == this->function().containers_.end()) {
4!
113
        throw InvalidSDFGException("Container " + name + " does not exist");
×
114
    }
115

116
    auto& type = function.containers_[name];
4✔
117
    if (type->is_symbol() && dynamic_cast<const types::Scalar*>(type.get())) {
4!
118
        function.assumptions_.erase(symbolic::symbol(name));
4!
119
    }
4✔
120

121
    function.containers_.erase(name);
4✔
122
};
6✔
123

124
void FunctionBuilder::rename_container(const std::string& old_name, const std::string& new_name) const {
×
125
    auto& function = this->function();
×
126
    if (!function.exists(old_name)) {
×
127
        throw InvalidSDFGException("Container " + old_name + " does not exist");
×
128
    }
129

130
    // Move type
131
    function.containers_[new_name] = std::move(function.containers_[old_name]);
×
132
    function.containers_.erase(old_name);
×
133

134
    // Handling of argument
135
    if (function.is_argument(old_name)) {
×
136
        auto it = std::find(function.arguments_.begin(), function.arguments_.end(), old_name);
×
137
        assert(it != function.arguments_.end());
×
138
        *it = new_name;
×
139
    }
×
140
    // Handling of external
141
    if (function.is_external(old_name)) {
×
142
        auto it = std::find(function.externals_.begin(), function.externals_.end(), old_name);
×
143
        assert(it != function.externals_.end());
×
144
        *it = new_name;
×
145
        function.externals_linkage_types_[new_name] = function.externals_linkage_types_[old_name];
×
146
        function.externals_linkage_types_.erase(old_name);
×
147
    }
×
148
    // Handling of assumption
149
    if (function.assumptions().find(symbolic::symbol(old_name)) != function.assumptions().end()) {
×
150
        auto assumption = function.assumption(symbolic::symbol(old_name));
×
151

152
        symbolic::Assumption new_assumption(symbolic::symbol(new_name));
×
153
        new_assumption.lower_bound_deprecated(assumption.lower_bound_deprecated());
×
154
        new_assumption.upper_bound_deprecated(assumption.upper_bound_deprecated());
×
155
        new_assumption.tight_lower_bound(assumption.tight_lower_bound());
×
156
        new_assumption.tight_upper_bound(assumption.tight_upper_bound());
×
157
        for (auto& lb : assumption.lower_bounds()) {
×
158
            new_assumption.add_lower_bound(lb);
×
159
        }
160
        for (auto& ub : assumption.upper_bounds()) {
×
161
            new_assumption.add_upper_bound(ub);
×
162
        }
163

164
        new_assumption.constant(assumption.constant());
×
165
        new_assumption.map(assumption.map());
×
166

167
        function.assumptions_.erase(symbolic::symbol(old_name));
×
168
        function.assumptions_.insert({new_assumption.symbol(), new_assumption});
×
169
    }
×
170
};
×
171

172
void FunctionBuilder::change_type(const std::string& name, const types::IType& type) const {
14✔
173
    auto& function = this->function();
14✔
174
    if (function.containers_.find(name) == function.containers_.end()) {
14!
175
        throw InvalidSDFGException("Container " + name + " does not exist");
×
176
    }
177

178
    function.containers_[name] = type.clone();
14!
179
};
14✔
180

181
types::StructureDefinition& FunctionBuilder::add_structure(const std::string& name, bool is_packed) const {
20✔
182
    if (this->function().structures_.find(name) != this->function().structures_.end()) {
20!
183
        throw InvalidSDFGException("Structure " + name + " already exists");
×
184
    }
185

186
    auto res = this->function().structures_.insert({name, std::make_unique<types::StructureDefinition>(name, is_packed)}
20!
187
    );
188
    if (!res.second) {
20!
NEW
189
        throw InvalidSDFGException("Structure " + name + " already exists");
×
190
    }
191

192
    return *(*res.first).second;
20✔
193
};
×
194

195
std::string FunctionBuilder::find_new_name(std::string prefix) const {
189✔
196
    size_t i = 0;
189✔
197
    std::string new_name = prefix + std::to_string(i);
189!
198
    while (this->function().exists(new_name)) {
341!
199
        i++;
152✔
200
        new_name = prefix + std::to_string(i);
152!
201
    }
202
    return new_name;
189✔
203
};
189!
204

205
void FunctionBuilder::update_tasklet(data_flow::Tasklet& tasklet, const data_flow::TaskletCode code) {
×
206
    tasklet.code_ = code;
×
207
}
×
208

209
std::unique_ptr<types::Structure> FunctionBuilder::
210
    create_vector_type(const types::Scalar& element_type, size_t vector_size) {
×
211
    std::string struct_name = "__daisy_vec_" + std::to_string(element_type.primitive_type()) + "_" +
×
212
                              std::to_string(vector_size);
×
213
    auto defined_structures = this->function().structures();
×
214
    if (std::find(defined_structures.begin(), defined_structures.end(), struct_name) != defined_structures.end()) {
×
215
        return std::make_unique<types::Structure>(struct_name);
×
216
    }
217

218
    auto& struct_def = this->add_structure(struct_name, true);
×
219
    for (size_t i = 0; i < vector_size; i++) {
×
220
        struct_def.add_member(element_type);
×
221
    }
×
222

223
    return std::make_unique<types::Structure>(struct_name);
×
224
}
×
225

226
} // namespace builder
227
} // 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