Repository navigation
[SYCL][libdevice] improve complex trig and pi ulp - #23375
Open
cperkinsintel wants to merge 3 commits into
Open
cperkinsintel wants to merge 3 commits into
cperkinsintel wants to merge 3 commits into
Conversation
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Contributor
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
Review effort: Lite
Findings: 1
Open (7)
id<1>does not support arithmetic/indexing the way this kernel uses it (4 * iandd_in[i]).… · New Same issue as incomplex_math.hpp:__has_include(<version>)should be guarded (e.g.,… · New__has_includeis not guaranteed to be available on all preprocessors, and using it unguarded can… · New These explicit specializations define non-inlinevariables in a header. If this header is… · New These explicit specializations define non-inlinevariables in a header. If this header is… · New These explicit specializations define non-inlinevariables in a header. If this header is… · New These explicit specializations define non-inlinevariables in a header. If this header is… · New
What changed in this PR
This PR improves correctness of complex inverse trig/hyperbolic functions for large-magnitude inputs on device by avoiding catastrophic cancellation and using a more reliable value of π, and adds/extends end-to-end coverage for the affected cases.
Changes:
- Add a new DeviceLib E2E test to compare
std::acos/asin/acosh/asinhon device vs host for large arguments. - Update complex math implementations (
acos/acosh/asinhand π constant selection) to avoid cancellation for negative real parts and fix π rounding issues. - Extend existing complex math test cases with additional “large argument” inputs for inverse functions.
| File | Description |
|---|---|
| sycl/test-e2e/DeviceLib/std_complex_inverse_trig_large_args.cpp | Adds a new E2E test exercising large-argument inverse complex functions on device. |
| sycl/test-e2e/Complex/sycl_complex_math_test_cases.hpp | Refactors default test values and appends large-argument cases for inverse functions. |
| sycl/include/sycl/ext/oneapi/experimental/complex/detail/complex_math.hpp | Switches π computation to a constant and updates inverse functions to avoid cancellation on negative real inputs. |
| libdevice/fallback-complex.hpp | Mirrors cancellation-avoidance logic and π constant usage for float complex fallbacks. |
| libdevice/fallback-complex-fp64.hpp | Mirrors cancellation-avoidance logic and π constant usage for double complex fallbacks. |
| libdevice/device_complex.h | Introduces a shared π definition used by libdevice complex implementations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Contributor
Author
|
The failure in llvm/sycl/test-e2e/USM/memops2d/memcpy2d_device_to_host.cpp (or device_to_device.cpp) on Arc is being seen by other PR as well. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Some of the inverse trig functions (acos, asin, acosh asinh) over complex numbers in SYCL have two problems:
z + sqrt(z^2 -+ 1)cancels catastrophically, its truevalue is smaler than the rounding error of its two terms.