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

Loop skewing transformation for nested loops. More...

#include <sdfg/transformations/loop_skewing.h>

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

Public Member Functions

 LoopSkewing (structured_control_flow::StructuredLoop &outer_loop, structured_control_flow::StructuredLoop &inner_loop, int skew_factor=1)
 Construct a new Loop Skewing 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 LoopSkewing 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 skewing transformation for nested loops.

This transformation applies loop skewing to two nested loops by adjusting the inner loop's iteration space to depend on the outer loop's iteration variable.

Loop skewing is useful for:

  • Exposing parallelism in loops with loop-carried dependencies
  • Improving cache locality by changing the iteration order
  • Enabling other transformations like wavefront parallelization

Transformation: for (i = lb_i; i < ub_i; i++) for (j = lb_j; j < ub_j; j++) body[i][j]

Becomes: for (i' = lb_i; i' < ub_i; i'++) for (j' = lb_j + skew_factor * (i' - lb_i); j' < ub_j + skew_factor * (i' - lb_i); j'++) body[i'][j' - skew_factor * (i' - lb_i)]

Implementation:

  • Uses builder.update_loop() to modify the inner loop in place
  • Uses root().replace() to update memory access patterns
  • No new loops are created, transformation modifies existing loop

Prerequisites:

  • Two properly nested loops (outer loop contains only inner loop)
  • Both loops can be any StructuredLoop (For or Map)
  • Inner loop update must not depend on the outer loop iteration variable
  • Non-zero skew factor

Constructor & Destructor Documentation

◆ LoopSkewing()

sdfg::transformations::LoopSkewing::LoopSkewing ( structured_control_flow::StructuredLoop & outer_loop,
structured_control_flow::StructuredLoop & inner_loop,
int skew_factor = 1 )

Construct a new Loop Skewing transformation.

Parameters
outer_loopThe outer loop to skew
inner_loopThe inner loop to skew
skew_factorThe skewing factor (default: 1)

Member Function Documentation

◆ apply()

virtual void sdfg::transformations::LoopSkewing::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::LoopSkewing::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()

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

◆ name()

virtual std::string sdfg::transformations::LoopSkewing::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::LoopSkewing::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: