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

daisytuner / docc / 28106147644

24 Jun 2026 02:32PM UTC coverage: 61.922% (+0.1%) from 61.779%
28106147644

Pull #806

github

web-flow
Merge 2be414d54 into 57cc1db99
Pull Request #806: Map Collapse for Multiple targets in a neste sequence

165 of 185 new or added lines in 2 files covered. (89.19%)

419 existing lines in 30 files now uncovered.

37705 of 60891 relevant lines covered (61.92%)

1004.4 hits per line

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

75.0
/opt/src/transformations/offloading/gpu_loop_reordering.cpp
1
#include "sdfg/transformations/offloading/gpu_loop_reordering.h"
2

3
#include <sdfg/transformations/loop_interchange.h>
4
#include <vector>
5

6
#include "sdfg/analysis/loop_analysis.h"
7
#include "sdfg/structured_control_flow/for.h"
8
#include "sdfg/targets/gpu/gpu_schedule_type.h"
9

10
namespace sdfg {
11
namespace transformations {
12

13
GPULoopReordering::GPULoopReordering(structured_control_flow::Map& map_) : map_(map_) {};
20✔
14
bool GPULoopReordering::
15
    can_be_applied(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) {
16✔
16
    auto& loop_analysis = analysis_manager.get<analysis::LoopAnalysis>();
16✔
17
    auto loop_paths = loop_analysis.loop_tree_paths(&this->map_);
16✔
18

19
    if (loop_paths.size() != 1) {
16✔
20
        return false;
×
21
    }
×
22

23
    auto& nested_loops = loop_paths.front();
16✔
24

25
    if (nested_loops.size() < 2) {
16✔
26
        return false;
14✔
27
    }
14✔
28

29
    // Criterion: first loop must be a GPU map
30
    auto first_loop = dynamic_cast<structured_control_flow::Map*>(nested_loops.at(0));
2✔
31
    if (!first_loop) {
2✔
32
        return false;
×
33
    }
×
34
    if (!gpu::is_gpu_schedule(first_loop->schedule_type())) {
2✔
35
        return false;
×
36
    }
×
37

38
    return true;
2✔
39
};
2✔
40

41
void GPULoopReordering::apply(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) {
2✔
42
    auto& loop_analysis = analysis_manager.get<analysis::LoopAnalysis>();
2✔
43
    auto loop_paths = loop_analysis.loop_tree_paths(&this->map_);
2✔
44
    auto& nested_loops = loop_paths.front();
2✔
45

46
    // Bubble sort permutation indices
47
    for (size_t i = 0; i < nested_loops.size(); i++) {
6✔
48
        for (size_t j = 0; j < nested_loops.size() - i - 1; j++) {
6✔
49
            auto for_loop = dynamic_cast<structured_control_flow::For*>(nested_loops.at(j));
2✔
50
            auto map = dynamic_cast<structured_control_flow::Map*>(nested_loops.at(j + 1));
2✔
51

52
            if (!for_loop || !map) {
2✔
53
                continue;
2✔
54
            }
2✔
55
            transformations::LoopInterchange loop_interchange(*for_loop, *map);
×
56
            if (loop_interchange.can_be_applied(builder, analysis_manager)) {
×
57
                loop_interchange.apply(builder, analysis_manager);
×
58
                nested_loops[j] = loop_interchange.new_outer_loop();
×
59
                nested_loops[j + 1] = loop_interchange.new_inner_loop();
×
60
            }
×
61
        }
×
62
    }
4✔
63
    analysis_manager.invalidate_all();
2✔
64
};
2✔
65

66
std::string GPULoopReordering::name() const { return "GPULoopReordering"; };
3✔
67

68
void GPULoopReordering::to_json(nlohmann::json& j) const {
1✔
69
    j["transformation_type"] = this->name();
1✔
70
    j["parameters"] = nlohmann::json::object();
1✔
71

72
    serializer::JSONSerializer ser_flat(false);
1✔
73
    j["subgraph"] = nlohmann::json::object();
1✔
74
    j["subgraph"]["0"] = nlohmann::json::object();
1✔
75
    ser_flat.serialize_node(j["subgraph"]["0"], map_);
1✔
76
}
1✔
77

78
GPULoopReordering GPULoopReordering::from_json(builder::StructuredSDFGBuilder& builder, const nlohmann::json& j) {
1✔
79
    size_t first_loop_id;
1✔
80
    const auto& node_desc = j.at("subgraph").at("0");
1✔
81
    first_loop_id = node_desc.at("element_id").get<size_t>();
1✔
82

83
    auto* first_loop = dynamic_cast<structured_control_flow::Map*>(builder.find_element_by_id(first_loop_id));
1✔
84
    if (!first_loop) {
1✔
UNCOV
85
        throw std::runtime_error("Invalid first_loop_id in GPULoopReordering deserialization");
×
UNCOV
86
    }
×
87
    return GPULoopReordering(*first_loop);
1✔
88
}
1✔
89

90
} // namespace transformations
91
} // 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