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

daisytuner / sdfglib / 19406662809

16 Nov 2025 01:54PM UTC coverage: 62.092% (-0.4%) from 62.447%
19406662809

push

github

web-flow
Merge pull request #347 from daisytuner/symbolic-range-analysis

extends symbol promotion with checks for effective range of scalars

174 of 355 new or added lines in 10 files covered. (49.01%)

13 existing lines in 4 files now uncovered.

11048 of 17793 relevant lines covered (62.09%)

112.56 hits per line

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

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

56
size_t FunctionBuilder::new_element_id() const { return ++this->function().element_counter_; };
4,683✔
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,085✔
66
    if (is_argument && is_external) {
1,085✔
67
        throw InvalidSDFGException("Container " + name + " cannot be both an argument and an external");
×
68
    }
69
    // Legal name
70
    check_name(name);
1,085✔
71

72
    auto res = this->function().containers_.insert({name, type.clone()});
1,085✔
73
    assert(res.second);
1,085✔
74

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

87
    return *(*res.first).second;
1,085✔
88
};
×
89

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

94
    auto res = this->function().containers_.insert({name, type.clone()});
9✔
95
    assert(res.second);
9✔
96

97
    this->function().externals_.push_back(name);
9✔
98
    this->function().externals_linkage_types_[name] = linkage_type;
9✔
99

100
    return *(*res.first).second;
9✔
101
};
×
102

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

112
    auto& type = function.containers_[name];
4✔
113
    if (type->is_symbol() && dynamic_cast<const types::Scalar*>(type.get())) {
4✔
114
        function.assumptions_.erase(symbolic::symbol(name));
4✔
115
    }
4✔
116

117
    function.containers_.erase(name);
4✔
118
};
6✔
119

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

126
    // Move type
127
    function.containers_[new_name] = std::move(function.containers_[old_name]);
×
128
    function.containers_.erase(old_name);
×
129

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

148
        symbolic::Assumption new_assumption(symbolic::symbol(new_name));
×
149
        new_assumption.lower_bound_deprecated(assumption.lower_bound_deprecated());
×
150
        new_assumption.upper_bound_deprecated(assumption.upper_bound_deprecated());
×
NEW
151
        new_assumption.tight_lower_bound(assumption.tight_lower_bound());
×
NEW
152
        new_assumption.tight_upper_bound(assumption.tight_upper_bound());
×
NEW
153
        for (auto& lb : assumption.lower_bounds()) {
×
NEW
154
            new_assumption.add_lower_bound(lb);
×
155
        }
NEW
156
        for (auto& ub : assumption.upper_bounds()) {
×
NEW
157
            new_assumption.add_upper_bound(ub);
×
158
        }
159

160
        new_assumption.constant(assumption.constant());
×
161
        new_assumption.map(assumption.map());
×
162

163
        function.assumptions_.erase(symbolic::symbol(old_name));
×
164
        function.assumptions_.insert({new_assumption.symbol(), new_assumption});
×
165
    }
×
166
};
×
167

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

174
    function.containers_[name] = type.clone();
14✔
175
};
14✔
176

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

182
    auto res = this->function().structures_.insert({name, std::make_unique<types::StructureDefinition>(name, is_packed)}
20✔
183
    );
184
    assert(res.second);
20✔
185

186
    return *(*res.first).second;
20✔
187
};
×
188

189
std::string FunctionBuilder::find_new_name(std::string prefix) const {
18✔
190
    size_t i = 0;
18✔
191
    std::string new_name = prefix + std::to_string(i);
18✔
192
    while (this->function().exists(new_name)) {
18✔
193
        i++;
×
194
        new_name = prefix + std::to_string(i);
×
195
    }
196
    return new_name;
18✔
197
};
18✔
198

199
void FunctionBuilder::update_tasklet(data_flow::Tasklet& tasklet, const data_flow::TaskletCode code) {
×
200
    tasklet.code_ = code;
×
201
}
×
202

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

212
    auto& struct_def = this->add_structure(struct_name, true);
×
213
    for (size_t i = 0; i < vector_size; i++) {
×
214
        struct_def.add_member(element_type);
×
215
    }
×
216

217
    return std::make_unique<types::Structure>(struct_name);
×
218
}
×
219

220
} // namespace builder
221
} // 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