-
Notifications
You must be signed in to change notification settings - Fork 92
swizzle_dyn: 64 byte swizzle_dyn for AVX2 #480
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
base: master
Are you sure you want to change the base?
Conversation
3bdb528
to
c045fbe
Compare
use x86::_mm256_permute2x128_si256 as avx2_cross_shuffle; | ||
use x86::_mm256_shuffle_epi8 as avx2_half_pshufb; | ||
let high = Simd::splat(64u8); | ||
// SAFETY: Caller promised AVX2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should probably add more safety comments, e.g. answer why is the transmute
sound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added one for the transmute
. Can't really think of anywhere else where its required.
The |
@jhorstmann Agreed. |
@@ -220,6 +220,8 @@ unsafe fn avx2_pshufb512(bytes: Simd<u8, 64>, idxs: Simd<u8, 64>) -> Simd<u8, 64 | |||
|
|||
let z0 = half_swizzler(bytes0, bytes1, idxs0); | |||
let z1 = half_swizzler(bytes0, bytes1, idxs1); | |||
|
|||
// SAFETY: Concatenation of two 32-element vectors to one 64-element vector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this says what your doing, what it should say is why it's safe to use transmute
like this. e.g.:
[Simd<u8, 32>; 2]
and Simd<u8, 64>
both have the same size (64) and no padding bytes, so transmuting is safe
Implemented a 64 bit
swizzle_dyn
for AVX2.Use case: Encountered this while implementing a chess move generator in rust with portable simd.
Would like an alternative suggestion for use of
mem::transmute
here.