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

Loop tiling (blocking) transformation. More...

#include <sdfg/transformations/loop_tiling.h>

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

Public Member Functions

 LoopTiling (structured_control_flow::StructuredLoop &loop, size_t tile_size, bool simplify_bounds=true)
 Construct a loop tiling 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 applied.
virtual void apply (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
 Apply the loop tiling transformation.
virtual void to_json (nlohmann::json &j) const override
 Serialize this transformation to JSON.
structured_control_flow::StructuredLoop * inner_loop ()
structured_control_flow::StructuredLoop * outer_loop ()
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 LoopTiling from_json (builder::StructuredSDFGBuilder &builder, const nlohmann::json &j)
 Deserialize a loop tiling transformation from JSON.

Protected Member Functions

bool reduction_buffers_supported (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager, const std::vector< size_t > &tile_sizes) const
 Check reduction footprints using symbolic tile domains without changing the graph.

Static Protected Member Functions

static structured_control_flow::StructuredLoop & tile_loop (builder::StructuredSDFGBuilder &builder, structured_control_flow::StructuredLoop &loop, size_t tile_size, bool simplify_bounds=true)
 Tile a single loop into an outer tile loop and an inner element loop.

Protected Attributes

structured_control_flow::StructuredLoop & loop_
size_t tile_size_
bool simplify_bounds_ = true
bool applied_ = false
structured_control_flow::StructuredLoop * inner_loop_ = nullptr
structured_control_flow::StructuredLoop * outer_loop_ = nullptr
Protected Attributes inherited from sdfg::transformations::Transformation
PassReportConsumer * report_ = nullptr

Detailed Description

Loop tiling (blocking) transformation.

This transformation splits a loop into two nested loops: an outer loop that iterates over tiles and an inner loop that iterates within each tile. Loop tiling improves data locality by ensuring that data accessed within a tile fits in cache.

Note
The loop must be contiguous (analyzed via LoopAnalysis)
The tile size must be greater than 1

Constructor & Destructor Documentation

◆ LoopTiling()

sdfg::transformations::LoopTiling::LoopTiling ( structured_control_flow::StructuredLoop & loop,
size_t tile_size,
bool simplify_bounds = true )

Construct a loop tiling transformation.

Parameters
loopThe loop to be tiled
tile_sizeThe size of each tile (must be > 1)
simplify_boundsDrop the redundant inner bound for perfectly dividing tiles (see tile_loop)

Member Function Documentation

◆ apply()

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

Apply the loop tiling transformation.

Parameters
builderThe SDFG builder
analysis_managerThe analysis manager

Implements sdfg::transformations::Transformation.

Reimplemented in sdfg::transformations::MultiLevelTiling.

◆ can_be_applied()

virtual bool sdfg::transformations::LoopTiling::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.

Reimplemented in sdfg::transformations::MultiLevelTiling.

◆ from_json()

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

Deserialize a loop tiling transformation from JSON.

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

◆ inner_loop()

structured_control_flow::StructuredLoop * sdfg::transformations::LoopTiling::inner_loop ( )

◆ name()

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

Get the name of this transformation.

Returns
"LoopTiling"

Implements sdfg::transformations::Transformation.

Reimplemented in sdfg::transformations::MultiLevelTiling.

◆ outer_loop()

structured_control_flow::StructuredLoop * sdfg::transformations::LoopTiling::outer_loop ( )

◆ reduction_buffers_supported()

bool sdfg::transformations::LoopTiling::reduction_buffers_supported ( builder::StructuredSDFGBuilder & builder,
analysis::AnalysisManager & analysis_manager,
const std::vector< size_t > & tile_sizes ) const
protected

Check reduction footprints using symbolic tile domains without changing the graph.

Parameters
builderThe builder for the unchanged original SDFG
analysis_managerThe analysis manager for the current graph
tile_sizesTile sizes in application order, each applied to the inner loop
Returns
true if affected reductions are unmaterialized and their proposed footprints are exact

◆ tile_loop()

structured_control_flow::StructuredLoop & sdfg::transformations::LoopTiling::tile_loop ( builder::StructuredSDFGBuilder & builder,
structured_control_flow::StructuredLoop & loop,
size_t tile_size,
bool simplify_bounds = true )
staticprotected

Tile a single loop into an outer tile loop and an inner element loop.

Splits loop in place: loop becomes the inner (element) loop and a new outer loop iterating over tiles is created before it. Map/Reduce loops preserve their schedule/reductions on the outer loop, while a tiled Map's inner loop is converted to a sequential schedule to avoid repeated GPU dimensions.

Parameters
builderThe SDFG builder
loopThe loop to tile (becomes the inner loop)
tile_sizeThe size of each tile (must be > 1)
simplify_boundsDrop the redundant original bound on the inner loop when the tile evenly divides the (constant) trip count, yielding a clean constant-trip tile that unrolls/vectorizes and leaves no redundant guards for later peeling.
Returns
The newly created outer tile loop

◆ to_json()

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

Serialize this transformation to JSON.

Parameters
jJSON object to populate

Implements sdfg::transformations::Transformation.

Reimplemented in sdfg::transformations::MultiLevelTiling.

Member Data Documentation

◆ applied_

bool sdfg::transformations::LoopTiling::applied_ = false
protected

◆ inner_loop_

structured_control_flow::StructuredLoop* sdfg::transformations::LoopTiling::inner_loop_ = nullptr
protected

◆ loop_

structured_control_flow::StructuredLoop& sdfg::transformations::LoopTiling::loop_
protected

◆ outer_loop_

structured_control_flow::StructuredLoop* sdfg::transformations::LoopTiling::outer_loop_ = nullptr
protected

◆ simplify_bounds_

bool sdfg::transformations::LoopTiling::simplify_bounds_ = true
protected

◆ tile_size_

size_t sdfg::transformations::LoopTiling::tile_size_
protected

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