RFR: 8338021: Support new unsigned and saturating vector operators in VectorAPI [v22]

Paul Sandoz psandoz at openjdk.org
Tue Oct 8 16:40:17 UTC 2024


On Fri, 4 Oct 2024 00:01:59 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> Hi All,
>> 
>> As per the discussion on panama-dev mailing list[1], patch adds the support for following new vector operators.
>> 
>> 
>>      . SUADD   : Saturating unsigned addition.
>>      . SADD    : Saturating signed addition. 
>>      . SUSUB   : Saturating unsigned subtraction.
>>      . SSUB    : Saturating signed subtraction.
>>      . UMAX    : Unsigned max
>>      . UMIN    : Unsigned min.
>>      
>> 
>> New vector operators are applicable to only integral types since their values wraparound in over/underflowing scenarios after setting appropriate status flags. For floating point types, as per IEEE 754 specs there are multiple schemes to handler underflow, one of them is gradual underflow which transitions the value to subnormal range. Similarly, overflow implicitly saturates the floating-point value to an Infinite value.
>> 
>> As the name suggests, these are saturating operations, i.e. the result of the computation is strictly capped by lower and upper bounds of the result type and is not wrapped around in underflowing or overflowing scenarios.
>> 
>> Summary of changes:
>> - Java side implementation of new vector operators.
>> - Add new scalar saturating APIs for each of the above saturating vector operator in corresponding primitive box classes, fallback implementation of vector operators is based over it.
>> - C2 compiler IR and inline expander changes.
>> - Optimized x86 backend implementation for new vector operators and their predicated counterparts.
>> - Extends existing VectorAPI Jtreg test suite to cover new operations.
>> 
>> Kindly review and share your feedback.
>> 
>> Best Regards,
>> PS: Intrinsification and auto-vectorization of new core-lib API will be addressed separately in a follow-up patch.
>> 
>> [1] https://mail.openjdk.org/pipermail/panama-dev/2024-May/020408.html
>
> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update VectorMath.java

Java changes look good (see comments to fix some typos). Needs another HotSpot reviewer.

Marked as reviewed by psandoz (Reviewer).

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMath.java line 275:

> 273:      * @param b the second operand.
> 274:      * @return the saturating addition of the operands.
> 275:      * @see VectorOperators#SADD

Suggestion:

     * @see VectorOperators#SUADD

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMath.java line 301:

> 299:      * @param b the second operand.
> 300:      * @return the saturating difference of the operands.
> 301:      * @see VectorOperators#SSUB

Suggestion:

     * @see VectorOperators#SUSUB

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMath.java line 413:

> 411:      * @param b the second operand.
> 412:      * @return the saturating addition of the operands.
> 413:      * @see VectorOperators#SADD

Suggestion:

     * @see VectorOperators#SUADD

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMath.java line 439:

> 437:      * @param b the second operand.
> 438:      * @return the saturating difference of the operands.
> 439:      * @see VectorOperators#SSUB

Suggestion:

     * @see VectorOperators#SUSUB

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMath.java line 551:

> 549:      * @param b the second operand.
> 550:      * @return the saturating addition of the operands.
> 551:      * @see VectorOperators#SADD

Suggestion:

     * @see VectorOperators#SUADD

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMath.java line 577:

> 575:      * @param b the second operand.
> 576:      * @return the saturating difference of the operands.
> 577:      * @see VectorOperators#SSUB

Suggestion:

     * @see VectorOperators#SUSUB

-------------

PR Review: https://git.openjdk.org/jdk/pull/20507#pullrequestreview-2354993291
PR Review: https://git.openjdk.org/jdk/pull/20507#pullrequestreview-2355019508
PR Review Comment: https://git.openjdk.org/jdk/pull/20507#discussion_r1792178593
PR Review Comment: https://git.openjdk.org/jdk/pull/20507#discussion_r1792178872
PR Review Comment: https://git.openjdk.org/jdk/pull/20507#discussion_r1792179260
PR Review Comment: https://git.openjdk.org/jdk/pull/20507#discussion_r1792179485
PR Review Comment: https://git.openjdk.org/jdk/pull/20507#discussion_r1792179780
PR Review Comment: https://git.openjdk.org/jdk/pull/20507#discussion_r1792180281


More information about the hotspot-compiler-dev mailing list