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

Loop unit stride transformation to convert non-unit stride loops to unit stride. More...

#include <sdfg/transformations/loop_unit_stride.h>

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

Public Member Functions

 LoopUnitStride (structured_control_flow::StructuredLoop &loop)
 Construct a LoopUnitStride 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.
std::string strided_container_name () const
 Get the name of the container holding the strided (original) value.
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 LoopUnitStride 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 unit stride transformation to convert non-unit stride loops to unit stride.

This transformation converts a loop with stride != 1 to a loop with |stride| = 1 using symbolic substitution on the condition.

Precondition: init == 0 (apply LoopShift first if needed)

Original loop (positive stride s > 1): for (i = 0; i < bound; i += s) body(i)

After LoopUnitStride: for (i = 0; s*i < bound; i++) i_orig = s * i // Assignment in transition body(i_orig) // Uses original value via propagation

For negative stride (s < -1): for (i = 0; bound < i; i += s) // s is negative body(i)

After LoopUnitStride: for (i = 0; bound < s*i; i++) i_orig = s * i // s is negative, so this decreases body(i_orig)

Example: // Original: i = 0, 2, 4, 6 (stride = 2, bound = 8) for (i = 0; i < 8; i += 2) A[i] = ...

// After: condition becomes 2*i < 8 for (i = 0; 2*i < 8; i++) i_orig = 2 * i // = 0, 2, 4, 6 A[i_orig] = ...

Prerequisites:

  • Loop init must be 0 (apply LoopShift first)
  • Loop must have detectable non-unit stride (stride != 1 and stride != -1)

Benefits:

  • Normalizes loop stride for analysis and transformation
  • Enables TileFusion which requires matching strides
  • Enables LoopRotate (which requires stride = -1)
Note
After applying this transformation, you should run SymbolPropagation to propagate the strided index expression into the loop body. The condition may need simplification via symbolic simplify pass.

Constructor & Destructor Documentation

◆ LoopUnitStride()

sdfg::transformations::LoopUnitStride::LoopUnitStride ( structured_control_flow::StructuredLoop & loop)
explicit

Construct a LoopUnitStride transformation.

Parameters
loopThe loop to normalize (must have non-unit stride)

Member Function Documentation

◆ apply()

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

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

◆ name()

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

Get the name of this transformation.

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

Implements sdfg::transformations::Transformation.

◆ strided_container_name()

std::string sdfg::transformations::LoopUnitStride::strided_container_name ( ) const

Get the name of the container holding the strided (original) value.

Returns
Container name (e.g., "__i_orig__")

◆ to_json()

virtual void sdfg::transformations::LoopUnitStride::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: