Skip to content

Commit

Permalink
Arm64/SVE: Implemented ReciprocalEstimate, ReciprocalExponent, `R…
Browse files Browse the repository at this point in the history
…eciprocalSqrtEstimate`, `ReciprocalSqrtStep`, and `ReciprocalStep` (dotnet#103673)

* Added ConverToInt32 and ConvertToUInt32 for float inputs.

* Added flags to handle only low predicate registers.

* Fix whitespace

* Remove special codegen flag

* Added new test template for operations with different return types.

* Add new test template.

* Added api for ConvertToInt32 and ConvertToUInt 32 for double.

* Finished 4/5 Round intrinsics for sve fp.

* Completed ReciprocalExponent SVE api.

* Revert "Finished 4/5 Round intrinsics for sve fp."

This reverts commit aab2067.

* Reciprocal SVE apis - note: ReciprocalExponent still has issues.

* Completed ReciprocalExponent SVE api.

* fixed naming.

* Fixed some naming.

* fixed more affect function names.

* Fixed some more naming and retested. All stress tests pass.

* fixed more helper function naming.
  • Loading branch information
ebepho authored Jun 21, 2024
1 parent 4b9a1b2 commit 2b5c542
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 24 deletions.
5 changes: 5 additions & 0 deletions src/coreclr/jit/hwintrinsiclistarm64sve.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ HARDWARE_INTRINSIC(Sve, PrefetchBytes,
HARDWARE_INTRINSIC(Sve, PrefetchInt16, -1, 3, false, {INS_invalid, INS_invalid, INS_invalid, INS_sve_prfh, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_MemoryLoad, HW_Flag_Scalable|HW_Flag_SpecialCodeGen|HW_Flag_ExplicitMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_BaseTypeFromFirstArg|HW_Flag_HasImmediateOperand|HW_Flag_HasEnumOperand)
HARDWARE_INTRINSIC(Sve, PrefetchInt32, -1, 3, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_prfw, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_MemoryLoad, HW_Flag_Scalable|HW_Flag_SpecialCodeGen|HW_Flag_ExplicitMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_BaseTypeFromFirstArg|HW_Flag_HasImmediateOperand|HW_Flag_HasEnumOperand)
HARDWARE_INTRINSIC(Sve, PrefetchInt64, -1, 3, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_prfd, INS_invalid, INS_invalid}, HW_Category_MemoryLoad, HW_Flag_Scalable|HW_Flag_SpecialCodeGen|HW_Flag_ExplicitMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_BaseTypeFromFirstArg|HW_Flag_HasImmediateOperand|HW_Flag_HasEnumOperand)
HARDWARE_INTRINSIC(Sve, ReciprocalEstimate, -1, 1, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_frecpe, INS_sve_frecpe}, HW_Category_SIMD, HW_Flag_Scalable)
HARDWARE_INTRINSIC(Sve, ReciprocalExponent, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_frecpx, INS_sve_frecpx}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, ReciprocalSqrtEstimate, -1, 1, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_frsqrte, INS_sve_frsqrte}, HW_Category_SIMD, HW_Flag_Scalable)
HARDWARE_INTRINSIC(Sve, ReciprocalSqrtStep, -1, 2, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_frsqrts, INS_sve_frsqrts}, HW_Category_SIMD, HW_Flag_Scalable)
HARDWARE_INTRINSIC(Sve, ReciprocalStep, -1, 2, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_frecps, INS_sve_frecps}, HW_Category_SIMD, HW_Flag_Scalable)
HARDWARE_INTRINSIC(Sve, ReverseBits, -1, -1, false, {INS_sve_rbit, INS_sve_rbit, INS_sve_rbit, INS_sve_rbit, INS_sve_rbit, INS_sve_rbit, INS_sve_rbit, INS_sve_rbit, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, ReverseElement, -1, 1, true, {INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev, INS_sve_rev}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_SpecialCodeGen)
HARDWARE_INTRINSIC(Sve, ReverseElement16, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_revh, INS_sve_revh, INS_sve_revh, INS_sve_revh, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4445,6 +4445,85 @@ internal Arm64() { }
public static unsafe void PrefetchInt64(Vector<ulong> mask, void* address, [ConstantExpected] SvePrefetchType prefetchType) { throw new PlatformNotSupportedException(); }


/// ReciprocalEstimate : Reciprocal estimate

/// <summary>
/// svfloat64_t svrecpe[_f64](svfloat64_t op)
/// FRECPE Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<double> ReciprocalEstimate(Vector<double> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svrecpe[_f32](svfloat32_t op)
/// FRECPE Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<float> ReciprocalEstimate(Vector<float> value) { throw new PlatformNotSupportedException(); }


/// ReciprocalExponent : Reciprocal exponent

/// <summary>
/// svfloat64_t svrecpx[_f64]_m(svfloat64_t inactive, svbool_t pg, svfloat64_t op)
/// FRECPX Ztied.D, Pg/M, Zop.D
/// svfloat64_t svrecpx[_f64]_x(svbool_t pg, svfloat64_t op)
/// FRECPX Ztied.D, Pg/M, Ztied.D
/// svfloat64_t svrecpx[_f64]_z(svbool_t pg, svfloat64_t op)
/// </summary>
public static unsafe Vector<double> ReciprocalExponent(Vector<double> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svrecpx[_f32]_m(svfloat32_t inactive, svbool_t pg, svfloat32_t op)
/// FRECPX Ztied.S, Pg/M, Zop.S
/// svfloat32_t svrecpx[_f32]_x(svbool_t pg, svfloat32_t op)
/// FRECPX Ztied.S, Pg/M, Ztied.S
/// svfloat32_t svrecpx[_f32]_z(svbool_t pg, svfloat32_t op)
/// </summary>
public static unsafe Vector<float> ReciprocalExponent(Vector<float> value) { throw new PlatformNotSupportedException(); }


/// ReciprocalSqrtEstimate : Reciprocal square root estimate

/// <summary>
/// svfloat64_t svrsqrte[_f64](svfloat64_t op)
/// FRSQRTE Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<double> ReciprocalSqrtEstimate(Vector<double> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svrsqrte[_f32](svfloat32_t op)
/// FRSQRTE Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<float> ReciprocalSqrtEstimate(Vector<float> value) { throw new PlatformNotSupportedException(); }


/// ReciprocalSqrtStep : Reciprocal square root step

/// <summary>
/// svfloat64_t svrsqrts[_f64](svfloat64_t op1, svfloat64_t op2)
/// FRSQRTS Zresult.D, Zop1.D, Zop2.D
/// </summary>
public static unsafe Vector<double> ReciprocalSqrtStep(Vector<double> left, Vector<double> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svrsqrts[_f32](svfloat32_t op1, svfloat32_t op2)
/// FRSQRTS Zresult.S, Zop1.S, Zop2.S
/// </summary>
public static unsafe Vector<float> ReciprocalSqrtStep(Vector<float> left, Vector<float> right) { throw new PlatformNotSupportedException(); }


/// ReciprocalStep : Reciprocal step

/// <summary>
/// svfloat64_t svrecps[_f64](svfloat64_t op1, svfloat64_t op2)
/// FRECPS Zresult.D, Zop1.D, Zop2.D
/// </summary>
public static unsafe Vector<double> ReciprocalStep(Vector<double> left, Vector<double> right) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svrecps[_f32](svfloat32_t op1, svfloat32_t op2)
/// FRECPS Zresult.S, Zop1.S, Zop2.S
/// </summary>
public static unsafe Vector<float> ReciprocalStep(Vector<float> left, Vector<float> right) { throw new PlatformNotSupportedException(); }
/// Reverse bits

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4499,6 +4499,86 @@ internal Arm64() { }
/// </summary>
public static unsafe void PrefetchInt64(Vector<ulong> mask, void* address, [ConstantExpected] SvePrefetchType prefetchType) => PrefetchInt64(mask, address, prefetchType);


/// ReciprocalEstimate : Reciprocal estimate

/// <summary>
/// svfloat64_t svrecpe[_f64](svfloat64_t op)
/// FRECPE Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<double> ReciprocalEstimate(Vector<double> value) => ReciprocalEstimate(value);

/// <summary>
/// svfloat32_t svrecpe[_f32](svfloat32_t op)
/// FRECPE Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<float> ReciprocalEstimate(Vector<float> value) => ReciprocalEstimate(value);


/// ReciprocalExponent : Reciprocal exponent

/// <summary>
/// svfloat64_t svrecpx[_f64]_m(svfloat64_t inactive, svbool_t pg, svfloat64_t op)
/// FRECPX Ztied.D, Pg/M, Zop.D
/// svfloat64_t svrecpx[_f64]_x(svbool_t pg, svfloat64_t op)
/// FRECPX Ztied.D, Pg/M, Ztied.D
/// svfloat64_t svrecpx[_f64]_z(svbool_t pg, svfloat64_t op)
/// </summary>
public static unsafe Vector<double> ReciprocalExponent(Vector<double> value) => ReciprocalExponent(value);

/// <summary>
/// svfloat32_t svrecpx[_f32]_m(svfloat32_t inactive, svbool_t pg, svfloat32_t op)
/// FRECPX Ztied.S, Pg/M, Zop.S
/// svfloat32_t svrecpx[_f32]_x(svbool_t pg, svfloat32_t op)
/// FRECPX Ztied.S, Pg/M, Ztied.S
/// svfloat32_t svrecpx[_f32]_z(svbool_t pg, svfloat32_t op)
/// </summary>
public static unsafe Vector<float> ReciprocalExponent(Vector<float> value) => ReciprocalExponent(value);


/// ReciprocalSqrtEstimate : Reciprocal square root estimate

/// <summary>
/// svfloat64_t svrsqrte[_f64](svfloat64_t op)
/// FRSQRTE Zresult.D, Zop.D
/// </summary>
public static unsafe Vector<double> ReciprocalSqrtEstimate(Vector<double> value) => ReciprocalSqrtEstimate(value);

/// <summary>
/// svfloat32_t svrsqrte[_f32](svfloat32_t op)
/// FRSQRTE Zresult.S, Zop.S
/// </summary>
public static unsafe Vector<float> ReciprocalSqrtEstimate(Vector<float> value) => ReciprocalSqrtEstimate(value);


/// ReciprocalSqrtStep : Reciprocal square root step

/// <summary>
/// svfloat64_t svrsqrts[_f64](svfloat64_t op1, svfloat64_t op2)
/// FRSQRTS Zresult.D, Zop1.D, Zop2.D
/// </summary>
public static unsafe Vector<double> ReciprocalSqrtStep(Vector<double> left, Vector<double> right) => ReciprocalSqrtStep(left, right);

/// <summary>
/// svfloat32_t svrsqrts[_f32](svfloat32_t op1, svfloat32_t op2)
/// FRSQRTS Zresult.S, Zop1.S, Zop2.S
/// </summary>
public static unsafe Vector<float> ReciprocalSqrtStep(Vector<float> left, Vector<float> right) => ReciprocalSqrtStep(left, right);


/// ReciprocalStep : Reciprocal step

/// <summary>
/// svfloat64_t svrecps[_f64](svfloat64_t op1, svfloat64_t op2)
/// FRECPS Zresult.D, Zop1.D, Zop2.D
/// </summary>
public static unsafe Vector<double> ReciprocalStep(Vector<double> left, Vector<double> right) => ReciprocalStep(left, right);

/// <summary>
/// svfloat32_t svrecps[_f32](svfloat32_t op1, svfloat32_t op2)
/// FRECPS Zresult.S, Zop1.S, Zop2.S
/// </summary>
public static unsafe Vector<float> ReciprocalStep(Vector<float> left, Vector<float> right) => ReciprocalStep(left, right);
/// Reverse bits

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4826,6 +4826,17 @@ internal Arm64() { }
public static unsafe void PrefetchInt32(System.Numerics.Vector<uint> mask, void* address, [ConstantExpected] SvePrefetchType prefetchType) { throw null; }
public static unsafe void PrefetchInt64(System.Numerics.Vector<ulong> mask, void* address, [ConstantExpected] SvePrefetchType prefetchType) { throw null; }

public static System.Numerics.Vector<double> ReciprocalEstimate(System.Numerics.Vector<double> value) { throw null; }
public static System.Numerics.Vector<float> ReciprocalEstimate(System.Numerics.Vector<float> value) { throw null; }
public static System.Numerics.Vector<double> ReciprocalExponent(System.Numerics.Vector<double> value) { throw null; }
public static System.Numerics.Vector<float> ReciprocalExponent(System.Numerics.Vector<float> value) { throw null; }
public static System.Numerics.Vector<double> ReciprocalSqrtEstimate(System.Numerics.Vector<double> value) { throw null; }
public static System.Numerics.Vector<float> ReciprocalSqrtEstimate(System.Numerics.Vector<float> value) { throw null; }
public static System.Numerics.Vector<double> ReciprocalSqrtStep(System.Numerics.Vector<double> left, System.Numerics.Vector<double> right) { throw null; }
public static System.Numerics.Vector<float> ReciprocalSqrtStep(System.Numerics.Vector<float> left, System.Numerics.Vector<float> right) { throw null; }
public static System.Numerics.Vector<double> ReciprocalStep(System.Numerics.Vector<double> left, System.Numerics.Vector<double> right) { throw null; }
public static System.Numerics.Vector<float> ReciprocalStep(System.Numerics.Vector<float> left, System.Numerics.Vector<float> right) { throw null; }

public static System.Numerics.Vector<byte> ReverseBits(System.Numerics.Vector<byte> value) { throw null; }
public static System.Numerics.Vector<short> ReverseBits(System.Numerics.Vector<short> value) { throw null; }
public static System.Numerics.Vector<int> ReverseBits(System.Numerics.Vector<int> value) { throw null; }
Expand Down
Loading

0 comments on commit 2b5c542

Please sign in to comment.