-
Notifications
You must be signed in to change notification settings - Fork 92
Remove poor-performing bitmasks, add Select trait, and enable select on integer bitmasks #482
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
…it that also supports bitmasks.
I'm not so sure that we don't want an opaque If we want known-layout mask types, we could just export the |
Full vector With this change you can still use My issue with keeping them the same type is that |
If we had a magic |
RVV doesn't have the bitmask implementation cfged right now anyway, but for reference, here's how those same two functions compile with it:
|
I'm fine if we temporarily don't have the bitmask |
So maybe I keep this PR how it is (with the new Select trait) but add back the unspecified layout documentation. I'll make a follow up PR that changes the generic type to be the vector type rather than the full width mask integer type. With the addition of the Select trait it should make it possible to do e.g. |
I think the full mask type should have the contained |
6efa217
to
da8fe78
Compare
Ok, I reverted masks to have an unspecified layout. My plan in the follow-up is to change masks to This PR now just removes the bitmask implementation and changes |
da8fe78
to
cd88ff3
Compare
cd88ff3
to
45a18ae
Compare
} else { | ||
// Safety: bitmask matches length | ||
unsafe { to_bitmask_impl::<T, u64, 64, N>(self) } | ||
} |
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.
maybe add a todo!()
for N > 64
?
@@ -450,7 +491,8 @@ where | |||
type Output = Self; | |||
#[inline] | |||
fn bitand(self, rhs: Self) -> Self { | |||
Self(self.0 & rhs.0) |
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 can just stay unchanged -- same for all the other bitwise ops.
Summary:
Mask<T, N>
==Simd<T, N>
0b0101.select(a, b)
This is a compromise. My justification:
cfg
and buildingstd
from source isn't really a good option. By providing both we can at least allow using each mask type in the same program depending on detected target features.Mask<T, N>
is equivalent toSimd<T, N>
in layout, I think we can finally put Change Mask element to match Simd element #322 to rest.Since
Mask
is still represented as<N x i1>
in LLVM, I think this mostly just affects memory layout. I think this actually improves codegen since the full width version ofMask
is more transparent than the (deleted in this PR) AVX512 bitmask version.Also, this PR allows selecting any vector from any width Mask with the same number of elements. I'm not sure if that should be supported or not, but Masks already implement
Into
to each other.This is the first item on my list for trying to get everything resolved for stabilization :)