Skip to content

[SIMD] Support optimal 4x4 matrix multiplication. #64238

Open

Description

@modulovalue

I wanted to share where we stand on being able to support optimal 4x4 matrix multiplication via our typed_data SIMD APIs so it can be used by e.g. Flutter for close to optimal performance.

Wasm SIMD doesn't support indexed fmla, which costs us roughly 30% compared to splat+fma (which is still a nice 5x~ perf gains over scalar! cc @kevmoo).

Optimal matmul gives use almost 6x faster 4x4 matmul on the VM. Given that matmul is a very important operation in Flutter, squeezing out the last 30%~ seems worthwhile.

Activity

  1. kevmoo commented on Sep 8, 2026

    @kevmoo
    Member

    I LOVE that you're digging in here @modulovalue !

    Some notes:

    • Forever Flutter has used https://pub.dev/packages/vector_math for linear algebra (Matrix bits)
    • vector_math was designed on the typed_data bits - as they were many years ago
    • it's also designed to support 32- and 64-bit numbers.
    • Flutter only uses the 64-bit bits
    • vector_math is now owned by the Flutter team (more or less)
    • I'm a BIG fan of saying we should strip vector_math down to focus on just what Flutter needs.
      • The current model uses a simple copy-paste-rename model to generate 64-bit bits from 32-bit bits.
    • I've already done a pass on optimizing vector_math - but there is a LOT of low-hanging fruit here. Especially if we drop this notion that the 64-bit path is just a slightly tweaked version of the 32-bit path.

    ☝️ Is product hand waving, speculation, and wishful thinking. But I'm happy to engage with you on it!

  2. mraleph commented on Sep 9, 2026

    @mraleph
    Member

    Given that matmul is a very important operation in Flutter, squeezing out the last 30%~ seems worthwhile.

    It would be nice to quantify this by some sort of Flutter benchmark, which is not a microbenchmark (e.g. it does actual UI rendering and demonstrates that Matrix multiplication is on the hot path). 30% of 50% is "sure, it's worthwhile", 30% of 10% is "maybe, it's worthwhile" and 30% of 5% is pretty much "it's irrelevant".

  3. added
    area-sdkUse area-sdk for general purpose SDK issues (packaging, distribution, …).
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-sdkUse area-sdk for general purpose SDK issues (packaging, distribution, …).

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions