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

daisytuner / docc / 31009380971

05 Aug 2026 01:15PM UTC coverage: 65.103% (+0.1%) from 65.005%
31009380971

Pull #814

github

web-flow
Merge 268a080ae into 7d5b198bd
Pull Request #814: Adds GPU reduce dispatchers

409 of 663 new or added lines in 18 files covered. (61.69%)

145 existing lines in 6 files now uncovered.

46693 of 71722 relevant lines covered (65.1%)

713.1 hits per line

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

50.82
/sdfg/src/structured_control_flow/reduce.cpp
1
#include "sdfg/structured_control_flow/reduce.h"
2

3
#include <string>
4

5
#include "sdfg/exceptions.h"
6
#include "sdfg/structured_control_flow/structured_loop.h"
7
#include "sdfg/visitor/structured_sdfg_visitor.h"
8

9
namespace sdfg {
10
namespace structured_control_flow {
11

12
std::string reduction_operation_to_string(ReductionOperation op) {
3✔
13
    switch (op) {
3✔
14
        case ReductionOperation::Add:
2✔
15
            return "add";
2✔
16
        case ReductionOperation::Mul:
×
17
            return "mul";
×
18
        case ReductionOperation::Min:
×
19
            return "min";
×
20
        case ReductionOperation::Max:
1✔
21
            return "max";
1✔
22
    }
3✔
23
    throw InvalidSDFGException("Reduce: unknown reduction operation");
×
24
}
3✔
25

26
ReductionOperation reduction_operation_from_string(const std::string& value) {
1✔
27
    if (value == "add") {
1✔
28
        return ReductionOperation::Add;
×
29
    } else if (value == "mul") {
1✔
30
        return ReductionOperation::Mul;
×
31
    } else if (value == "min") {
1✔
32
        return ReductionOperation::Min;
×
33
    } else if (value == "max") {
1✔
34
        return ReductionOperation::Max;
1✔
35
    }
1✔
36
    throw InvalidSDFGException("Reduce: unknown reduction operation '" + value + "'");
×
37
}
1✔
38

39
Reduce::Reduce(
40
    size_t element_id,
41
    const DebugInfo& debug_info,
42
    ControlFlowNode* parent,
43
    symbolic::Symbol indvar,
44
    symbolic::Expression init,
45
    symbolic::Expression update,
46
    symbolic::Condition condition,
47
    std::vector<ReductionInfo> reductions,
48
    const ScheduleType& schedule_type
49
)
50
    : StructuredLoop(element_id, debug_info, parent, indvar, init, update, condition, schedule_type),
81✔
51
      reductions_(std::move(reductions)) {};
81✔
52

53
bool Reduce::accept(visitor::ActualStructuredSDFGVisitor& visitor) { return visitor.visit(*this); }
55✔
54

55
void Reduce::validate(const Function& function) const { StructuredLoop::validate(function); };
253✔
56

57
void Reduce::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
15✔
58
    StructuredLoop::replace(old_expression, new_expression);
15✔
59

60
    if (SymEngine::is_a<SymEngine::Symbol>(*old_expression) && SymEngine::is_a<SymEngine::Symbol>(*new_expression)) {
15✔
61
        const auto& old_name = SymEngine::rcp_static_cast<const SymEngine::Symbol>(old_expression)->get_name();
15✔
62
        const auto& new_name = SymEngine::rcp_static_cast<const SymEngine::Symbol>(new_expression)->get_name();
15✔
63
        for (auto& reduction : this->reductions_) {
19✔
64
            if (reduction.container == old_name) {
19✔
NEW
65
                reduction.container = new_name;
×
NEW
66
            }
×
67
        }
19✔
68
    }
15✔
69
}
15✔
70

NEW
71
void Reduce::replace(const symbolic::ExpressionMapping& replacements) {
×
NEW
72
    StructuredLoop::replace(replacements);
×
73

NEW
74
    for (auto& reduction : this->reductions_) {
×
NEW
75
        auto it = replacements.find(symbolic::symbol(reduction.container));
×
NEW
76
        if (it != replacements.end() && SymEngine::is_a<SymEngine::Symbol>(*it->second)) {
×
NEW
77
            reduction.container = SymEngine::rcp_static_cast<const SymEngine::Symbol>(it->second)->get_name();
×
NEW
78
        }
×
NEW
79
    }
×
NEW
80
}
×
81

82
const std::vector<ReductionInfo>& Reduce::reductions() const { return this->reductions_; };
63✔
83

NEW
84
void Reduce::replace_reduction_container(const std::string& old_name, const std::string& new_name) {
×
NEW
85
    if (old_name == new_name) {
×
NEW
86
        return;
×
NEW
87
    }
×
NEW
88
    for (auto& reduction : this->reductions_) {
×
NEW
89
        if (reduction.container == old_name) {
×
NEW
90
            reduction.container = new_name;
×
NEW
91
        }
×
NEW
92
    }
×
NEW
93
};
×
94

95
} // namespace structured_control_flow
96
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc