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

daisytuner / sdfglib / 15262928007

26 May 2025 10:36PM UTC coverage: 58.284% (-2.0%) from 60.304%
15262928007

push

github

web-flow
Merge pull request #36 from daisytuner/sdfg-validation

Introduces new definition of memlets plus sanity checks

104 of 266 new or added lines in 6 files covered. (39.1%)

241 existing lines in 15 files now uncovered.

7908 of 13568 relevant lines covered (58.28%)

96.1 hits per line

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

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

3
namespace sdfg {
4
namespace builder {
5

6
FunctionBuilder::FunctionBuilder() : element_counter_(1) {};
803✔
7

8
const types::IType& FunctionBuilder::add_container(const std::string& name,
805✔
9
                                                   const types::IType& type, bool is_argument,
10
                                                   bool is_external) const {
11
    if (is_argument && is_external) {
805✔
NEW
12
        throw InvalidSDFGException("Container " + name +
×
13
                                   " cannot be both an argument and an external");
14
    }
15

16
    auto res = this->function().containers_.insert({name, type.clone()});
805✔
17
    assert(res.second);
805✔
18

19
    if (is_argument) {
805✔
20
        this->function().arguments_.push_back(name);
205✔
21
    }
205✔
22
    if (is_external) {
805✔
23
        this->function().externals_.push_back(name);
11✔
24
    }
11✔
25
    if (type.is_symbol() && dynamic_cast<const types::Scalar*>(&type)) {
805✔
26
        auto sym = symbolic::symbol(name);
625✔
27
        this->function().assumptions_.insert({sym, symbolic::Assumption::create(sym, type)});
625✔
28
    }
625✔
29

30
    return *(*res.first).second;
805✔
31
};
×
32

33
void FunctionBuilder::remove_container(const std::string& name) const {
6✔
34
    auto& function = this->function();
6✔
35
    if (!function.is_transient(name)) {
6✔
36
        throw InvalidSDFGException("Container " + name + " is not transient");
2✔
37
    }
38
    if (this->function().containers_.find(name) == this->function().containers_.end()) {
4✔
NEW
39
        throw InvalidSDFGException("Container " + name + " does not exist");
×
40
    }
41

42
    auto& type = function.containers_[name];
4✔
43
    if (type->is_symbol() && dynamic_cast<const types::Scalar*>(type.get())) {
4✔
44
        function.assumptions_.erase(symbolic::symbol(name));
4✔
45
    }
4✔
46

47
    function.containers_.erase(name);
4✔
48
};
6✔
49

50
void FunctionBuilder::change_type(const std::string& name, const types::IType& type) const {
9✔
51
    auto& function = this->function();
9✔
52
    if (!function.is_transient(name)) {
9✔
NEW
53
        throw InvalidSDFGException("Container " + name + " is not transient");
×
54
    }
55
    if (function.containers_.find(name) == function.containers_.end()) {
9✔
NEW
56
        throw InvalidSDFGException("Container " + name + " does not exist");
×
57
    }
58

59
    function.containers_[name] = type.clone();
9✔
60
};
9✔
61

62
types::StructureDefinition& FunctionBuilder::add_structure(const std::string& name,
20✔
63
                                                           bool is_packed) const {
64
    if (this->function().structures_.find(name) != this->function().structures_.end()) {
20✔
NEW
65
        throw InvalidSDFGException("Structure " + name + " already exists");
×
66
    }
67

68
    auto res = this->function().structures_.insert(
20✔
69
        {name, std::make_unique<types::StructureDefinition>(name, is_packed)});
20✔
70
    assert(res.second);
20✔
71

72
    return *(*res.first).second;
20✔
73
};
×
74

75
void FunctionBuilder::make_array(const std::string& name, const symbolic::Expression& size) const {
2✔
76
    auto& function = this->function();
2✔
77
    if (!function.is_transient(name)) {
2✔
78
        throw InvalidSDFGException("Container " + name + " is not transient");
1✔
79
    }
80
    if (function.containers_.find(name) == function.containers_.end()) {
1✔
NEW
81
        throw InvalidSDFGException("Container " + name + " does not exist");
×
82
    }
83

84
    auto& old_type = function.containers_[name];
1✔
85
    if (old_type->is_symbol() && dynamic_cast<const types::Scalar*>(old_type.get())) {
1✔
86
        function.assumptions_.erase(symbolic::symbol(name));
1✔
87
    }
1✔
88

89
    function.containers_[name] = std::make_unique<types::Array>(*old_type, size);
1✔
90
};
2✔
91

92
std::string FunctionBuilder::find_new_name(std::string prefix) const {
4✔
93
    size_t i = 0;
4✔
94
    std::string new_name = prefix + std::to_string(i);
4✔
95
    while (this->function().exists(new_name)) {
4✔
96
        i++;
×
97
        new_name = prefix + std::to_string(i);
×
98
    }
99
    return new_name;
4✔
100
};
4✔
101

102
}  // namespace builder
103
}  // 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