Re: RFR: 8262096: Vector API fails to work due to VectorShape initialization exception [v4]

2021-02-26 Thread Jie Fu
On Fri, 26 Feb 2021 15:48:18 GMT, Vladimir Ivanov  wrote:

> > I'd like to keep DoubleVector.SPECIES_PREFERRED.length() <= 
> > VectorSupport.getMaxLaneCount(double.class) for Java programmers since the 
> > VectorSupport_GetMaxLaneCount is used to implement a Java API.
> 
> It doesn't make much sense to me. `VectorSupport` is an internal API for 
> `jdk.incubator.vector` to consume.
> It's `jdk.incubator.vector` job to interpret the result and adapt accordingly.

Okay, I'm fine to fix it in jdk/incubator/vector/VectorShape.java if we don't 
keep something like that.

For the updated fix, the {max/preferred} shape will be initialized as 
shape-64-bit if hotspot doesn't support vectorization.

Testing:
  - jdk/incubator/vector with MaxVectorSize=default/8/4 on Linux/x64 
  - jdk/incubator/vector without C2 on Linux/x64

Any comments?
Thanks.

-

PR: https://git.openjdk.java.net/jdk/pull/2722


Re: RFR: 8262096: Vector API fails to work due to VectorShape initialization exception [v4]

2021-02-26 Thread Vladimir Ivanov
On Fri, 26 Feb 2021 15:37:08 GMT, Jie Fu  wrote:

> I'd like to keep DoubleVector.SPECIES_PREFERRED.length() <= 
> VectorSupport.getMaxLaneCount(double.class) for Java programmers since the 
> VectorSupport_GetMaxLaneCount is used to implement a Java API.

It doesn't make much sense to me. `VectorSupport` is an internal API for 
`jdk.incubator.vector` to consume.
It's `jdk.incubator.vector` job to interpret the result and adapt accordingly.

-

PR: https://git.openjdk.java.net/jdk/pull/2722


Re: RFR: 8262096: Vector API fails to work due to VectorShape initialization exception [v4]

2021-02-26 Thread Jie Fu
On Fri, 26 Feb 2021 13:55:15 GMT, Vladimir Ivanov  wrote:

> IMO the fix should be in 
> `src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java`.
> 
> JVM does the right job when it signals vector support is absent (by returning 
> `-1`).
> 
> `jdk.incubator.vector` implementation should take that into account and 
> choose a preferred shape for pure Java execution mode.

Hi @iwanowww ,

Thanks for your review.

>From the view of C2 compiler, you are right.

But the Java programmer may be confused if we got something like 
DoubleVector.SPECIES_PREFERRED.length() > 
VectorSupport.getMaxLaneCount(double.class).
I'd like to keep DoubleVector.SPECIES_PREFERRED.length() <= 
VectorSupport.getMaxLaneCount(double.class) for Java programmers since the 
VectorSupport_GetMaxLaneCount is used to implement a Java API.

What do you think?
Thanks.

-

PR: https://git.openjdk.java.net/jdk/pull/2722


Re: RFR: 8262096: Vector API fails to work due to VectorShape initialization exception [v4]

2021-02-26 Thread Vladimir Ivanov
On Fri, 26 Feb 2021 02:38:00 GMT, Jie Fu  wrote:

>> Hi all,
>> 
>> Vector API fails to work when:
>>  - case 1: MaxVectorSize is set to <=8, or
>>  - case 2: C2 is disabled
>> 
>> The reason is that {max/preferred} VectorShape initialization fails in both 
>> cases.
>> And the root cause is that VectorSupport_GetMaxLaneCount [1] returns 
>> unreasonable values (0 for case 1 and -1 for case 2).
>> 
>> Vector API should not depend on C2 to run.
>> It should work even there is no JIT compiler since it's a Java-level api.
>> So let's fix it.
>> 
>> Testing:
>>   - jdk/incubator/vector with -XX:MaxVectorSize=default/8 on Linux/x64
>> 
>> Thanks.
>> Best regards,
>> Jie
>> 
>> [1] 
>> https://github.com/openjdk/jdk/blob/master/src/hotspot/share/prims/vectorSupport.cpp#L364
>
> Jie Fu has updated the pull request incrementally with one additional commit 
> since the last revision:
> 
>   Remove -XX:TieredStopAtLevel=3

IMO the fix should be in 
`src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java`.

JVM does the right job when it signals vector support is absent (by returning 
`-1`).

`jdk.incubator.vector` implementation should take that into account and choose 
a preferred shape for pure Java execution mode.

-

Changes requested by vlivanov (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/2722


Re: RFR: 8262096: Vector API fails to work due to VectorShape initialization exception [v4]

2021-02-25 Thread Paul Sandoz
On Fri, 26 Feb 2021 02:38:00 GMT, Jie Fu  wrote:

>> Hi all,
>> 
>> Vector API fails to work when:
>>  - case 1: MaxVectorSize is set to <=8, or
>>  - case 2: C2 is disabled
>> 
>> The reason is that {max/preferred} VectorShape initialization fails in both 
>> cases.
>> And the root cause is that VectorSupport_GetMaxLaneCount [1] returns 
>> unreasonable values (0 for case 1 and -1 for case 2).
>> 
>> Vector API should not depend on C2 to run.
>> It should work even there is no JIT compiler since it's a Java-level api.
>> So let's fix it.
>> 
>> Testing:
>>   - jdk/incubator/vector with -XX:MaxVectorSize=default/8 on Linux/x64
>> 
>> Thanks.
>> Best regards,
>> Jie
>> 
>> [1] 
>> https://github.com/openjdk/jdk/blob/master/src/hotspot/share/prims/vectorSupport.cpp#L364
>
> Jie Fu has updated the pull request incrementally with one additional commit 
> since the last revision:
> 
>   Remove -XX:TieredStopAtLevel=3

Marked as reviewed by psandoz (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/2722


Re: RFR: 8262096: Vector API fails to work due to VectorShape initialization exception [v4]

2021-02-25 Thread Jie Fu
> Hi all,
> 
> Vector API fails to work when:
>  - case 1: MaxVectorSize is set to <=8, or
>  - case 2: C2 is disabled
> 
> The reason is that {max/preferred} VectorShape initialization fails in both 
> cases.
> And the root cause is that VectorSupport_GetMaxLaneCount [1] returns 
> unreasonable values (0 for case 1 and -1 for case 2).
> 
> Vector API should not depend on C2 to run.
> It should work even there is no JIT compiler since it's a Java-level api.
> So let's fix it.
> 
> Testing:
>   - jdk/incubator/vector with -XX:MaxVectorSize=default/8 on Linux/x64
> 
> Thanks.
> Best regards,
> Jie
> 
> [1] 
> https://github.com/openjdk/jdk/blob/master/src/hotspot/share/prims/vectorSupport.cpp#L364

Jie Fu has updated the pull request incrementally with one additional commit 
since the last revision:

  Remove -XX:TieredStopAtLevel=3

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/2722/files
  - new: https://git.openjdk.java.net/jdk/pull/2722/files/aa475b0a..bbe6150c

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=2722=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=2722=02-03

  Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2722.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2722/head:pull/2722

PR: https://git.openjdk.java.net/jdk/pull/2722


Re: RFR: 8262096: Vector API fails to work due to VectorShape initialization exception [v4]

2021-02-25 Thread Jie Fu
On Fri, 26 Feb 2021 02:28:55 GMT, Paul Sandoz  wrote:

> In that case I think we can remove the execution with 
> `-XX:TieredStopAtLevel=x`.

Fixed. Thanks.

-

PR: https://git.openjdk.java.net/jdk/pull/2722