RFP: New vector operations and APIs.

Bhateja, Jatin jatin.bhateja at intel.com
Mon May 13 01:55:18 UTC 2024


Hi All,

Please find below the proposal for adding new vector operators and API based on the user's feedback.

A) New VectorAPI operations.
     . VectorOperators.SATURATING_UNSIGNED_ADD
     . VectorOperators.SATURATING_UNSIGNED_SUB
     . VectorOperators.SATURATING_ADD
     . VectorOperators.SATURATING_SUB

Applicable Types for new operators:
Prosed vector operators are applicable to 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[2] which transitions the value to subnormal range. Similarly, overflow implicitly.
saturates the floating-point value to a representable range or an Infinite value.  
As the name suggest, 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.

B) New Vector API.
    . Vector<E>.selectFrom(Vector<E> v1, Vector<E> v2)

Using index values stored in the lanes of this vector, assemble values stored in first (v1) and second (v2) vector arguments. Thus, first and second vector serves as a table, whose elements are selected by indexes in the current vector. API is applicable to all integral and floating-point types.  The result of this operation is semantically equivalent to expression Vector.blend(v1.rearrange(this.toShuffle(), v2,rearrange(this.toShuffle), this.toShuffle().laneIsValid()). This is a convenience API for an existing rearrange API[2], we already have such a convenience API "Vector.selectFrom(Vector)"[3] for single vector permute, proposed API extends it to two vector permute. 

Target Architecture Support:-
New operators should emit optimum instruction sequence for supported target platforms. 

We plan to target these extensions for JDK-24.

Please let us know your comments.

Best Regards,
Jatin

[1] https://docs.oracle.com/cd/E19957-01/806-3568/ncg_math.html#:~:text=How%20Does%20IEEE%20Arithmetic%20Treat%20Underflow%3F
[2] https://docs.oracle.com/en/java/javase/22/docs/api/jdk.incubator.vector/jdk/incubator/vector/Vector.html#rearrange(jdk.incubator.vector.VectorShuffle,jdk.incubator.vector.Vector)
[3] https://docs.oracle.com/en/java/javase/22/docs/api/jdk.incubator.vector/jdk/incubator/vector/Vector.html#selectFrom(jdk.incubator.vector.Vector)







More information about the panama-dev mailing list