Vectorize Atan for Vector64/128/256/512 and TensorPrimitives#126425
Vectorize Atan for Vector64/128/256/512 and TensorPrimitives#126425stephentoub wants to merge 2 commits intomainfrom
Conversation
Add vectorized Atan implementations for float and double across all SIMD vector types. - AtanDouble: AMD atan.c Remez(4,4) rational polynomial with 5-region argument reduction - AtanSingle: widens to double, uses AMD atanf.c Remez(2,2) rational polynomial - Hook up TensorPrimitives.Atan 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 Atan support across the intrinsic SIMD vector types and enables TensorPrimitives to use those vectorized implementations for float/double.
Changes:
- Adds
Vector64/128/256/512.AtanAPIs (float/double) and updates the System.Runtime.Intrinsics reference assembly surface area. - Implements vectorized
atankernels inVectorMath(double core and single via widening to double core). - Enables TensorPrimitives
Atanvectorization forfloat/double(NET11+) and updates tolerances in generic tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs | Adds new Atan API declarations for Vector64/128/256/512 in the ref assembly. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/VectorMath.cs | Introduces vectorized AtanDouble and AtanSingle implementations used by intrinsic vector APIs. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs | Adds Vector64.Atan(float/double) plus scalar fallback helper. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs | Adds Vector128.Atan(float/double) with accelerated path and fallback composition. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs | Adds Vector256.Atan(float/double) with accelerated path and fallback composition. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs | Adds Vector512.Atan(float/double) with accelerated path and fallback composition. |
| src/libraries/System.Numerics.Tensors/tests/TensorPrimitives.Generic.cs | Adjusts tolerances for Atan/AtanPi validation. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Atan.cs | Enables vectorization for Atan<T> when T is float/double (NET11+) by calling new vector intrinsics. |
|
@copilot please evaluate and address the feedback |
🤖 Copilot Code Review — PR #126425Note This review was generated by Copilot. Holistic AssessmentMotivation: Vectorizing Approach: The implementation correctly mirrors the established Summary: Detailed Findings✅ Mathematical Correctness — Verified for all special IEEE 754 valuesNaN: In ±Infinity: ±0: Falls to region 1 in both paths. Unconditional branch computation: All five reduced values are computed and then ✅ Pattern Consistency — Matches established Asin vectorization exactlyThe code structure mirrors the
✅ Test Changes — Appropriate tolerance valuesThe added tolerances ( ✅ Ref Assembly — Entries correctly placedThe 8 new entries (2 per vector width × 4 widths) in
|
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/03da1847-4eb4-48bf-8274-65090982c2a0 Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Added |
Add vectorized Atan implementations for float and double across all SIMD vector types, with corresponding unit tests.
Description
Vector64/128/256/512.AtanAPIs (float/double) and updates the System.Runtime.Intrinsics reference assembly surface area.atankernels inVectorMath(double core and single via widening to double core).Atanvectorization forfloat/double(NET11+) and updates tolerances in generic tests.AtanDoubleandAtanSingletest data toGenericMathTestMemberDatawith 29 test cases each, covering edge cases (±0, NaN, ±Infinity) and representative magnitudes using well-known mathematical constants.AtanDoubleTestandAtanSingleTestunit tests toVector64Tests.cs,Vector128Tests.cs,Vector256Tests.cs, andVector512Tests.cs, following the same[Theory]/[MemberData]pattern as the existingAsin,Cos, andSintests.