Vectorize Acosh for Vector64/128/256/512 and TensorPrimitives#126424
Vectorize Acosh for Vector64/128/256/512 and TensorPrimitives#126424stephentoub wants to merge 2 commits intomainfrom
Conversation
Add vectorized Acosh implementations for float and double across all SIMD vector types. - AcoshDouble: uses log identity (log(x + sqrt(x^2 - 1))) for vectorization - AcoshSingle: widens to double and calls AcoshDouble - Hook up TensorPrimitives.Acosh 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 SIMD-enabled Acosh support across Vector64/128/256/512 and enables vectorization for TensorPrimitives.Acosh (float/double), wiring everything through new implementations in VectorMath.
Changes:
- Exposes new
Vector64/128/256/512.AcoshAPIs (float/double) and updates the intrinsics ref surface. - Introduces
VectorMath.AcoshDouble/VectorMath.AcoshSingleimplementations used by the new vector APIs. - Enables
TensorPrimitives.Acoshvectorization for float/double and adjusts test tolerances.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs | Adds new Acosh overloads to the public ref surface for all vector widths. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/VectorMath.cs | Implements vectorized Acosh core routines used by vector APIs. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs | Adds Vector64.Acosh (float/double) and scalar fallback loop. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs | Adds Vector128.Acosh (float/double) with fallback composition. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs | Adds Vector256.Acosh (float/double) with fallback composition. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs | Adds Vector512.Acosh (float/double) with fallback composition. |
| src/libraries/System.Numerics.Tensors/tests/TensorPrimitives.Generic.cs | Updates Acosh tolerance used by generic tensor tests. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Acosh.cs | Makes Acosh vectorizable for float/double and routes vector calls to Vector*.Acosh. |
Comments suppressed due to low confidence (3)
src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs:490
- Same ordering issue as above:
Acoshshould appear beforeAsinin this alphabetically ordered list of Vector256 APIs. Please reorder to maintain consistent ref file ordering.
src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs:944 - Same ordering issue as above:
Acoshshould be listed beforeAsinin the Vector512 ref API list (the surrounding entries are alphabetically ordered).
src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs:1397 - Same ordering issue as above:
Acoshshould be listed beforeAsinin the Vector64 ref API list to preserve alphabetical ordering.
src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/VectorMath.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/VectorMath.cs
Outdated
Show resolved
Hide resolved
|
@copilot please evaluate and address the feedback |
|
Note This review was generated by Copilot. 🤖 Copilot Code Review — PR #126424Holistic AssessmentMotivation: Vectorizing Approach: The implementation correctly uses the identity Summary: Detailed Findings
|
…racy, fix comment Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/43d57cf9-0cfe-4d16-9977-8c3294328c02 Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Addressed all three feedback items in 3544d66:
All 1575 TensorPrimitives tests pass (including Acosh with |
Description
Add vectorized Acosh implementations for float and double across all SIMD vector types.
Changes:
Vector64/128/256/512.AcoshAPIs (float/double) and updates the intrinsics ref surface in correct alphabetical order.VectorMath.AcoshDouble/VectorMath.AcoshSingleimplementations used by the new vector APIs.AcoshDoubleuses(x-1)*(x+1)instead ofx²-1to avoid catastrophic cancellation near x=1, with a large-value optimization usinglog(2) + log(x)for x > 2^28.AcoshSinglewidens to double precision, callsAcoshDouble, and narrows the result back for improved accuracy.TensorPrimitives.Acoshvectorization for float/double with test tolerances of 1e-14 (double) and 1e-6 (float).