Repository navigation
Add mask<->vector conversion methods - #400
Conversation
8d75a8e to
6590b49
Compare
|
The direction looks good to me, I'll take a closer look later. Thanks! |
6590b49 to
d433103
Compare
|
We generally try to align with std::simd on naming, because that's what other libs are also doing and it makes porting across the whole ecosystem really easy. But in our case to_simd sounds like it's going to give you the |
Shnatsel
left a comment
There was a problem hiding this comment.
I've pushed a change to specify more generic bounds, cargo-semver-checks is happy with it. PTAL.
We need to make a call on whether to align with std::simd and call this to_simd or keep the to_vector, I'm OK with either.
|
Personally, vote for |
974bf51 to
5e11b63
Compare
|
to_vector it is |
Resolves #398.
This PR adds methods for converting masks to and from vectors.
The
SimdMasktrait now has anIntsassociated type, which represents the mask's corresponding integer vector type.For AVX-512, these are implemented using
movm_epi[N]andmovepi[N]_mask. For all other instruction sets, the mask types are the same as the integer vector types, so all we have to do is re-wrap them in the proper type.I'm not attached to any of the names here (
Ints,from_vector,to_vector) and am willing to change them if anyone has a better idea.I'm also not sure if we should provide corresponding
from_maskorto_maskfunctions on the corresponding integer vector types; I think that would require adding a newSimdSignedInttype or implementing this functionality for both signed and unsigned int vector types.I also implemented these as associated methods on
SimdMaskbut haven't added any sort of conversion trait. In general, I prefer APIs where the types are concrete if possible (no wide-ranging conversion trait) because it helps with type inference and reduces the number of "turbofish" I have to type out.