Skip to content
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

Portable vector shuffles #388

Closed
gnzlbg opened this issue Mar 20, 2018 · 3 comments
Closed

Portable vector shuffles #388

gnzlbg opened this issue Mar 20, 2018 · 3 comments

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 20, 2018

I've just submitted a PR with an API for portable vector shuffles (#387). From the docs:

// Shuffle allows reordering the elements of a vector:
let x = i32x4::new(1, 2, 3, 4);
let r = shuffle!(x, [2, 1, 3, 0]);
assert_eq!(r, i32x4::new(3, 2, 4, 1));

// The resulting vector can be smaller than the input:
let r = shuffle!(x, [1, 3]);
assert_eq!(r, i32x2::new(2, 4));

// Equal:
let r = shuffle!(x, [1, 3, 2, 0]);
assert_eq!(r, i32x4::new(2, 4, 3, 1));

// Or larger (at most twice as large):
et r = shuffle!(x, [1, 3, 2, 2, 1, 3, 2, 2]);
assert_eq!(r, i32x8::new(2, 4, 3, 3, 2, 4, 3, 3));

// It also allows reordering elements of two vectors:
let y = i32x4::new(5, 6, 7, 8);
let r = shuffle!(x, y, [4, 0, 5, 1]);
assert_eq!(r, i32x4::new(5, 1, 6, 2));
// And this can be used to construct larger or smaller
// vectors as well.

It would be nice to gather feed-back on this.

@TheIronBorn
Copy link
Contributor

TheIronBorn commented Jun 22, 2018

Does this API allow shuffling where the indices are unknown? i.e. using _mm_shuffle_epi8 where the indices vector is unknown? (useful for SIMD lookup "tables")

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jun 22, 2018 via email

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jul 19, 2018

This has been fixed in https://github.com/gnzlbg/packed_simd

@gnzlbg gnzlbg closed this as completed Jul 19, 2018
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

No branches or pull requests

3 participants