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

Eliminates a zero-initialization nest that is redundant before a GPU MMA matmul nest. More...

#include <sdfg/transformations/redundant_zero_init_elimination.h>

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

Public Member Functions

 RedundantZeroInitElimination (structured_control_flow::StructuredLoop &loop)
std::string name () const override
 Get the name of this transformation.
bool can_be_applied (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
 Check if this transformation can be safely applied.
void apply (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
 Apply this transformation to the SDFG.
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 RedundantZeroInitElimination from_json (builder::StructuredSDFGBuilder &builder, const nlohmann::json &j)

Additional Inherited Members

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

Detailed Description

Eliminates a zero-initialization nest that is redundant before a GPU MMA matmul nest.

Original: [init=zero] map i, j: Y[i, j] = 0 <MMA nest>: ... MmaFragmentLoad(c <- Y) ... EltwiseAdd(acc, c) ... MmaFragmentStore(Y)

After RedundantZeroInitElimination: <MMA nest>: ... GpuMmaFill(c) ... EltwiseAdd(acc, c) ... MmaFragmentStore(Y)

The C-fragment loads of Y in the MMA nest could only observe the zeros written by the init nest, so they are replaced by zero fills and the init nest is removed.

Prerequisites:

  • The loop carries the zero-init annotation (ScheduleType_ZeroInit). The producer (naive MatMul/GEMM expansion) thereby certifies that the nest writes zeros to exactly the output region of the matmul nest directly following it.
  • The nest is still a pure zero init, i.e. a perfect loop chain whose body is a single constant 0 -> assign -> Y block (it was not fused with other computation).
  • The next sibling in the same sequence is a loop nest containing GPU MMA matmul nodes and fragment stores to Y.
  • Within that nest, Y is only used as the memory operand of fragment stores and of C-fragment loads, and the C-fragment loads are only nested in maps and branches (no sequential loop could re-read stored partial results).

Note: the MMA nests produced by GpuMmaEinsumTransform never use the data already contained in Y beyond these C-fragment loads. If other MMA lowerings are matched in the future (e.g. an overwrite mode without C-fragment loads, or nests reading Y differently), the checks may need to be extended.

Constructor & Destructor Documentation

◆ RedundantZeroInitElimination()

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

Member Function Documentation

◆ apply()

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

bool sdfg::transformations::RedundantZeroInitElimination::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()

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

◆ name()

std::string sdfg::transformations::RedundantZeroInitElimination::name ( ) const
overridevirtual

Get the name of this transformation.

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

Implements sdfg::transformations::Transformation.

◆ to_json()

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