Could I Ask about JEP 438 Vector API no suport BitSet problem?

Paul Sandoz paul.sandoz at oracle.com
Mon Apr 15 16:59:38 UTC 2024


Hi,

I am guessing you are investigating the optimization of bulk operations on bit sets? Is there a particular use-case you have in mind? i.e. what problem are you trying to solve? 

BitSet does not expose direct access to its underlying storage (and nor should it, the invariants are more complicated than first appears). And, as you found out there is no access to BitSet at a given bit offset using the Vector API.

Paul.

> On Apr 13, 2024, at 7:16 PM, Latch Wu <latchwu at gmail.com> wrote:
> 
> Hi  Paul Sandoz, I am Master student. I was use Vector API and Java.util.BitSet on Project. there are have big trouble. Vector API no support BitSet_Vector
> every time, I must be transfer BitSet.toByteArray()
> 
> in this case, because BitSet no support Vector API
> I need to do something unproductive,
> 
> var aBytes = (BitSet) bs1.toByteArray();
> var bBytes = (BitSet) bs2.toByteArray();
> byte[] c = new byte[bs1.getByteArray().length];
> final VectorSpecies<Byte> SPECIES = ByteVector.SPECIES_MAX;
> 
> for (int k = 0; k < aBytes.length; k += SPECIES.length()) {
>     var m = SPECIES.indexInRange(k, aBytes.length);
>     va = ByteVector.fromArray(SPECIES, aBytes, k, m);
>     vb = ByteVector.fromArray(SPECIES, bBytes, k, m);
>     vc = va.and(vb);
>     vc.intoArray(c, k, m);
> }
> byte[] newC = c.clone();
> BitSet temp = BitSet.valueOf(newC);
> 
> ================================================================
> var aBytes = (BitSet) bs1;
> var aByteClone = (BitSet) aBytes.clone();
> var bBytes = (BitSet) bs2;
> var ceqAandB = (BitSet) bBytes.clone();
> CeqAandB.and(aByteClone);
> ================================================================
> If I use the following code, it is faster than using AVX-512 Vectory API
> Could you have any suggestion for me?
> 
> Best regard,
> 
> Latch Wu
> 



More information about the panama-dev mailing list