Repository navigation
Open
Labels
api-approvedAPI was approved in API review, it can be implementedarea-System.Runtime.Intrinsicsavx512Related to the AVX-512 architecture
Milestone
Description
Background and motivation
AVX-512 IFMA is supported by Intel in the Cannon Lake and newer architectures, and by AMD in Zen 4.
These instructions are known to be useful for cryptography and large number processing, and as a faster compromised alternative for VPMULLQ instruction that finishes 5x slower on Intel CPUs compared to AMD Zen 4, as VPMADD52LUQ finishes in only 4 clock cycles.
API Proposal
namespace System.Runtime.Intrinsics.X86
{
public abstract class Avx512Ifma : Avx512F
{
public static bool IsSupported { get; }
public static Vector512<ulong> MultiplyAdd52Low(Vector512<ulong> a, Vector512<ulong> b, Vector512<ulong> c);
public static Vector512<ulong> MultiplyAdd52High(Vector512<ulong> a, Vector512<ulong> b, Vector512<ulong> c);
public abstract class VL : Avx512F.VL
{
public static new bool IsSupported { get; }
public static Vector256<ulong> MultiplyAdd52Low(Vector256<ulong> a, Vector256<ulong> b, Vector256<ulong> c);
public static Vector256<ulong> MultiplyAdd52High(Vector256<ulong> a, Vector256<ulong> b, Vector256<ulong> c);
public static Vector128<ulong> MultiplyAdd52Low(Vector128<ulong> a, Vector128<ulong> b, Vector128<ulong> c);
public static Vector128<ulong> MultiplyAdd52High(Vector128<ulong> a, Vector128<ulong> b, Vector128<ulong> c);
}
}
}API Usage
zmm0 = Avx512Ifma.MultiplyAdd52Low(zmm0, zmm2, zmm3);
zmm1 = Avx512Ifma.MultiplyAdd52High(zmm1, zmm2, zmm3);An example of vectorized Montgomery reduction implementations using the equivalent C++ intrinsics:
Alternative Designs
Risks
None
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedarea-System.Runtime.Intrinsicsavx512Related to the AVX-512 architecture
Activity
BruceForstall commentedon Jan 4, 2024
@dotnet/avx512-contrib
tannergooding commentedon Jan 4, 2024
The names here could be "better". I'd expect simply
MultiplyAdd52LowandMultiplyAdd52Highor similar would be sufficient and more closely matches the "name" portion of the underlying C/C++ intrinsic_mm512_madd52lo_epu64and_mm512_madd52hi_epu64(the name portion ismadd52loandmadd52hi).These are not "fused" operations as the result of doing this as separate scalar is the same as if they are done "combined" (which is unlike floating-point)
MineCake147E commentedon Jan 15, 2024
I updated the proposal accordingly.
terrajobst commentedon Feb 29, 2024
Video
addend,left, andrightsaucecontrol commentedon Nov 6, 2024
Similar to #86849, this should probably be changed to:
Since the parent is not yet implemented, we also have the option of changing that name to just
Ifma, since it wouldn't directly correlate to the AVX_IFMA cpuid bit any longer.jamesburton commentedon Jun 30, 2026
Hi @tannergooding — same ask as #98833: would you be open to me picking this up?
Context: AvxVnni.V512 (#128365) just landed; AVX-512 IFMA is its natural sibling on the EVEX side. The shape I'd implement looks like
Avx512Ifma(parentAvx512F) with a nested.V512for the 512-bit forms — the exact split-pattern from the AvxVnni.V512 work that's now in.AVX-512 IFMAis enumerated by its own CPUID bit (separate fromAVX-IFMA), so the V128/V256 path can be unavailable while V512 is present and vice-versa — the nested.V512gate is the right shape for that. Naturally pairs with the VEX-form AVX-IFMA in #98833; happy to take them in sequence, smaller surface (#98833) first then this.Confirming the
api-approvedscope is still current and there's no reason to wait (e.g., behind a planned restructuring) before I open the PR. As with #98833, not opening anything until you confirm — keen to avoid a #129326-style close.jamesburton commentedon Jun 30, 2026
Bundling with #98833 per Tanner's direction (see #98833 (comment)) — single PR using the
AvxIfma+ nestedAvxIfma.V512shape (mirrors the AvxVnni.V512 pattern landed in #128365, and the restructuring @saucecontrol pre-proposed above on 2024-11-06). Will close both this and #98833 on merge.