[GR-64794] Vector API: Implement Vector::compress/expand #11434
Merged
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.
This PR adds support for intrinsification of
Vector::compress
andVector::expand
on AVX512.Vector::compress
extracts elements from the source vector according to a mask, then puts them into the first elements of the destination vector one-by-one. The remaining elements in the destination vector are zeroed. This operation is useful for text transcoding, for example, when converting a UTF-32 sequence to UTF-8, we can usecompress
to contract the fixed-sized code points of UTF-32 to the variable-sized code points of UTF-8.Vector::expand
is the opposite operation, it takes the elements from the source vector one-by-one and put them at each element in the destination vector such that the corresponding element in the mask operand is set.AVX-512 has dedicated instruction for
compress
andexpand
. With this patch,Vector::compress(src, mask)
is compiled intovpcompressd dst{mask}, src
,Vector::expand(src, mask)
is compiled intovpexpandd dst{mask}, src
.Please kindly review, thanks a lot.