Skip to content

feat(simd): x86_64 baseline of SSE4.2, architecture-aware USE_SIMD - #5411

Open
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-usesimd
Open

feat(simd): x86_64 baseline of SSE4.2, architecture-aware USE_SIMD#5411
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-usesimd

Conversation

@lgritz

@lgritz lgritz commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

USE_SIMD defaulted to empty, so we inherited whatever the compiler chose: SSE2 for gcc/clang on Linux, penryn (SSE4.1, no 4.2) for Apple clang, and plain SSE2 for MSVC, which never predefines the SSE* macros that simd.h keys off and which no Windows CI job overrides. Every x86-64 CPU has had SSE4.2 since 2008, so we were leaving the 32 OIIO_SIMD_SSE >= 4 fast paths on the floor for no reason.

Default USE_SIMD to sse4.2 when targeting x86_64, and leave it empty elsewhere -- NEON is architecturally mandatory on ARMv8-A, so aarch64 needs no help. USE_SIMD=0 still disables everything.

The block also had no notion of the target architecture at all: -m${feature} was a blind passthrough, so USE_SIMD=avx2,f16c on ARM emitted -mavx2 and failed to compile, which is why every ARM CI job leaves USE_SIMD unset. Now tokens are classified, tokens for the wrong CPU family are skipped with a status message, ARM tokens (neon, armv8.2-a+fp16, apple-m1, mcpu=...) are understood, and universal Apple builds qualify the x86 flags with -Xarch_x86_64 rather than handing -msse4.2 to the arm64 slice.

For MSVC on x64, emit the SSE4 defines unconditionally rather than only when the user names those tokens, and let simd.h reach the same conclusion on its own so that downstream users of the installed header benefit too. This is safe because MSVC exposes every intrinsic through AVX2 regardless of /arch:. gcc and clang do gate intrinsics on -m flags, so the header cannot do the same for them; that limitation is now documented in simd.h and INSTALL.md.

Assisted-by: Claude Code / claude-opus-5

USE_SIMD defaulted to empty, so we inherited whatever the compiler chose:
SSE2 for gcc/clang on Linux, penryn (SSE4.1, no 4.2) for Apple clang, and
plain SSE2 for MSVC, which never predefines the __SSE*__ macros that simd.h
keys off and which no Windows CI job overrides. Every x86-64 CPU has had
SSE4.2 since 2008, so we were leaving the 32 OIIO_SIMD_SSE >= 4 fast paths on
the floor for no reason.

Default USE_SIMD to sse4.2 when targeting x86_64, and leave it empty
elsewhere -- NEON is architecturally mandatory on ARMv8-A, so aarch64 needs
no help. USE_SIMD=0 still disables everything.

The block also had no notion of the target architecture at all: -m${feature}
was a blind passthrough, so USE_SIMD=avx2,f16c on ARM emitted -mavx2 and
failed to compile, which is why every ARM CI job leaves USE_SIMD unset. Now
tokens are classified, tokens for the wrong CPU family are skipped with a
status message, ARM tokens (neon, armv8.2-a+fp16, apple-m1, mcpu=...) are
understood, and universal Apple builds qualify the x86 flags with
-Xarch_x86_64 rather than handing -msse4.2 to the arm64 slice.

For MSVC on x64, emit the SSE4 defines unconditionally rather than only when
the user names those tokens, and let simd.h reach the same conclusion on its
own so that downstream users of the installed header benefit too. This is
safe because MSVC exposes every intrinsic through AVX2 regardless of /arch:.
gcc and clang do gate intrinsics on -m flags, so the header cannot do the
same for them; that limitation is now documented in simd.h and INSTALL.md.

Assisted-by: Claude Code / claude-opus-5

Signed-off-by: Larry Gritz <lg@larrygritz.com>
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