[vectorIntrinsics+compress] RFR: 8274971: Add PrefixMask API
Joshua Zhu
jzhu at openjdk.java.net
Mon Oct 11 10:14:18 UTC 2021
On Mon, 11 Oct 2021 09:54:55 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:
>> I separate my implementation of "compress" API into several patches for easy review.
>> This change is to import PrefixMask API for VectorMask.
>> It cooperates with compress/expand API. (See the usage in ALIBABA selectiveStore use case.)
>> It returns a prefix mask, based on the true count of the mask.
>> Assume "N" is the true count of the mask, the mask bit is set from the beginning lane till the lane numbered "N-1", otherwise it is unset.
>> Temporarily mask.prefixMask() is implemented by
>>
>> vectorSpecies.iota().compare(VectorOperators.LT, trueCount());
>>
>> The alternative implementation is:
>>
>> vectorSpecies().indexInRange(0, m.trueCount())
>>
>> I choose the former implementation since the latter depends on the Intrinsic support of indexVector.
>>
>> I'm looking for instructions that could be used to accelerate indexVector/iota, so that vector-to-vector operations together with a store/load and prefix mask could be optimized further into single memory version instruction.
>> Intel experts, do you have any suggestions on SIMD instructions for iota vector generation?
>
> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java line 640:
>
>> 638: return species.iota().compare(VectorOperators.LT, trueCount());
>> 639: }
>> 640:
>
> Not sure if this API is needed as a public interface since all the constituents are publicly exposed APIs, unless we plan to intrinsify it.
>
> But existing VectorMask.fromLong(SPECIES, (1 << m.trueCount()) -1), can efficiently handle this pattern, I am already working on accelerating VectorMask.fromLong API for AVX512 target.
I prefer to add it as an addtional API and it can be used to cooperate with compress/expand API.
See previous design discussion threads.
-------------
PR: https://git.openjdk.java.net/panama-vector/pull/148
More information about the panama-dev
mailing list