docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::transformations::LoopPeeling Class Reference

Loop peeling for a perfectly nested chain of compound-condition loops. More...

#include <sdfg/transformations/loop_peeling.h>

Inheritance diagram for sdfg::transformations::LoopPeeling:
[legend]

Public Member Functions

 LoopPeeling (structured_control_flow::StructuredLoop &loop, bool predicate=false)
 Construct a loop peeling transformation.
virtual std::string name () const override
 Get the name of this transformation.
virtual bool can_be_applied (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
 Check if this transformation can be safely applied.
virtual void apply (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
 Apply this transformation to the SDFG.
virtual void to_json (nlohmann::json &j) const override
 Serialize this transformation to JSON.
Public Member Functions inherited from sdfg::transformations::Transformation
virtual ~Transformation ()=default
virtual void set_report (PassReportConsumer *report)
 Set the report consumer for transformation feedback.
virtual bool try_apply (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager)
 Attempt to apply the transformation if possible.

Static Public Member Functions

static LoopPeeling from_json (builder::StructuredSDFGBuilder &builder, const nlohmann::json &j)

Additional Inherited Members

Protected Attributes inherited from sdfg::transformations::Transformation
PassReportConsumer * report_ = nullptr

Detailed Description

Loop peeling for a perfectly nested chain of compound-condition loops.

Targets a loop whose condition is a conjunction of a canonical (constant-trip) bound and one or more dynamic bounds, e.g. for (k = k0; k < TK + k0 && k < N; ++k), and greedily collects the perfectly nested chain of such loops beneath it. All loops in the chain are over-approximated to their constant trip counts and shifted to a 0-based induction variable, so the whole nest becomes compile-time constant and can be fully unrolled/vectorized. The dropped dynamic bounds are re-applied in one of two ways, selected by predicate:

  • Hoisted (default, predicate = false) — a single outer IfElse whose "then" branch runs the clean, unguarded, 0-based nest when the whole tile is in bounds, and whose "else" branch runs the original (variable-trip) nest for boundary tiles. The unguarded inner micro-kernel vectorizes on CPU. Universal.
  • Predicated (predicate = true) — the 0-based nest is emitted directly and the innermost body is wrapped in one combined guard if (all dynamic bounds hold), with no remainder branch. On GPU the guard lowers to cheap predicated instructions, so register-tile accumulators stay in registers (no local-memory spill). Use for GPU / einsum register tiling.

Constructor & Destructor Documentation

◆ LoopPeeling()

sdfg::transformations::LoopPeeling::LoopPeeling ( structured_control_flow::StructuredLoop & loop,
bool predicate = false )
explicit

Construct a loop peeling transformation.

Parameters
loopThe outermost loop of the perfectly nested compound-condition chain.
predicateIf true, emit the predicated (GPU register-tiling) form; if false (default), emit the hoisted then/else form.

Member Function Documentation

◆ apply()

virtual void sdfg::transformations::LoopPeeling::apply ( builder::StructuredSDFGBuilder & builder,
analysis::AnalysisManager & analysis_manager )
overridevirtual

Apply this transformation to the SDFG.

Parameters
builderThe SDFG builder
analysis_managerThe analysis manager (may be invalidated)

Implements sdfg::transformations::Transformation.

◆ can_be_applied()

virtual bool sdfg::transformations::LoopPeeling::can_be_applied ( builder::StructuredSDFGBuilder & builder,
analysis::AnalysisManager & analysis_manager )
overridevirtual

Check if this transformation can be safely applied.

Parameters
builderThe SDFG builder
analysis_managerThe analysis manager providing necessary analyses
Returns
true if all preconditions are met

Implements sdfg::transformations::Transformation.

◆ from_json()

LoopPeeling sdfg::transformations::LoopPeeling::from_json ( builder::StructuredSDFGBuilder & builder,
const nlohmann::json & j )
static

◆ name()

virtual std::string sdfg::transformations::LoopPeeling::name ( ) const
overridevirtual

Get the name of this transformation.

Returns
The transformation name (e.g., "LoopInterchange")

Implements sdfg::transformations::Transformation.

◆ to_json()

virtual void sdfg::transformations::LoopPeeling::to_json ( nlohmann::json & j) const
overridevirtual

Serialize this transformation to JSON.

Parameters
jJSON object to populate with transformation description
Exceptions
std::logic_errorif not implemented

Implements sdfg::transformations::Transformation.


The documentation for this class was generated from the following file: