Skip to content

x86: add avx512 permvar.qi shims#5156

Merged
RalfJung merged 1 commit into
rust-lang:masterfrom
folkertdev:avx512-permvar-qi
Jul 4, 2026
Merged

x86: add avx512 permvar.qi shims#5156
RalfJung merged 1 commit into
rust-lang:masterfrom
folkertdev:avx512-permvar-qi

Conversation

@folkertdev

Copy link
Copy Markdown
Contributor

cc rust-lang/portable-simd#524

These instructions are used by portable-simd's swizzle_dyn.

The tests are taken straight from stdarch, I don't have the hardware to validate them. But the implementation is using existing logic so hopefully that is sufficient?

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Jul 3, 2026

@nazar-pc nazar-pc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the hardware to validate them

In case it is useful, Intel SDE can be used for running AVX512 on unsupported hardware, it is even used in CI here as an example.

GitHub Actions runners are also a mix of those that support AVX512 and those that do not. So it might be non-determinstically tested that way too.

View changes since this review

#[rustfmt::skip]
let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31);
let r = _mm256_permutexvar_epi8(idx, a);

@RalfJung RalfJung Jul 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the idx vector is all 1s? That doesn't seem like it tests very much...

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, many such cases...

Well, I remembered that we have an avx512 machine at work that I can ssh into, so I've made some tests with more arbitrary input and validated them on actual hardware.

Unfortunately stdarch CI is messed up right now, so I can't additionally test it there rust-lang/stdarch#2181.

unsafe fn test_mm_permutexvar_epi8() {
let idx = _mm_set1_epi8(1);
let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
// Only the lower 4 bits of the index are used, the rest is masked off.

@RalfJung RalfJung Jul 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a u8::MAX in each of these to make it obvious that we are testing the masking.

View changes since the review

@RalfJung

RalfJung commented Jul 4, 2026

Copy link
Copy Markdown
Member

Thanks for the real HW test. :)

You can also already squash the commits.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Jul 4, 2026
@rustbot

rustbot commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@folkertdev folkertdev force-pushed the avx512-permvar-qi branch from 81c681e to 8b18dc8 Compare July 4, 2026 10:48
@RalfJung RalfJung enabled auto-merge July 4, 2026 11:16
@RalfJung RalfJung added this pull request to the merge queue Jul 4, 2026
Merged via the queue into rust-lang:master with commit 9f6397b Jul 4, 2026
14 checks passed
@rustbot rustbot removed the S-waiting-on-author Status: Waiting for the PR author to address review comments label Jul 4, 2026
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.

4 participants