[vectorIntrinsics+compress] RFR: 8274664: Add support for compress/expand api methods

Sandhya Viswanathan sviswanathan at openjdk.java.net
Mon Oct 4 22:59:22 UTC 2021


On Mon, 4 Oct 2021 22:34:19 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

>> Add support for the cross lane operations to compress/expand the lane elements of a vector selecting lanes under the control of a mask. The remaining lanes of the destination vector could be either set to zero or get the value from corresponding elements of the background vector.
>> The following methods are added:
>>  public abstract Vector<E> compress(VectorMask<E> m);
>>  public abstract Vector<E> compress(VectorMask<E> m, Vector<E> v);
>>  public abstract Vector<E> expand(VectorMask<E> m);
>>  public abstract Vector<E> expand(VectorMask<E> m, Vector<E> v);
>
> This is an great start. I think it best to get the code in and iterate.
> 
> It should be possible to reduce some code by composition e..g. compress(m) === compress(m. zeroVector), at least from a test assertion perspective. Unsure from an intrinsic perspective.
> 
> Also i wonder for `compress(m, v)` whether values from `v` should drawn starting from zero rather than popcount of `m`, thus allowing easier partitioning:
> 
>   pFalse = v.compress(m.not());
>   p = v.compress(m, pFalse);
> 
> Again, i am unsure from an intrinsic perspective.

Thanks a lot @PaulSandoz  for the review. I will integrate and then we can iterate. 

With current definition, from the intrinsic perspective the compress(m,  v) can be directly translated to the vcompressps/vcompresspd instruction.
Also the following holds true:
v == v.compress(m).expand(m, v)
v == v.expand(m).compress(m, v)

-------------

PR: https://git.openjdk.java.net/panama-vector/pull/143


More information about the panama-dev mailing list