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

daisytuner / docc / 27896596762

21 Jun 2026 06:58AM UTC coverage: 61.87% (+0.02%) from 61.847%
27896596762

push

github

web-flow
extends MapFusion to reduction consumers (#796)

* extends MapFusion to elementwise-stream reduction consumers

* extends MapFusion to support hoisting before an inner reduction

88 of 103 new or added lines in 3 files covered. (85.44%)

4 existing lines in 2 files now uncovered.

37021 of 59837 relevant lines covered (61.87%)

1018.73 hits per line

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

33.9
/opt/src/passes/normalization/map_fusion.cpp
1
#include "sdfg/passes/normalization/map_fusion.h"
2

3
#include "sdfg/data_flow/library_nodes/stdlib/malloc.h"
4
#include "sdfg/transformations/map_fusion.h"
5

6
namespace sdfg {
7
namespace passes {
8
namespace normalization {
9

10
MapFusion::MapFusion(
11
    builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager, bool allow_init_hoist
12
)
13
    : visitor::NonStoppingStructuredSDFGVisitor(builder, analysis_manager), allow_init_hoist_(allow_init_hoist) {}
2✔
14

15
bool MapFusion::accept(structured_control_flow::Sequence& node) {
8✔
16
    bool applied = false;
8✔
17

18
    if (node.size() < 2) {
8✔
19
        return applied;
6✔
20
    }
6✔
21

22
    // Iterate over sequence looking for consecutive (Map, StructuredLoop) pairs
23
    size_t i = 0;
2✔
24
    while (i + 1 < node.size()) {
4✔
25
        auto* first = dynamic_cast<structured_control_flow::Map*>(&node.at(i).first);
2✔
26
        if (!first) {
2✔
27
            i++;
×
28
            continue;
×
29
        }
×
30
        if (first->root().size() == 0) {
2✔
31
            i++;
×
32
            continue;
×
33
        }
×
34

35
        if (auto* second = dynamic_cast<structured_control_flow::StructuredLoop*>(&node.at(i + 1).first)) {
2✔
36
            if (second->root().size() == 0) {
2✔
37
                i++;
×
38
                continue;
×
39
            }
×
40
            transformations::MapFusion transformation(*first, *second, true, allow_init_hoist_);
2✔
41
            if (transformation.can_be_applied(builder_, analysis_manager_)) {
2✔
42
                auto first_name = first->indvar()->get_name();
×
43
                auto second_name = second->indvar()->get_name();
×
44
                transformation.apply(builder_, analysis_manager_);
×
45
                DEBUG_PRINTLN("Applied MapFusion to maps " + first_name + " and " + second_name);
×
46
                applied = true;
×
47
            }
×
48
        } else if (i + 2 < node.size()) {
2✔
49
            auto* mid_block = dynamic_cast<structured_control_flow::Block*>(&node.at(i + 1).first);
×
50
            if (mid_block && mid_block->is_a_library_node<stdlib::MallocNode>()) {
×
51
                if (auto* second = dynamic_cast<structured_control_flow::StructuredLoop*>(&node.at(i + 2).first)) {
×
52
                    if (second->root().size() == 0) {
×
53
                        i++;
×
54
                        continue;
×
55
                    }
×
NEW
56
                    transformations::MapFusion transformation(*first, *second, false, allow_init_hoist_);
×
57
                    if (transformation.can_be_applied(builder_, analysis_manager_)) {
×
58
                        auto first_name = first->indvar()->get_name();
×
59
                        auto second_name = second->indvar()->get_name();
×
60
                        transformation.apply(builder_, analysis_manager_);
×
61
                        DEBUG_PRINTLN(
×
62
                            "Applied MapFusion to map " + first_name + " and loop " + second_name +
×
63
                            " with intermediate malloc block"
×
64
                        );
×
65
                        applied = true;
×
66

67
                        // Move malloc block before the first map
68
                        this->builder_.move_child(node, i + 1, node, i);
×
69
                        i = i + 2; // Skip over the newly moved malloc block and the second loop that was just fused
×
70
                        continue;
×
71
                    }
×
72
                }
×
73
            }
×
74
        }
×
75
        i++;
2✔
76
    }
2✔
77

78
    return applied;
2✔
79
}
8✔
80

81
} // namespace normalization
82
} // namespace passes
83
} // 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