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

Add some common shuffles #98

Merged
merged 3 commits into from
Apr 21, 2021
Merged

Add some common shuffles #98

merged 3 commits into from
Apr 21, 2021

Conversation

calebzulawski
Copy link
Member

Skipping rotate etc right now, since it depends on some more const eval that we don't have.

Copy link
Member

@workingjubilee workingjubilee left a comment

Choose a reason for hiding this comment

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

Ahaha, I love it.

I agree with adding these operations.
It would be nice to prove they are optimized on aarch64 or even on x86_64 before we stabilize these, but I will leave that thought for future "verify vectorization" efforts.

We do need to unfortunately be agonizingly clear as to what ordering is gained from these ops, though.

fn reverse seems fine. I could see bikeshedding over fn interleave, (mostly because deinterleave seems verbose) but eh, the name seems fine, really! Just needs clear docs, is all.

crates/core_simd/src/permute.rs Show resolved Hide resolved
Comment on lines 32 to 40
/// Interleave two vectors.
///
/// The even lanes of the first result contain the lower half of `self`, and the odd
/// lanes contain the lower half of `other`.
///
/// The even lanes of the second result contain the upper half of `self`, and the odd
/// lanes contain the upper half of `other`.
#[inline]
pub fn interleave(self, other: Self) -> (Self, Self) {
Copy link
Member

Choose a reason for hiding this comment

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

We should address the case of lane numbering ("are we indexing from zero or one?") explicitly here if we are going to use "even" or "odd". Likewise, "upper" and "lower" need an explicit meaning.

"Interleave" feels slightly uncommon as a vocabulary word, even though it is a technically correct term, so in the documentation itself consider using "alternating" to describe this phenomenon: as-is, going by these remarks, I have to visualize the elements moving before I realize it is in fact alternating.

I don't thiiink I would want to use "zip" like Arm does to describe this, but am unsure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I agree that all of those definitions are a little vague. There's probably a clearer way to describe it, but I'm not sure what that is.

crates/core_simd/src/permute.rs Outdated Show resolved Hide resolved
@calebzulawski
Copy link
Member Author

interleave and deinterleave could certainly be zip and unzip (like the arm instruction names). Intel uses pack and unpack which I'm not a fan of. My only concern was that zip could get confused with iterator zipping (though it's fairly similar, I guess?)

@workingjubilee
Copy link
Member

workingjubilee commented Apr 21, 2021

This looks much better now.
I agree that "pack" and "unpack" is really... unfitting, and that zip/unzip risks some confusion. Maybe we'll come back to it, but not now.

@workingjubilee workingjubilee merged commit 2fa62b9 into master Apr 21, 2021
@calebzulawski calebzulawski deleted the feature/common-shuffles branch August 7, 2021 18:19
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.

2 participants