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

daisytuner / sdfglib / 19137853817

06 Nov 2025 01:50PM UTC coverage: 62.068% (+0.3%) from 61.815%
19137853817

push

github

web-flow
Merge pull request #325 from daisytuner/symbol-promotion-shl

fixes check for shl inputs in symbol promotion

117 of 142 new or added lines in 2 files covered. (82.39%)

14 existing lines in 1 file now uncovered.

10263 of 16535 relevant lines covered (62.07%)

101.72 hits per line

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

79.77
/src/data_flow/tasklet.cpp
1
#include "sdfg/data_flow/tasklet.h"
2

3
#include "sdfg/data_flow/data_flow_graph.h"
4
#include "sdfg/symbolic/symbolic.h"
5

6
namespace sdfg {
7
namespace data_flow {
8

9
Tasklet::Tasklet(
275✔
10
    size_t element_id,
11
    const DebugInfo& debug_info,
12
    const graph::Vertex vertex,
13
    DataFlowGraph& parent,
14
    const TaskletCode code,
15
    const std::string& output,
16
    const std::vector<std::string>& inputs
17
)
18
    : CodeNode(element_id, debug_info, vertex, parent, {output}, inputs), code_(code) {};
275✔
19

20
void Tasklet::validate(const Function& function) const {
204✔
21
    auto& graph = this->get_parent();
204✔
22

23
    // Validate: inputs match arity
24
    if (arity(this->code_) != this->inputs_.size()) {
204✔
25
        throw InvalidSDFGException(
×
26
            "Tasklet: Invalid number of inputs for code " + std::to_string(this->code_) + ": expected " +
×
27
            std::to_string(arity(this->code_)) + ", got " + std::to_string(this->inputs_.size())
×
28
        );
29
    }
30

31
    // Validate: inputs match type of operation
32
    for (auto& iedge : graph.in_edges(*this)) {
512✔
33
        auto& input_type = iedge.result_type(function);
308✔
34
        if (is_integer(this->code_) && !types::is_integer(input_type.primitive_type())) {
308✔
35
            throw InvalidSDFGException("Tasklet: Integer operation with non-integer input type");
×
36
        }
37
        if (is_floating_point(this->code_) && !types::is_floating_point(input_type.primitive_type())) {
308✔
38
            throw InvalidSDFGException("Tasklet: Floating point operation with integer input type");
×
39
        }
40
    }
41

42
    // Validate: Graph - No two access nodes for same data
43
    std::unordered_map<std::string, const AccessNode*> input_names;
204✔
44
    for (auto& iedge : graph.in_edges(*this)) {
512✔
45
        if (dynamic_cast<const ConstantNode*>(&iedge.src()) != nullptr) {
308✔
46
            continue;
89✔
47
        }
48
        auto& src = static_cast<const AccessNode&>(iedge.src());
219✔
49
        if (input_names.find(src.data()) != input_names.end()) {
219✔
50
            if (input_names.at(src.data()) != &src) {
3✔
51
                throw InvalidSDFGException("Tasklet: Two access nodes with the same data as iedge: " + src.data());
×
52
            }
53
        } else {
3✔
54
            input_names.insert({src.data(), &src});
216✔
55
        }
56
    }
57
}
204✔
58

59
TaskletCode Tasklet::code() const { return this->code_; };
194✔
60

61

62
bool Tasklet::is_assign() const { return this->code_ == TaskletCode::assign; }
30✔
63

64
bool Tasklet::is_trivial(const Function& function) const {
1✔
65
    if (!this->is_assign()) {
1✔
NEW
66
        return false;
×
67
    }
68

69
    auto& graph = this->get_parent();
1✔
70
    auto& iedge = *graph.in_edges(*this).begin();
1✔
71
    auto& oedge = *graph.out_edges(*this).begin();
1✔
72
    auto& input_type = iedge.result_type(function);
1✔
73
    auto& output_type = oedge.result_type(function);
1✔
74

75
    return input_type.primitive_type() == output_type.primitive_type();
1✔
76
}
1✔
77

78
bool Tasklet::is_cast(const Function& function) const {
10✔
79
    if (!this->is_assign()) {
10✔
NEW
80
        return false;
×
81
    }
82

83
    auto& graph = this->get_parent();
10✔
84
    auto& iedge = *graph.in_edges(*this).begin();
10✔
85
    auto& oedge = *graph.out_edges(*this).begin();
10✔
86
    auto& input_type = iedge.result_type(function);
10✔
87
    auto& output_type = oedge.result_type(function);
10✔
88

89
    return input_type.primitive_type() != output_type.primitive_type();
10✔
90
}
10✔
91

92
bool Tasklet::is_zext(const Function& function) const {
1✔
93
    if (!this->is_assign()) {
1✔
NEW
94
        return false;
×
95
    }
96

97
    auto& graph = this->get_parent();
1✔
98
    auto& iedge = *graph.in_edges(*this).begin();
1✔
99
    auto& oedge = *graph.out_edges(*this).begin();
1✔
100
    auto& input_type = iedge.result_type(function);
1✔
101
    auto& output_type = oedge.result_type(function);
1✔
102

103
    if (!types::is_unsigned(input_type.primitive_type()) || !types::is_unsigned(output_type.primitive_type())) {
1✔
NEW
104
        return false;
×
105
    }
106
    if (types::bit_width(output_type.primitive_type()) <= types::bit_width(input_type.primitive_type())) {
1✔
NEW
107
        return false;
×
108
    }
109

110
    return true;
1✔
111
}
1✔
112

113
bool Tasklet::is_sext(const Function& function) const {
1✔
114
    if (!this->is_assign()) {
1✔
NEW
115
        return false;
×
116
    }
117

118
    auto& graph = this->get_parent();
1✔
119
    auto& iedge = *graph.in_edges(*this).begin();
1✔
120
    auto& oedge = *graph.out_edges(*this).begin();
1✔
121
    auto& input_type = iedge.result_type(function);
1✔
122
    auto& output_type = oedge.result_type(function);
1✔
123

124
    if (types::is_unsigned(input_type.primitive_type()) || types::is_unsigned(output_type.primitive_type())) {
1✔
NEW
125
        return false;
×
126
    }
127
    if (types::bit_width(output_type.primitive_type()) <= types::bit_width(input_type.primitive_type())) {
1✔
NEW
128
        return false;
×
129
    }
130

131
    return true;
1✔
132
}
1✔
133

134
bool Tasklet::is_trunc(const Function& function) const {
1✔
135
    if (!this->is_assign()) {
1✔
NEW
136
        return false;
×
137
    }
138

139
    auto& graph = this->get_parent();
1✔
140
    auto& iedge = *graph.in_edges(*this).begin();
1✔
141
    auto& oedge = *graph.out_edges(*this).begin();
1✔
142
    auto& input_type = iedge.result_type(function);
1✔
143
    auto& output_type = oedge.result_type(function);
1✔
144

145
    if (types::is_unsigned(input_type.primitive_type()) != types::is_unsigned(output_type.primitive_type())) {
1✔
NEW
146
        return false;
×
147
    }
148
    if (types::bit_width(output_type.primitive_type()) >= types::bit_width(input_type.primitive_type())) {
1✔
NEW
149
        return false;
×
150
    }
151

152
    return true;
1✔
153
}
1✔
154

155
bool Tasklet::is_fptoui(const Function& function) const {
1✔
156
    if (!this->is_assign()) {
1✔
NEW
157
        return false;
×
158
    }
159

160
    auto& graph = this->get_parent();
1✔
161
    auto& iedge = *graph.in_edges(*this).begin();
1✔
162
    auto& oedge = *graph.out_edges(*this).begin();
1✔
163
    auto& input_type = iedge.result_type(function);
1✔
164
    auto& output_type = oedge.result_type(function);
1✔
165

166
    if (!types::is_floating_point(input_type.primitive_type()) || !types::is_unsigned(output_type.primitive_type())) {
1✔
NEW
167
        return false;
×
168
    }
169

170
    return true;
1✔
171
}
1✔
172

173
bool Tasklet::is_fptosi(const Function& function) const {
1✔
174
    if (!this->is_assign()) {
1✔
NEW
175
        return false;
×
176
    }
177

178
    auto& graph = this->get_parent();
1✔
179
    auto& iedge = *graph.in_edges(*this).begin();
1✔
180
    auto& oedge = *graph.out_edges(*this).begin();
1✔
181
    auto& input_type = iedge.result_type(function);
1✔
182
    auto& output_type = oedge.result_type(function);
1✔
183

184
    if (!types::is_floating_point(input_type.primitive_type()) || !types::is_signed(output_type.primitive_type())) {
1✔
NEW
185
        return false;
×
186
    }
187

188
    return true;
1✔
189
}
1✔
190

191
bool Tasklet::is_uitofp(const Function& function) const {
1✔
192
    if (!this->is_assign()) {
1✔
NEW
193
        return false;
×
194
    }
195

196
    auto& graph = this->get_parent();
1✔
197
    auto& iedge = *graph.in_edges(*this).begin();
1✔
198
    auto& oedge = *graph.out_edges(*this).begin();
1✔
199
    auto& input_type = iedge.result_type(function);
1✔
200
    auto& output_type = oedge.result_type(function);
1✔
201

202
    if (!types::is_unsigned(input_type.primitive_type()) || !types::is_floating_point(output_type.primitive_type())) {
1✔
NEW
203
        return false;
×
204
    }
205

206
    return true;
1✔
207
}
1✔
208

209
bool Tasklet::is_sitofp(const Function& function) const {
1✔
210
    if (!this->is_assign()) {
1✔
NEW
211
        return false;
×
212
    }
213

214
    auto& graph = this->get_parent();
1✔
215
    auto& iedge = *graph.in_edges(*this).begin();
1✔
216
    auto& oedge = *graph.out_edges(*this).begin();
1✔
217
    auto& input_type = iedge.result_type(function);
1✔
218
    auto& output_type = oedge.result_type(function);
1✔
219

220
    if (!types::is_signed(input_type.primitive_type()) || !types::is_floating_point(output_type.primitive_type())) {
1✔
NEW
221
        return false;
×
222
    }
223

224
    return true;
1✔
225
}
1✔
226

227
bool Tasklet::is_fpext(const Function& function) const {
1✔
228
    if (!this->is_assign()) {
1✔
NEW
229
        return false;
×
230
    }
231

232
    auto& graph = this->get_parent();
1✔
233
    auto& iedge = *graph.in_edges(*this).begin();
1✔
234
    auto& oedge = *graph.out_edges(*this).begin();
1✔
235
    auto& input_type = iedge.result_type(function);
1✔
236
    auto& output_type = oedge.result_type(function);
1✔
237

238
    if (!types::is_floating_point(input_type.primitive_type()) ||
1✔
239
        !types::is_floating_point(output_type.primitive_type())) {
1✔
NEW
240
        return false;
×
241
    }
242
    if (types::bit_width(output_type.primitive_type()) <= types::bit_width(input_type.primitive_type())) {
1✔
NEW
243
        return false;
×
244
    }
245

246
    return true;
1✔
247
}
1✔
248

249
bool Tasklet::is_fptrunc(const Function& function) const {
1✔
250
    if (!this->is_assign()) {
1✔
NEW
251
        return false;
×
252
    }
253

254
    auto& graph = this->get_parent();
1✔
255
    auto& iedge = *graph.in_edges(*this).begin();
1✔
256
    auto& oedge = *graph.out_edges(*this).begin();
1✔
257
    auto& input_type = iedge.result_type(function);
1✔
258
    auto& output_type = oedge.result_type(function);
1✔
259

260
    if (!types::is_floating_point(input_type.primitive_type()) ||
1✔
261
        !types::is_floating_point(output_type.primitive_type())) {
1✔
NEW
262
        return false;
×
263
    }
264
    if (types::bit_width(output_type.primitive_type()) >= types::bit_width(input_type.primitive_type())) {
1✔
NEW
265
        return false;
×
266
    }
267

268
    return true;
1✔
269
}
1✔
270

271
const std::string& Tasklet::output() const { return this->outputs_[0]; };
54✔
272

273
std::unique_ptr<DataFlowNode> Tasklet::clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph& parent)
×
274
    const {
275
    return std::unique_ptr<Tasklet>(
×
276
        new Tasklet(element_id, this->debug_info_, vertex, parent, this->code_, this->outputs_.at(0), this->inputs_)
×
277
    );
278
};
×
279

280
void Tasklet::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {};
2✔
281

282
} // namespace data_flow
283
} // 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

© 2025 Coveralls, Inc