Skip to content

Fix/neg avx512f - #1423

Open
emrys53 wants to merge 3 commits into
xtensor-stack:masterfrom
emrys53:fix/neg-avx512f
Open

emrys53 wants to merge 3 commits into
xtensor-stack:masterfrom
emrys53:fix/neg-avx512f

Conversation

@emrys53

@emrys53 emrys53 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

The neg function for avx512f was different from the implementations of avx and sse. It produced different results from scalar counterpart in the case of signed zero. neg(+0.0) returned +0.0 instead of -0.0. It now uses a similar implementation in avx512f as avx and sse.
I also added a missing XSIMD_INLINE and noexcept that I realized was missing in the avx neg function. (This is unrelated to the fix, but since it was one line change I added it anyway).
The tests were written by AI and now it tests for signbit when __FAST_MATH__ is not defined.

emrys53 and others added 3 commits October 7, 2026 16:48
…lar implementation in signed zero case and made it similar to avx/sse implementations
The existing neg tests compare with ==, under which +0 == -0, so they
pass against a kernel that evaluates 0 - x instead of flipping the sign
bit. Check the sign bit explicitly: across every lane of the batch
arithmetic test, and for the scalar and batch overloads in the api test.

Both are guarded by __FAST_MATH__, which implies -fno-signed-zeros and
makes the property untestable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@serge-sans-paille

Copy link
Copy Markdown
Contributor

Thanks for disclosing AI usage for the tests. Implementation and tests looks good.

@serge-sans-paille

Copy link
Copy Markdown
Contributor

looks like the s390x build fails on the new test case. @emrys53 would you mind having a look?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants