Add xsimd::get<>() for optimized compile-time element extraction#1294
Open
DiamonDinoia wants to merge 1 commit intoxtensor-stack:masterfrom
Open
Add xsimd::get<>() for optimized compile-time element extraction#1294DiamonDinoia wants to merge 1 commit intoxtensor-stack:masterfrom
DiamonDinoia wants to merge 1 commit intoxtensor-stack:masterfrom
Conversation
0b6d85f to
c6dd311
Compare
Contributor
Author
|
Nice thanks for fixing CI! This is ready for review. Once approved I will rewrite the history. I don't want to trigger a useless CI run. |
serge-sans-paille
requested changes
Apr 16, 2026
| void check_get_all(batch_type const& res, std::index_sequence<Is...>) const | ||
| { | ||
| int dummy[] = { (check_get_element<Is>(res), 0)... }; | ||
| (void)dummy; |
Contributor
There was a problem hiding this comment.
you could check that loading the generated array ends up being equal to res, right?
serge-sans-paille
requested changes
Apr 17, 2026
Contributor
serge-sans-paille
left a comment
There was a problem hiding this comment.
Please fix the testing so that we have a decent confidence in the getter when index != 0
Contributor
Author
Yes, I will! I also noticed some small changes I should make. I just did not have time to get to this still. |
5a371e7 to
fd8c743
Compare
Introduces get<I>(batch) as a top-level API for extracting a single lane
at a compile-time index. Falls back to the runtime get() when per-arch
overloads aren't present.
Per-arch optimal lowerings:
- SSE2: pextrw / byte-shift+movd / swizzle+first by lane width.
- SSE4.1: pextrb/w/d/q; I==0 short-circuits to first().
- AVX: I==0 short-circuits to first(); else halve + SSE4.1 path.
- AVX-512F: I==0 short-circuits to first(); 32/64-bit lanes use
valignd/valignq + first() (2 ops); 8/16-bit halve through AVX.
- NEON / NEON64 / RVV: native single-lane extract intrinsics.
fd8c743 to
f30c5e0
Compare
Contributor
Author
|
I like how it is now. I tried to minimize new code by re-using existing APIs. Tests check all values. |
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.
Add a free function xsimd::get(batch) API mirroring std::get(tuple) for fast compile-time element extraction from SIMD batches.
Per-architecture optimized kernel::get overloads using the fastest available intrinsics:
Also fixes a latent bug in the common fallback for complex batch compile-time get (wrong buffer type).