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.
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
Implement common swizzle operations. #335
base: master
Are you sure you want to change the base?
Implement common swizzle operations. #335
Changes from 10 commits
71baa3f
c28564d
ffe58c9
5d30d9f
024fb9a
4575d28
94b2f08
ae495bd
0c9a7ab
14904c9
73621ab
8c07d1a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
imho this should include something like
lanewise
in it's name, since I expect Rust to gain a bitwisegrev
at some point and we'd want the bitwise simd and scalar integer operations to have matching names (probablygen_rev
orgeneralized_reverse
orgrev
?).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.
For something that effectively implements a very specific xor-striding pattern,
general_reverse
is a non-descript name.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.
well,
grev
is what that particular bitwise op has become named, thanks to RISC-V afaict.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.
grev -- general bit reverse
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.
Just because an ISA has picked a terrible name doesn't mean we need to copy it.
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.
Looking at the precedent of
u32::count_ones
, it looks like the Rust standard library takes the convention of providing a more meaningful name (count_ones
) while maintaining searchability for the common namepopcnt
using#[doc(alias = "popcnt")]
, https://github.com/rust-lang/rust/blob/f1b1ed7e18f1fbe5226a96626827c625985f8285/library/core/src/num/int_macros.rs#L104. I think such an approach could be warranted here too, keepinggrev
as an alias. Indeed,grev
is a much less established term thanpopcnt
, so the precedent from grev is weaker.Other names I considered:
Currently I lean towards swap_lanes_xor. Open to other suggestions!
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.
swizzle_to_xor_indexes
?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.
reverse_pow2_lane_groups
? Conceptually this operation performs the reversal of blocks ofk
lanes withinn
-lane groups, wherek
andn
are both powers of two,k ≤ n ≤ LANES
, and the choice ofk
andn
is determined uniquely up to operation uniqueness by choosing where index0
will be swizzled to (it’ll be exactlySWAP_MASK
).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.
afaict
grev
is actually more powerful than that, it can do any arbitrary combination of thosek
-n
reversals for arbitraryk
andn
.e.g.
grev(v, 5)
is equivalent tosimd_swizzle!(v, [5, 4, 7, 6, 1, 0, 3, 2])
which is a combination of reversing adjacent pairs (blocks of 1) and swapping blocks of 4.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.
Thanks all for the suggestions. Of the proposals so far, my preference order is:
swizzle_to_xor_indices
butterfly_swizzle
grev
I have gone with
swizzle_to_xor_indices
. Let me know what you think.