RFR: 8262096: Vector API fails to work due to VectorShape initialization exception [v5]
Jie Fu
jiefu at openjdk.java.net
Tue Mar 2 02:11:09 UTC 2021
On Sun, 28 Feb 2021 13:31:38 GMT, Jie Fu <jiefu at openjdk.org> wrote:
>> `@requires vm.compiler2.enabled` had been added.
>> Thanks.
>
> @PaulSandoz , are you also OK with the latest version?
> Thanks.
> @DamonFool I think Vladimir is correct in the layering, in this respect i think we can make things a littler clearer. This seems like a small thing but i think its worth making very explicit as there is some hidden complexity.
>
> What if we add the following method to `VectorShape`:
>
> ```java
> /**
> * Returns the maximum vector bit size for a given element type.
> *
> * @param etype the element type.
> * @return the maximum vector bit.
> */
> /*package-private*/
> static int getMaxVectorBitSize(Class<?> etype) {
> // May return -1 if C2 is not enabled,
> // or a value smaller than the S_64_BIT.vectorBitSize / elementSizeInBits, on say 32-bit platforms
> // If so default to S_64_BIT
> int maxLaneCount = VectorSupport.getMaxLaneCount(etype);
> int elementSizeInBits = LaneType.of(etype).elementSize;
> return Math.max(maxLaneCount * elementSizeInBits, S_64_BIT.vectorBitSize);
> }
> ```
>
> It is package private so it can be tested explicitly if need be.
>
> Then we can reuse that method:
>
> ```
> S_Max_BIT(getMaxVectorBitSize(byte.class));
> ```
>
> ```
> static VectorShape largestShapeFor(Class<?> etype) {
> return VectorShape.forBitSize(getMaxVectorBitSize(etype));
> }
> ```
>
> I think that's correct, but i have not tested. WDYT?
Good suggestion.
Updated.
Testing:
- jdk/incubator/vector with MaxVectorSize=default/8/4 on Linux/x64
- jdk/incubator/vector without C2 on Linux/x64
Thanks.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2722
More information about the core-libs-dev
mailing list