Skip to content

[API Proposal]: : AVX-IFMA Intrinsics #98833

Description

@DeepakRajendrakumaran

Background and motivation

The upcoming Intel® Sierra Forest, Grand Ridge, Arrow Lake, Lunar Lake will introduce AVX-IFMA instruction set architecture which provides VEX-encoded versions of following Instructions

  • VPMADD52HUQ—Packed Multiply of Unsigned 52-Bit Integers and Add the High 52-Bit Products to Qword Accumulators
  • VPMADD52LUQ—Packed Multiply of Unsigned 52-Bit Integers and Add the Low 52-Bit Products to Qword Accumulators

Reference: https://www.intel.com/content/www/us/en/content-details/812218/intel-architecture-instruction-set-extensions-programming-reference.html .

This proposal aims to expose AVX-IFMA instructions via intrinsics.

Note: A public proposal exists already for AVX-512 IFMA(#96476)

API Proposal

namespace System.Runtime.Intrinsics.X86
{
    public abstract class AvxIfma : Avx2
    {
        internal AvxIfma () { }

        public static new bool IsSupported { get; }

        public new abstract class X64 : Avx2.X64
        {
            internal X64() { }

            public static new bool IsSupported { get; }

        }

        /// <summary>
        /// __m128i _mm_madd52lo_avx_epu64 (__m128i __X, __m128i __Y, __m128i __Z)
        /// vpmadd52luq xmm, xmm, xmm
        /// </summary>
        public static Vector128<ulong> MultiplyAdd52Low(Vector128<ulong> addend, Vector128<ulong> left, Vector128<ulong> right);

        /// <summary>
        /// _m128i _mm_madd52hi_avx_epu64 (__m128i __X, __m128i __Y, __m128i __Z)
        /// vpmadd52huq xmm, xmm, xmm
        /// </summary>
        public static Vector128<ulong> MultiplyAdd52High(Vector128<ulong> addend, Vector128<ulong> left, Vector128<ulong> right);

        /// <summary>
        /// __m256i _mm_madd52lo_avx_epu64 (__m256i __X, __m256i __Y, __m256i __Z)
        /// vpmadd52luq ymm, ymm, ymm
        /// </summary>
        public static Vector256<ulong> MultiplyAdd52Low(Vector256<ulong> addend, Vector256<ulong> left, Vector256<ulong> right);

        /// <summary>
        /// __m256i _mm256_madd52hi_avx_epu64 (__m256i __X, __m256i __Y, __m256i __Z)
        /// vpmadd52huq ymm, ymm, ymm
        /// </summary>
        public static Vector256<ulong> MultiplyAdd52High(Vector256<ulong> addend, Vector256<ulong> left, Vector256<ulong> right);

    }
}

API Usage

Vector128<ulong> foo(Vector128<ulong> arg0, Vector128<ulong> arg1, Vector128<ulong> arg2)
{
        return AvxIfma.MultiplyAdd52Low(arg0, arg1, arg2);
}

Alternative Designs

No response

Risks

No response

Activity

  1. added
    api-suggestion
    on Feb 22, 2024
  2. ghost added
    untriaged
    on Feb 22, 2024
  3. anthonycanino commented on Feb 22, 2024

    @anthonycanino
    Contributor

    @dotnet/avx512-contrib

  4. added
    avx512
    on Feb 22, 2024
  5. removed
    avx512
    on Feb 22, 2024
  6. huoyaoyuan commented on Feb 23, 2024

    @huoyaoyuan
    Member

    What's the relationship with the AVX512.VL version? The mentioned instruction names are same.

    I assume they are indicated by different feature flags as AVX512.VL requires 512 bit and more register support.

  7. tannergooding commented on Feb 23, 2024

    @tannergooding
    Member

    Yes, different feature flags and encodings. Avx512Ifma.VL is 128-bit and 256-bit EVEX encoded.

    AvxIfma is 128-bit and 256-bit VEX encoded support. A given CPU might support one, both, or neither.

  8. added
    api-ready-for-review
    and removed
    api-suggestion
    untriaged
    on Feb 23, 2024
  9. terrajobst commented on Feb 29, 2024

    @terrajobst
    Contributor

    Video

    • We should rename the parameters to addend, left, and right
    namespace System.Runtime.Intrinsics.X86
    {
        public abstract class AvxIfma : Avx2
        {
            public static new bool IsSupported { get; }
    
            public static Vector128<ulong> MultiplyAdd52Low(Vector128<ulong> addend, Vector128<ulong> left, Vector128<ulong> right);
            public static Vector128<ulong> MultiplyAdd52High(Vector128<ulong> addend, Vector128<ulong> left, Vector128<ulong> right);
            public static Vector256<ulong> MultiplyAdd52Low(Vector256<ulong> addend, Vector256<ulong> left, Vector256<ulong> right);
            public static Vector256<ulong> MultiplyAdd52High(Vector256<ulong> addend, Vector256<ulong> left, Vector256<ulong> right);
    
            public new abstract class X64 : Avx2.X64
            {
                public static new bool IsSupported { get; }
            }
        }
    }
  10. added
    api-approved
    and removed
    api-ready-for-review
    on Feb 29, 2024
  11. added this to the 10.0.0 milestone on Jul 19, 2024
  12. modified the milestones: 10.0.0, Future on Jul 14, 2025
  13. jamesburton commented on Jun 30, 2026

    @jamesburton
    Contributor

    Hi @tannergooding — would you (or whoever's the current owner of this surface) be open to me picking this up?

    Context: I just landed AvxVnni.V512 (#128365). The VEX-side AVX-IFMA surface here is structurally very close to the AvxVnni half of that work — Avx2-parented, two intrinsic methods around VPMADD52LUQ / VPMADD52HUQ, ulong-typed, V128/V256 only (no V512 split at this layer — that's the EVEX form covered by #96476).

    Strix Halo / Zen 5 reports the CPUID bit, so I can functionally verify locally with the same probe pattern I used for AvxVnni.V512.

    Just confirming the api-approved scope from 2024 is still current before I open the PR. Happy to defer if there's a reason to bundle this with #96476 first, or to wait behind a planned restructuring of this area. Not opening anything until you confirm — wouldn't want a repeat of the BF16 close.

  14. tannergooding commented on Jun 30, 2026

    @tannergooding
    Member

    @jamesburton, feel free to pickl this up. #96476 should be done simultaneously and should have the same fixup we've had approved and done for the other ISAs, where its a nested V512 class.

  15. jamesburton commented on Jun 30, 2026

    @jamesburton
    Contributor

    Thanks Tanner — picking this up and bundling with #96476 in a single PR, using the AvxIfma + nested AvxIfma.V512 shape (mirroring the AvxVnni.V512 pattern that just landed in #128365). Will mirror the file-by-file structure of that work to minimise review surface. Targeting end of next week for a draft.

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

    api-approvedarea-System.Runtime.Intrinsics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions