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

Loop interchange transformation that swaps two nested loops. More...

#include <sdfg/transformations/loop_interchange.h>

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

Public Member Functions

 LoopInterchange (structured_control_flow::StructuredLoop &outer_loop, structured_control_flow::StructuredLoop &inner_loop)
 Construct a loop interchange transformation.
virtual std::string name () const override
 Get the name of this transformation.
LoopSwap proposal (analysis::AnalysisManager *analysis_manager=nullptr) const
 Compute the interchanged loop headers without modifying the SDFG.
virtual bool can_be_applied (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
 Check if this transformation can be applied.
virtual void apply (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
 Apply the loop interchange transformation.
virtual void to_json (nlohmann::json &j) const override
 Serialize this transformation to JSON.
structured_control_flow::StructuredLoop * new_outer_loop () const
structured_control_flow::StructuredLoop * new_inner_loop () const
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 LoopInterchange from_json (builder::StructuredSDFGBuilder &builder, const nlohmann::json &j)
 Deserialize a loop interchange transformation from JSON.

Additional Inherited Members

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

Detailed Description

Loop interchange transformation that swaps two nested loops.

This transformation swaps the order of two nested loops (outer and inner), potentially improving data locality and parallelization opportunities. The transformation preserves the computational semantics while reordering loop execution.

Supports two cases:

  • Independent bounds: inner loop bounds do not reference the outer induction variable. The loop headers are simply swapped.
  • Dependent bounds (Fourier-Motzkin): inner loop bounds are min/max of affine terms in the outer induction variable with non-negative coefficients. The new outer range is spanned by the first and last outer iteration; the new inner range inverts each affine term, rounded onto the outer loop's stride lattice.
Note
The outer loop must have exactly one child (the inner loop)
For-For interchange is checked via dependence analysis (delta sets must remain lex-non-negative)

Constructor & Destructor Documentation

◆ LoopInterchange()

sdfg::transformations::LoopInterchange::LoopInterchange ( structured_control_flow::StructuredLoop & outer_loop,
structured_control_flow::StructuredLoop & inner_loop )

Construct a loop interchange transformation.

Parameters
outer_loopThe outer loop to be interchanged
inner_loopThe inner loop to be interchanged

Member Function Documentation

◆ apply()

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

Apply the loop interchange transformation.

Parameters
builderThe SDFG builder
analysis_managerThe analysis manager

Implements sdfg::transformations::Transformation.

◆ can_be_applied()

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

Check if this transformation can be applied.

Parameters
builderThe SDFG builder
analysis_managerThe analysis manager
Returns
true if the transformation can be applied safely

Implements sdfg::transformations::Transformation.

◆ from_json()

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

Deserialize a loop interchange transformation from JSON.

Parameters
builderThe SDFG builder
jJSON description of the transformation
Returns
The deserialized transformation

◆ name()

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

Get the name of this transformation.

Returns
"LoopInterchange"

Implements sdfg::transformations::Transformation.

◆ new_inner_loop()

structured_control_flow::StructuredLoop * sdfg::transformations::LoopInterchange::new_inner_loop ( ) const

◆ new_outer_loop()

structured_control_flow::StructuredLoop * sdfg::transformations::LoopInterchange::new_outer_loop ( ) const

◆ proposal()

LoopSwap sdfg::transformations::LoopInterchange::proposal ( analysis::AnalysisManager * analysis_manager = nullptr) const

Compute the interchanged loop headers without modifying the SDFG.

Includes bound projection and inversion for dependent loops. Shared by the reduction-footprint preview and apply(); does not check dependence legality.

Parameters
analysis_managerOptional; enables floor-division bounds whose numerator is provably non-negative
Returns
Original loop IDs and the proposed outer and inner headers

◆ to_json()

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

Serialize this transformation to JSON.

Parameters
jJSON object to populate

Implements sdfg::transformations::Transformation.


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