[PATCH] 8217561 : X86: Add floating-point Math.min/max intrinsics, approval request
B. Blaser
bsrbnd at gmail.com
Sun Feb 17 20:21:50 UTC 2019
On Sun, 17 Feb 2019 at 19:02, Andrew Haley <aph at redhat.com> wrote:
>
> On 2/17/19 3:36 PM, B. Blaser wrote:
>
> > We see that the new instruction sequence is about 2x faster than the
> > previous one. Could we have a Reviewer feedback and eventually a
> > definitive approval for this?
>
> I don't think that benchmark is necessarily representative either.
> It's not so common to have totally unpredictable comparisons. For
> comparison we need both predictable and unpredictable tests.
>
> A good example of a predictable test would be
>
> @Benchmark
> public double fMinReduce(Blackhole bh) {
> double result = Double.MAX_DOUBLE;
> for (int i=0; i<COUNT; i++)
> result = Math.min(result, floats[i]);
> return result;
> }
>
> What does the intrinsic do to the performance of that test?
Thanks for your feedback, Andrew.
The unpredictability is necessary to measure the instruction sequence
only which is more than 2x faster than before.
However, I agree that your predictable example is a bit less than 3x
slower with the intrinsic, but we have the same regression with the
existing integer min/max intrinsic:
@Benchmark
public float iMinReduce(Blackhole bh) {
int result = Integer.MAX_VALUE;
for (int i=0; i<COUNT; i++)
result = Math.min(result, ints[i]);
return result;
}
@Benchmark
public float fMinReduce(Blackhole bh) {
float result = Float.MAX_VALUE;
for (int i=0; i<COUNT; i++)
result = Math.min(result, floats[i]);
return result;
}
Note that Jatin's example is also biased but up to 10x faster than before!
Nevertheless, the interest of intrinsics goes far beyond these
examples as they also open the door of other optimizations like the
algebraic simplifications you mentioned previously, see [1] & [2].
Bernard
[1] http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2019-February/032817.html
[2] http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2018-October/031025.html
More information about the hotspot-compiler-dev
mailing list