Vectorize Asinh for Vector64/128/256/512 and TensorPrimitives#126419
Vectorize Asinh for Vector64/128/256/512 and TensorPrimitives#126419stephentoub wants to merge 4 commits intomainfrom
Conversation
Add vectorized Asinh implementations for float and double across all SIMD vector types. - AsinhDouble: uses log identity (log(|x| + sqrt(x^2 + 1))) for vectorization - AsinhSingle: widens to double, uses AMD asinhf.c polynomial approximation - Hook up TensorPrimitives.Asinh to use vectorized implementations Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics |
There was a problem hiding this comment.
Pull request overview
Adds vectorized Asinh implementations for float/double across all SIMD vector widths and enables vectorization for TensorPrimitives.Asinh.
Changes:
- Exposes new
Vector64/128/256/512.Asinh(float|double)public APIs and wires them toVectorMathimplementations when hardware-accelerated. - Implements vectorized
asinhcore logic inVectorMathfordoubleandfloat(via widening todoubleand polynomial/range selection). - Enables
TensorPrimitives.Asinhvectorization forfloat/doubleonNET11_0_OR_GREATERand adjusts test tolerances accordingly.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs | Adds Asinh API surface to the reference assembly for Vector64/128/256/512. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/VectorMath.cs | Introduces the vectorized AsinhDouble/AsinhSingle implementations used by the SIMD APIs. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs | Adds Vector64.Asinh public APIs plus scalar fallback helper. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs | Adds Vector128.Asinh public APIs with accelerated and fallback paths. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs | Adds Vector256.Asinh public APIs with accelerated and fallback paths. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs | Adds Vector512.Asinh public APIs with accelerated and fallback paths. |
| src/libraries/System.Numerics.Tensors/tests/TensorPrimitives.Generic.cs | Updates Asinh test entry to use explicit tolerances for float/double. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Asinh.cs | Enables vectorization for TensorPrimitives.Asinh and adds vector invoke implementations. |
|
@copilot please evaluate and address the feedback |
This comment has been minimized.
This comment has been minimized.
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/75feae7d-528c-4fd6-aee8-88ccfa9c7841 Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/75feae7d-528c-4fd6-aee8-88ccfa9c7841 Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Added Note: Runtime test execution is blocked by a pre-existing SIGABRT crash in |
…t coverage - Fix redundant 'absx * absx' computation in AsinhSingleCoreDouble by reusing the existing 'x2' local variable. - Add test cases covering all code paths and thresholds: - Subnormals (5E-324 double, float.Epsilon) - Near-tiny values (1E-10 double, 1E-06f float) - AsinhSingleCoreDouble range B: 2 < |x| <= 4 (3.0f, 4.0f) - Log path: 4 < |x| <= 4096 (10.0, 100.0, 4096.0) - Large path: |x| > 4096 (10000.0f, 1E+10f) - AsinhDouble large threshold at 2^28 (268435456.0) - Very large values (1E+10 double) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🤖 Copilot Code Review — PR #126419Note This review was generated by GitHub Copilot using Holistic AssessmentMotivation: Vectorizing Approach: The PR uses two distinct strategies: a naive log-identity formula for double precision ( Summary: Detailed Findings
|
Description
Add vectorized Asinh implementations for float and double across all SIMD vector types, with comprehensive unit tests.
Implementation
Vector64/128/256/512.Asinh(float|double)public APIs and wires them toVectorMathimplementations when hardware-accelerated.asinhcore logic inVectorMathfordoubleandfloat(via widening todoubleand polynomial/range selection).TensorPrimitives.Asinhvectorization forfloat/doubleonNET11_0_OR_GREATERand adjusts test tolerances accordingly.Tests
AsinhDoubleandAsinhSingletest data toGenericMathTestMemberDatawith 31 test cases each, covering special values (±0, ±∞, NaN) and representative mathematical constants (±π, ±e, ±ln(10), ±π/2, ±log₂(e), ±√2, ±1, ±π/4, ±1/√2, ±ln(2), ±2/π, ±log₁₀(e), ±1/π) with appropriate variance tolerances.AsinhDoubleTestandAsinhSingleTestmethods toVector64Tests,Vector128Tests,Vector256Tests, andVector512Tests, following the same[Theory]/[MemberData]pattern as existingAsintests.