libsimdpp icon indicating copy to clipboard operation
libsimdpp copied to clipboard

mask narrowing and widening functions

Open peabody-korg opened this issue 8 years ago • 2 comments

a set of functions like this mask_int32<N> to _mask_int32(mask_int16<N> a); (akin to the int/uint widening and narrowing operations)

This particular function would convert 16-bit lanes of 0 or 0xffff or 32-bit lanes of 0 of 0xffffffff.

Just some zipping/unzipping is all that's required to make a family of functions to convert from any lane width to any other lane width. Given that they are mask types, they can assume that lanes are all 0s or 1s.

FWIW I already have a family of functions that does this (although it actually operates on a custom class built on top of uintN, not mask_uintN, and has no provision for AVX512 single-bit masks). I'm happy to provide these for inspiration.

peabody-korg avatar Dec 02 '17 16:12 peabody-korg

This is good idea, thanks. I'm wondering now whether it makes sense to keep to_mask function around, because it would duplicate this new functionality. to_mask has been added this development cycle and not been released, so it can still be removed.

p12tic avatar Dec 08 '17 23:12 p12tic

@peabody-korg As for existing implementation, it would be great to have something to start from. Could you do a PR with what you have or just push some commits to your own fork? Thanks

p12tic avatar Dec 08 '17 23:12 p12tic