Skip to content

[API Proposal]: Arm64: FEAT_SVE: mask part 2 #98184

Closed

Description

@tannergooding

This is a continuation of #93964

namespace System.Runtime.Intrinsics.Arm;

/// VectorT Summary
public abstract partial class Sve : AdvSimd /// Feature: FEAT_SVE  Category: mask
{
  /// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe Vector<T> ConditionalSelect(Vector<T> mask, Vector<T> left, Vector<T> right); // SEL

  /// T: sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateBreakAfterMask(Vector<T> mask, Vector<T> from); // BRKA // predicated

  /// T: sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateBreakAfterPropagateMask(Vector<T> mask, Vector<T> left, Vector<T> right); // BRKPA

  /// T: sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateBreakBeforeMask(Vector<T> mask, Vector<T> from); // BRKB // predicated

  /// T: sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateBreakBeforePropagateMask(Vector<T> mask, Vector<T> left, Vector<T> right); // BRKPB

  /// T: byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateWhileLessThanMask(int left, int right); // WHILELT

  /// T: byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateWhileLessThanMask(long left, long right); // WHILELT

  /// T: byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateWhileLessThanMask(uint left, uint right); // WHILELO

  /// T: byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateWhileLessThanMask(ulong left, ulong right); // WHILELO

  /// T: byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateWhileLessThanOrEqualMask(int left, int right); // WHILELE

  /// T: byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateWhileLessThanOrEqualMask(long left, long right); // WHILELE

  /// T: byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateWhileLessThanOrEqualMask(uint left, uint right); // WHILELS

  /// T: byte, ushort, uint, ulong
  public static unsafe Vector<T> CreateWhileLessThanOrEqualMask(ulong left, ulong right); // WHILELS

  /// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe T ExtractAfterLast(Vector<T> value); // LASTA // predicated

  /// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe T ExtractLast(Vector<T> value); // LASTB // predicated

  /// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe Vector<T> ExtractVector(Vector<T> upper, Vector<T> lower, ulong index); // EXT // MOVPRFX

  public static unsafe Vector<byte> FalseMask(); // PFALSE

  /// T: byte, ushort, uint, ulong
  public static unsafe Vector<T> MaskGetFirstSet(Vector<T> mask, Vector<T> from); // PNEXT

  /// T: sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe Vector<T> MaskSetFirst(Vector<T> mask, Vector<T> from); // PFIRST

  /// T: sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe bool MaskTestAnyTrue(Vector<T> mask, Vector<T> from); // PTEST

  /// T: sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe bool MaskTestFirstTrue(Vector<T> mask, Vector<T> from); // PTEST

  /// T: sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe bool MaskTestLastTrue(Vector<T> mask, Vector<T> from); // PTEST

  /// T: sbyte, short, int, long, byte, ushort, uint, ulong
  public static unsafe Vector<T> PropagateBreak(Vector<T> left, Vector<T> right); // BRKN // predicated

  public static unsafe Vector<byte> TrueMask(); // PTRUE

  public static unsafe Vector<byte> TrueMask([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All); // PTRUE


  // All patterns used by PTRUE.
  public enum SveMaskPattern : byte
  {
    LargestPowerOf2 = 0,   // The largest power of 2.
    VectorCount1 = 1,    // 1 element.
    VectorCount2 = 2,    // 2 elements.
    VectorCount3 = 3,    // 3 elements.
    VectorCount4 = 4,    // 4 elements.
    VectorCount5 = 5,    // 5 elements.
    VectorCount6 = 6,    // 6 elements.
    VectorCount7 = 7,    // 7 elements.
    VectorCount8 = 8,    // 8 elements.
    VectorCount16 = 9,   // 16 elements.
    VectorCount32 = 10,  // 32 elements.
    VectorCount64 = 11,  // 64 elements.
    VectorCount128 = 12, // 128 elements.
    VectorCount256 = 13, // 256 elements.
    LargestMultipleOf4 = 29,  // The largest multiple of 4.
    LargestMultipleOf3 = 30,  // The largest multiple of 3.
    All  = 31    // All available (implicitly a multiple of two).
  };

  /// total method signatures: 45
}

Activity

  1. added
    api-suggestion
    on Feb 8, 2024
  2. added this to the 9.0.0 milestone on Feb 8, 2024
  3. added
    api-ready-for-review
    and removed
    api-suggestion
    on Feb 14, 2024
  4. bartonjs commented on Feb 15, 2024

    @bartonjs
    Member

    Video

    • CreateWhileLessThanMask depends on return overloading, which isn't legal; so it is changing to CreateWhileLessThanMaskNBit, i.e. CreateWhileLessThanMask8Bit, CreateWhileLessThanMask16Bit, CreateWhileLessThanMask32Bit, CreateWhileLessThanMask64Bit
    • ExtractAfterLast is expanded to ExtractAfterLastScalar and ExtractAfterLastVector
    • ExtractVector's final argument is [ConstExpected] byte index, not ulong index
    • FalseMask() => CreateFalseMask() so it has a verb
      • Then further to CreateFalseMaskByte, CreateFalseMaskSByte, etc, because it needs to vary the return type.
      • And similar to TrueMask
    • MaskGetFirstSet => CreateMaskForNextActiveElement
      • (mask, from) => (totalMask, fromMask)
    • MaskSetFirst => CreateMaskForFirstActiveElement
      • (mask, from) => (totalMask, fromMask)
    • MaskTestAnyTrue => TestAnyTrue
      • (mask, from) => (leftMask, rightMask)
    • PropagateBreak => CreateBreakPropagateMask
    namespace System.Runtime.Intrinsics.Arm;
    
    /// VectorT Summary
    public abstract partial class Sve : AdvSimd /// Feature: FEAT_SVE  Category: mask
    {
      /// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe Vector<T> ConditionalSelect(Vector<T> mask, Vector<T> left, Vector<T> right); // SEL
    
      /// T: sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateBreakAfterMask(Vector<T> totalMask, Vector<T> fromMask); // BRKA // predicated
    
      /// T: sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateBreakAfterPropagateMask(Vector<T> mask, Vector<T> left, Vector<T> right); // BRKPA
    
      /// T: sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateBreakBeforeMask(Vector<T> totalMask, Vector<T> fromMask); // BRKB // predicated
    
      /// T: sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateBreakBeforePropagateMask(Vector<T> mask, Vector<T> left, Vector<T> right); // BRKPB
    
      /// T: byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateWhileLessThanMask{8,16,32,64}Bit(int left, int right); // WHILELT
    
      /// T: byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateWhileLessThanMask{8,16,32,64}Bit(long left, long right); // WHILELT
    
      /// T: byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateWhileLessThanMask{8,16,32,64}Bit(uint left, uint right); // WHILELO
    
      /// T: byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateWhileLessThanMask{8,16,32,64}Bit(ulong left, ulong right); // WHILELO
    
      /// T: byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateWhileLessThanOrEqualMask{8,16,32,64}Bit(int left, int right); // WHILELE
    
      /// T: byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateWhileLessThanOrEqualMask{8,16,32,64}Bit(long left, long right); // WHILELE
    
      /// T: byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateWhileLessThanOrEqualMask{8,16,32,64}Bit(uint left, uint right); // WHILELS
    
      /// T: byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateWhileLessThanOrEqualMask{8,16,32,64}Bit(ulong left, ulong right); // WHILELS
    
      /// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe T ExtractAfterLastScalar(Vector<T> value); // LASTA // predicated
      public static unsafe Vector<T> ExtractAfterLastVector(Vector<T> value); // LASTA // predicated
    
      /// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe T ExtractLastScalar(Vector<T> value); // LASTB // predicated
      public static unsafe Vector<T> ExtractLastVector(Vector<T> value); // LASTB // predicated
    
      /// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe Vector<T> ExtractVector(Vector<T> upper, Vector<T> lower, [ConstExpected] byte index); // EXT // MOVPRFX
    
      public static unsafe Vector<byte> CreateFalseMaskByte(); // PFALSE
      public static unsafe Vector<sbyte> CreateFalseMaskSByte(); // PFALSE
      // repeat for Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double
    
      /// T: byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateMaskForNextActiveElement(Vector<T> totalMask, Vector<T> fromMask); // PNEXT
    
      /// T: sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateMaskForFirstActiveElement(Vector<T> totalMask, Vector<T> fromMask); // PFIRST
    
      /// T: sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe bool TestAnyTrue(Vector<T> leftMask, Vector<T> rightMask); // PTEST
    
      /// T: sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe bool TestFirstTrue(Vector<T> leftMask, Vector<T> rightMask); // PTEST
    
      /// T: sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe bool TestLastTrue(Vector<T> leftMask, Vector<T> rightMask); // PTEST
    
      /// T: sbyte, short, int, long, byte, ushort, uint, ulong
      public static unsafe Vector<T> CreateBreakPropagateMask(Vector<T> totalMask, Vector<T> fromMask); // BRKN // predicated
    
      public static unsafe Vector<byte> CreateTrueMaskByte([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All); // PTRUE
      public static unsafe Vector<sbyte> CreateTrueMaskSByte([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All); // PTRUE
      // repeat for Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double
    }
  5. added
    api-approved
    and removed
    api-ready-for-review
    on Feb 15, 2024
  6. added
    arm-sve
    on Jul 28, 2024
  7. modified the milestones: 9.0.0, 10.0.0 on Jul 28, 2024
  8. a74nh commented on Apr 15, 2025

    @a74nh
    Contributor

    All of these are in Sve.cs

    Available as experimental API in .NET 9.

  9. a74nh commented on May 1, 2025

    @a74nh
    Contributor

    Raised #115225 to cover the change in argument names for CreateBreak/CreateMask APIs

  10. locked and limited conversation to collaborators on Jun 1, 2025
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.Intrinsicsarm-sve

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions