VectorAPI min and max intrinsics
shravya.rukmannagari at intel.com
Tue Apr 17 17:34:55 UTC 2018
The float(minps, maxps) and double(minpd, maxpd) instructions would match the "<" and ">" from the Java language specification. As per the documentation of the instructions (minps, maxps),
If the values being compared are both 0.0s (of either sign), the value in the second operand (source operand) is returned. If a value in the second operand is an SNaN, then SNaN is forwarded unchanged to the destination (that is, a QNaN version of the SNaN is not returned). If only one value is a NaN (SNaN or QNaN) for this instruction, the second operand (source operand), either a NaN or a valid floating-point value, is written to the result. If instead of this behavior, it is required that the NaN source operand (from either the first or second operand) be returned, the action of MINPS can be emulated using a sequence of instructions, such as, a comparison followed by AND, ANDN and OR.
As per the Java lang specification, comparison is:
- If either operand is NaN, then the result is false.
- All values other than NaN are ordered, with negative infinity less than all finite values, and positive infinity greater than all finite values.
- Positive zero and negative zero are considered equal.
From: Paul Sandoz [mailto:paul.sandoz at oracle.com]
Sent: Monday, April 16, 2018 5:55 PM
To: Rukmannagari, Shravya <shravya.rukmannagari at intel.com>
Cc: panama-dev at openjdk.java.net
Subject: Re: VectorAPI min and max intrinsics
I notice you have adjusted the the Vector Java implementations to differ from the the java.lang.Math.min/max implementations (<= to < etc) (for the floating point types i intended to adjust to call Math.min/max).
Ideally it would be best to align with Math.min/max behaviour if at all possible at least for the integral types. For the FP types i am unsure about how the instructions deal with NaNs and -0.0 and +0.0.
Can you describe the semantics of the vector instructions so i can compare with Math.min/max?
> On Apr 16, 2018, at 4:28 PM, Rukmannagari, Shravya <shravya.rukmannagari at intel.com> wrote:
> Hi All,
> I would like to contribute a patch adding support for vector Intrinsics for Vector API min and max functions for all the datatypes.
> Could you please review the patch here: http://cr.openjdk.java.net/~srukmannagar/VectorAPI_minMax/webrev.01/
More information about the panama-dev