Skip to content

Consider FMA #5

Open
Open
@jfbastien

Description

@jfbastien

Fused multiply-add is being discussed in WebAssembly/simd#8. Let's move the discussion here so we don't drop it.

I'd consider FMA after the first shot at SIMD because, similar to #4, it doesn't have universal platform support. Specific benchmarks may benefit from its presence. As with other ops, maybe we should consider adding support for scalar and vector FMA at the same time.

FMA is part of IEEE 754-2008, but isn't universally supported and can't be polyfilled efficiently. Maybe implementations should simply not advertise FMA if the hardware doesn't support it, forcing users to feature-detect, as opposed to offering non-fused fallback which yield different numerical results.

FMA offers multiply+add with one less rounding, sometimes better runtime performance (sometimes because the hardware itself is magical, it avoids register issues, has its own execution unit, etc), and may have better instruction-cache impact.

It's supported in languages like C or C++ through opt-in with pragma fp_contract, explicit math.h fma function and friends, or fast math flags. I would disallow such optimizations by WebAssembly compilers, only the developer-side compiler should be allowed to emit that opcode.

It's supported in recent x86, and all ARMv8.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions