Skip to content

[API Proposal]: AVX512 BMM Intrinsics #123898

@alexcovington

Description

@alexcovington

Background and motivation

New AVX512 BMM (Bit Matrix Multiply and Bit Reversal) instructions have been published, and I would like to add support for these instructions as .NET intrinsics.

API Proposal

namespace System.Runtime.Intrinsics.X86
{
    public abstract class Avx512Bmm : Avx512F
    {
        public static new bool IsSupported { get; }

        public static Vector128<byte> ReverseBits(Vector128<byte> x);
        public static Vector256<byte> ReverseBits(Vector256<byte> x);
        public static Vector512<byte> ReverseBits(Vector512<byte> x);

        public static Vector256<ushort> BitMultiplyMatrix16x16WithOrReduction(Vector256<ushort> x, Vector256<ushort> y, Vector256<ushort> z);
        public static Vector512<ushort> BitMultiplyMatrix16x16WithOrReduction(Vector512<ushort> x, Vector512<ushort> y, Vector512<ushort> z);
        public static Vector256<ushort> BitMultiplyMatrix16x16WithXorReduction(Vector256<ushort> x, Vector256<ushort> y, Vector256<ushort> z);
        public static Vector512<ushort> BitMultiplyMatrix16x16WithXorReduction(Vector512<ushort> x, Vector512<ushort> y, Vector512<ushort> z);
    }
}

API Usage

Usage would be consistent with other AVX512 intrinsics:

Vector256<ushort> x = Vector256.Create((ushort)0x1);
Vector256<ushort> y = Vector256.Create((ushort)0x1);
Vector256<ushort> z = Vector256.Create((ushort)0x1011);
Vector256<ushort> result = Avx512Bmm.BitMatrix16x16x16MultiplyAddWithOrReduction(x, y, z);
// result = <0x1011, 0x1011, 0x1011, 0x1011, 0x1011, 0x1011, 0x1011, 0x1011,
//           0x1011, 0x1011, 0x1011, 0x1011, 0x1011, 0x1011, 0x1011, 0x1011>
Vector128<byte> x = Vector128.Create((byte)0xAA);
Vector128<byte> y = Avx512Bmm.ReverseBits(x);
// y = <0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
//      0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55>

Alternative Designs

BitMatrix16x16x16MultiplyAddWithOrReduction is a lengthy name, and I'm open to other suggestions.

Risks

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions