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

daisytuner / docc / 28094136925

24 Jun 2026 11:07AM UTC coverage: 61.875% (+0.1%) from 61.779%
28094136925

push

github

web-flow
defines transformation json schema and aligns transformations (#809)

249 of 329 new or added lines in 38 files covered. (75.68%)

5 existing lines in 5 files now uncovered.

37186 of 60099 relevant lines covered (61.87%)

1014.83 hits per line

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

41.67
/opt/src/transformations/loop_indvar_finalize.cpp
1
#include "sdfg/transformations/loop_indvar_finalize.h"
2

3
#include <stdexcept>
4

5
#include "sdfg/builder/structured_sdfg_builder.h"
6
#include "sdfg/structured_control_flow/block.h"
7
#include "sdfg/structured_control_flow/map.h"
8
#include "sdfg/symbolic/symbolic.h"
9

10
/**
11
 * Loop Indvar Finalize Transformation Implementation
12
 *
13
 * For a normalized loop, computes the closed-form final value of the original
14
 * induction variable and adds a block right after the loop with this assignment.
15
 *
16
 * closed_form = num_iterations
17
 *
18
 * SymbolPropagation will then propagate this value into any subsequent blocks
19
 * that reference the induction variable, breaking WAR dependencies.
20
 */
21

22
namespace sdfg {
23
namespace transformations {
24

25
LoopIndvarFinalize::LoopIndvarFinalize(structured_control_flow::StructuredLoop& loop) : loop_(loop) {}
14✔
26

27
std::string LoopIndvarFinalize::name() const { return "LoopIndvarFinalize"; }
×
28

29
bool LoopIndvarFinalize::
30
    can_be_applied(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) {
14✔
31
    // Loop must be in normal form
32
    if (!loop_.is_loop_normal_form()) {
14✔
33
        return false;
1✔
34
    }
1✔
35

36
    return true;
13✔
37
}
14✔
38

39
void LoopIndvarFinalize::apply(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) {
13✔
40
    auto indvar = loop_.indvar();
13✔
41

42
    // num_iterations() already returns max(0, ceil((bound - init) / stride)),
43
    // so it is safe to use directly even when the loop does not execute.
44
    auto closed_form = loop_.num_iterations();
13✔
45

46
    auto parent_node = loop_.get_parent();
13✔
47
    auto* parent = dynamic_cast<structured_control_flow::Sequence*>(parent_node);
13✔
48

49
    // Add block with closed-form assignment right after the loop
50
    // SymbolPropagation will propagate into subsequent blocks
51
    builder.add_block_after(*parent, loop_, {{indvar, closed_form}}, loop_.debug_info());
13✔
52

53
    analysis_manager.invalidate_all();
13✔
54
}
13✔
55

56
void LoopIndvarFinalize::to_json(nlohmann::json& j) const {
×
57
    j["transformation_type"] = this->name();
×
NEW
58
    j["parameters"] = nlohmann::json::object();
×
59

NEW
60
    serializer::JSONSerializer ser_flat(false);
×
NEW
61
    j["subgraph"] = nlohmann::json::object();
×
NEW
62
    j["subgraph"]["0"] = nlohmann::json::object();
×
NEW
63
    ser_flat.serialize_node(j["subgraph"]["0"], loop_);
×
UNCOV
64
}
×
65

66
LoopIndvarFinalize LoopIndvarFinalize::from_json(builder::StructuredSDFGBuilder& builder, const nlohmann::json& j) {
×
67
    auto loop_id = j["subgraph"]["0"]["element_id"].get<size_t>();
×
68

69
    auto element = builder.find_element_by_id(loop_id);
×
70
    if (!element) {
×
71
        throw std::runtime_error("LoopIndvarFinalize: Element not found");
×
72
    }
×
73

74
    auto loop = dynamic_cast<structured_control_flow::StructuredLoop*>(element);
×
75
    if (!loop) {
×
76
        throw std::runtime_error("LoopIndvarFinalize: Element is not a loop");
×
77
    }
×
78

79
    return LoopIndvarFinalize(*loop);
×
80
}
×
81

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