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

daisytuner / sdfglib / 17706131661

13 Sep 2025 08:25PM UTC coverage: 60.51%. Remained the same
17706131661

push

github

web-flow
Merge pull request #226 from daisytuner/infty

uses infty constants and thread-safe rcp pointers

16 of 20 new or added lines in 3 files covered. (80.0%)

1 existing line in 1 file now uncovered.

9445 of 15609 relevant lines covered (60.51%)

106.8 hits per line

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

48.84
/src/symbolic/assumptions.cpp
1
#include "sdfg/symbolic/assumptions.h"
2

3
#include "sdfg/types/scalar.h"
4

5
namespace sdfg {
6
namespace symbolic {
7

8
Assumption::Assumption()
48✔
9
    : symbol_(symbolic::symbol("")), lower_bound_(SymEngine::NegInf), upper_bound_(SymEngine::Inf), constant_(false),
48✔
10
      map_(SymEngine::null) {
48✔
11

12
      };
48✔
13

14
Assumption::Assumption(const Symbol symbol)
966✔
15
    : symbol_(symbol), lower_bound_(SymEngine::NegInf), upper_bound_(SymEngine::Inf), constant_(false),
966✔
16
      map_(SymEngine::null) {
966✔
17

18
      };
966✔
19

20
Assumption::Assumption(const Assumption& a)
7,815✔
21
    : symbol_(a.symbol_), lower_bound_(a.lower_bound_), upper_bound_(a.upper_bound_), constant_(a.constant_),
7,815✔
22
      map_(a.map_) {
7,815✔
23

24
      };
7,815✔
25

26
Assumption& Assumption::operator=(const Assumption& a) {
1,040✔
27
    symbol_ = a.symbol_;
1,040✔
28
    lower_bound_ = a.lower_bound_;
1,040✔
29
    upper_bound_ = a.upper_bound_;
1,040✔
30
    constant_ = a.constant_;
1,040✔
31
    map_ = a.map_;
1,040✔
32
    return *this;
1,040✔
33
};
34

35
const Symbol Assumption::symbol() const { return symbol_; };
2✔
36

37
const Expression Assumption::lower_bound() const { return lower_bound_; };
5,774✔
38

39
void Assumption::lower_bound(const Expression lower_bound) { lower_bound_ = lower_bound; };
2,202✔
40

41
const Expression Assumption::upper_bound() const { return upper_bound_; };
5,080✔
42

43
void Assumption::upper_bound(const Expression upper_bound) { upper_bound_ = upper_bound; };
2,109✔
44

45
bool Assumption::constant() const { return constant_; };
1,959✔
46

47
void Assumption::constant(bool constant) { constant_ = constant; };
1,204✔
48

49
const Expression Assumption::map() const { return map_; };
2,497✔
50

51
void Assumption::map(const Expression map) { map_ = map; };
795✔
52

53
Assumption Assumption::create(const Symbol symbol, const types::IType& type) {
741✔
54
    if (auto scalar_type = dynamic_cast<const types::Scalar*>(&type)) {
741✔
55
        auto assum = Assumption(symbol);
741✔
56

57
        types::PrimitiveType primitive_type = scalar_type->primitive_type();
741✔
58
        switch (primitive_type) {
741✔
59
            case types::PrimitiveType::Bool: {
60
                assum.lower_bound(zero());
2✔
61
                assum.upper_bound(one());
2✔
62
                break;
2✔
63
            }
64
            case types::PrimitiveType::UInt8: {
65
                assum.lower_bound(integer(std::numeric_limits<uint8_t>::min()));
32✔
66
                assum.upper_bound(integer(std::numeric_limits<uint8_t>::max()));
32✔
67
                break;
32✔
68
            }
69
            case types::PrimitiveType::UInt16: {
70
                assum.lower_bound(integer(std::numeric_limits<uint16_t>::min()));
2✔
71
                assum.upper_bound(integer(std::numeric_limits<uint16_t>::max()));
2✔
72
                break;
2✔
73
            }
74
            case types::PrimitiveType::UInt32: {
75
                assum.lower_bound(integer(std::numeric_limits<uint32_t>::min()));
111✔
76
                assum.upper_bound(integer(std::numeric_limits<uint32_t>::max()));
111✔
77
                break;
111✔
78
            }
79
            case types::PrimitiveType::UInt64: {
80
                assum.lower_bound(integer(std::numeric_limits<uint64_t>::min()));
263✔
81
                assum.upper_bound(SymEngine::Inf);
263✔
82
                break;
263✔
83
            }
84
            case types::PrimitiveType::UInt128: {
85
                assum.lower_bound(integer(0));
×
NEW
86
                assum.upper_bound(SymEngine::Inf);
×
87
                break;
×
88
            }
89
            case types::PrimitiveType::Int8: {
90
                assum.lower_bound(integer(std::numeric_limits<int8_t>::min()));
6✔
91
                assum.upper_bound(integer(std::numeric_limits<int8_t>::max()));
6✔
92
                break;
6✔
93
            }
94
            case types::PrimitiveType::Int16: {
95
                assum.lower_bound(integer(std::numeric_limits<int16_t>::min()));
4✔
96
                assum.upper_bound(integer(std::numeric_limits<int16_t>::max()));
4✔
97
                break;
4✔
98
            }
99
            case types::PrimitiveType::Int32: {
100
                assum.lower_bound(integer(std::numeric_limits<int32_t>::min()));
295✔
101
                assum.upper_bound(integer(std::numeric_limits<int32_t>::max()));
295✔
102
                break;
295✔
103
            }
104
            case types::PrimitiveType::Int64: {
105
                assum.lower_bound(SymEngine::NegInf);
26✔
106
                assum.upper_bound(SymEngine::Inf);
26✔
107
                break;
26✔
108
            }
109
            case types::PrimitiveType::Int128: {
NEW
110
                assum.lower_bound(SymEngine::NegInf);
×
NEW
111
                assum.upper_bound(SymEngine::Inf);
×
UNCOV
112
                break;
×
113
            }
114
            default: {
115
                throw std::runtime_error("Unsupported type");
×
116
            }
117
        };
118
        return assum;
741✔
119
    } else {
741✔
120
        throw std::runtime_error("Unsupported type");
×
121
    }
122
};
741✔
123

124
void upper_bounds(const Symbol sym, const Assumptions& assumptions, ExpressionSet& ubs, ExpressionSet& visited) {
×
125
    if (visited.find(sym) != visited.end()) {
×
126
        return;
×
127
    }
128
    visited.insert(sym);
×
129

130
    auto ub = assumptions.at(sym).upper_bound();
×
131
    if (SymEngine::is_a<SymEngine::Integer>(*ub)) {
×
132
        ubs.insert(ub);
×
133
    } else if (SymEngine::is_a<SymEngine::Symbol>(*ub)) {
×
134
        auto ub_sym = SymEngine::rcp_static_cast<const SymEngine::Symbol>(ub);
×
135
        ubs.insert(ub_sym);
×
136

137
        upper_bounds(ub_sym, assumptions, ubs, visited);
×
138
    } else if (SymEngine::is_a<SymEngine::Min>(*ub)) {
×
139
        auto ub_min = SymEngine::rcp_static_cast<const SymEngine::Min>(ub);
×
140
        for (auto& arg : ub_min->get_args()) {
×
141
            if (SymEngine::is_a<SymEngine::Integer>(*ub)) {
×
142
                ubs.insert(ub);
×
143
            } else if (SymEngine::is_a<SymEngine::Symbol>(*ub)) {
×
144
                auto ub_sym = SymEngine::rcp_static_cast<const SymEngine::Symbol>(ub);
×
145
                ubs.insert(ub_sym);
×
146

147
                upper_bounds(ub_sym, assumptions, ubs, visited);
×
148
            } else {
×
149
                ubs.insert(arg);
×
150
            }
151
        }
152
    } else {
×
153
        ubs.insert(ub);
×
154
    }
155
};
×
156

157
void upper_bounds(const Symbol sym, const Assumptions& assumptions, ExpressionSet& ubs) {
×
158
    ExpressionSet visited;
×
159
    upper_bounds(sym, assumptions, ubs, visited);
×
160
};
×
161

162
void lower_bounds(const Symbol sym, const Assumptions& assumptions, ExpressionSet& lbs, ExpressionSet& visited) {
×
163
    if (visited.find(sym) != visited.end()) {
×
164
        return;
×
165
    }
166
    visited.insert(sym);
×
167

168
    auto lb = assumptions.at(sym).lower_bound();
×
169
    if (SymEngine::is_a<SymEngine::Integer>(*lb)) {
×
170
        lbs.insert(lb);
×
171
    } else if (SymEngine::is_a<SymEngine::Symbol>(*lb)) {
×
172
        auto lb_sym = SymEngine::rcp_static_cast<const SymEngine::Symbol>(lb);
×
173
        lbs.insert(lb_sym);
×
174

175
        lower_bounds(lb_sym, assumptions, lbs, visited);
×
176
    } else if (SymEngine::is_a<SymEngine::Max>(*lb)) {
×
177
        auto lb_max = SymEngine::rcp_static_cast<const SymEngine::Max>(lb);
×
178
        for (auto& arg : lb_max->get_args()) {
×
179
            if (SymEngine::is_a<SymEngine::Integer>(*lb)) {
×
180
                lbs.insert(lb);
×
181
            } else if (SymEngine::is_a<SymEngine::Symbol>(*lb)) {
×
182
                auto lb_sym = SymEngine::rcp_static_cast<const SymEngine::Symbol>(lb);
×
183
                lbs.insert(lb_sym);
×
184

185
                lower_bounds(lb_sym, assumptions, lbs, visited);
×
186
            } else {
×
187
                lbs.insert(arg);
×
188
            }
189
        }
190
    } else {
×
191
        lbs.insert(lb);
×
192
    }
193
};
×
194

195
void lower_bounds(const Symbol sym, const Assumptions& assumptions, ExpressionSet& lbs) {
×
196
    ExpressionSet visited;
×
197
    lower_bounds(sym, assumptions, lbs, visited);
×
198
};
×
199

200
} // namespace symbolic
201
} // 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