Skip to content

Refactor SIMD ifdefs #797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged

Refactor SIMD ifdefs #797

merged 1 commit into from
May 1, 2025

Conversation

byroot
Copy link
Member

@byroot byroot commented May 1, 2025

The extconf check if SIMD is available, but then later on the simd.h header has extra logic to decide if it uses it or not.

e.g. for SSE2 we have:

if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) ||
  defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)

Which exclude i686 builds.

Hence if we're not entering that #if we can end up with JSON_ENABLE_SIMD=1 but neither HAVE_SIMD_NEON nor HAVE_SIMD_SSE2.

So instead of relying on JSON_ENABLE_SIMD to check if any SIMD implementation is available, this commit introduce HAVE_SIMD.

FYI: @hsbt @samyron

The extconf check if SIMD is available, but then later on
the `simd.h` header has extra logic to decide if it uses
it or not.

e.g. for SSE2 we have:

```
if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) ||
   defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
```

Which exclude i686 builds.

Hence if we're not entering that `#if` we can end up with
`JSON_ENABLE_SIMD=1` but neither `HAVE_SIMD_NEON` nor `HAVE_SIMD_SSE2`.

So instead of relying on `JSON_ENABLE_SIMD` to check if any SIMD
implementation is available, this commit introduce `HAVE_SIMD`.
@byroot byroot force-pushed the simd-detection branch from 0604aa4 to 220e019 Compare May 1, 2025 07:29
@byroot byroot merged commit 4a9564f into ruby:master May 1, 2025
34 checks passed
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.

1 participant