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

Contracts a floating-point multiplication feeding an addition into a fused multiply-add. More...

#include <sdfg/fp_math/transformations/fuse_fma.h>

Inheritance diagram for sdfg::fp_math::FuseFMA:
[legend]

Public Member Functions

 FuseFMA (data_flow::Tasklet &add, bool invalidate_analysis=true)
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.
data_flow::Tasklet * fma () const
 The fused multiply-add tasklet created by apply(), or nullptr before.
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 FuseFMA from_json (builder::StructuredSDFGBuilder &builder, const nlohmann::json &j)

Additional Inherited Members

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

Detailed Description

Contracts a floating-point multiplication feeding an addition into a fused multiply-add.

Anchored at an fp_add tasklet d = t + c (or d = c + t) whose operand t is a transient scalar that is written only by an fp_mul tasklet t = a * b of the same block and read only by this addition. The pair is replaced by a single fp_fma tasklet d = fma(a, b, c); the product container is removed.

If both operands of the addition are such products, the one on _in1 is contracted. All operands, the product and the result must share the same floating-point precision.

Contraction skips the intermediate rounding of the product, so it is only valid under -ffp-contract=fast semantics.

See also
UnfuseFMA for the inverse.

Constructor & Destructor Documentation

◆ FuseFMA()

sdfg::fp_math::FuseFMA::FuseFMA ( data_flow::Tasklet & add,
bool invalidate_analysis = true )
explicit

Member Function Documentation

◆ apply()

virtual void sdfg::fp_math::FuseFMA::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::fp_math::FuseFMA::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.

◆ fma()

data_flow::Tasklet * sdfg::fp_math::FuseFMA::fma ( ) const

The fused multiply-add tasklet created by apply(), or nullptr before.

◆ from_json()

FuseFMA sdfg::fp_math::FuseFMA::from_json ( builder::StructuredSDFGBuilder & builder,
const nlohmann::json & j )
static

◆ name()

virtual std::string sdfg::fp_math::FuseFMA::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::fp_math::FuseFMA::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:
  • opt/include/sdfg/fp_math/transformations/fuse_fma.h