On Sun, 28 Feb 2021 13:31:38 GMT, Jie Fu <[email protected]> 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