Re: RFR: 6506405: Math.abs(float) is slow [v9]

2021-08-15 Thread Tagir F . Valeev
On Mon, 12 Jul 2021 17:59:32 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has refreshed the contents of this pull request, and > previous commits have been removed. The increm

Re: RFR: 6506405: Math.abs(float) is slow [v9]

2021-07-14 Thread Joe Darcy
On Mon, 12 Jul 2021 17:59:32 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has refreshed the contents of this pull request, and > previous commits have been removed. The increm

Re: RFR: 6506405: Math.abs(float) is slow [v9]

2021-07-12 Thread Brian Burkhalter
> Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Brian Burkhalter has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content

Re: RFR: 6506405: Math.abs(float) is slow [v6]

2021-07-09 Thread Brian Burkhalter
> Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision: 6506405: Clean up test - Changes: - all: https://git

Re: RFR: 6506405: Math.abs(float) is slow [v7]

2021-07-09 Thread Brian Burkhalter
On Fri, 9 Jul 2021 22:02:14 GMT, Joe Darcy wrote: >> Brian Burkhalter has refreshed the contents of this pull request, and >> previous commits have been removed. The incremental views will show >> differences compared to the previous content of the PR. > > src/java.base/share/classes/jdk/intern

Re: RFR: 6506405: Math.abs(float) is slow [v7]

2021-07-09 Thread Joe Darcy
On Fri, 9 Jul 2021 21:30:22 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has refreshed the contents of this pull request, and > previous commits have been removed. The increme

Re: RFR: 6506405: Math.abs(float) is slow [v8]

2021-07-09 Thread Brian Burkhalter
> Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision: 6506405: More test cleanup - Changes: - all: https:/

Re: RFR: 6506405: Math.abs(float) is slow [v7]

2021-07-09 Thread Brian Burkhalter
> Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Brian Burkhalter has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content

Re: RFR: 6506405: Math.abs(float) is slow [v5]

2021-07-09 Thread Brian Burkhalter
On Fri, 9 Jul 2021 13:54:39 GMT, Joe Darcy wrote: >> Brian Burkhalter has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 6506405: Add some tests > > test/jdk/java/lang/Math/AbsTests.java line 35: > >> 33: */ >> 34: public class AbsTests {

Re: RFR: 6506405: Math.abs(float) is slow [v5]

2021-07-09 Thread Joe Darcy
On Thu, 8 Jul 2021 18:15:23 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has updated the pull request incrementally with one > additional commit since the last revision: > >

Re: RFR: 6506405: Math.abs(float) is slow [v2]

2021-07-08 Thread Joe Darcy
PS The benefit of an intrinsic in a case like this is being to use a platform-optimized implementation, trading off native instruction, floating-point branch, and bitwise conversion costs. -Joe On 7/8/2021 4:26 AM, Joe Darcy wrote: On 7/8/2021 3:50 AM, Andrew Haley wrote: On Thu, 8 Jul 2021

Re: RFR: 6506405: Math.abs(float) is slow [v5]

2021-07-08 Thread Brian Burkhalter
> Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision: 6506405: Add some tests - Changes: - all: https://gi

Re: RFR: 6506405: Math.abs(float) is slow [v4]

2021-07-08 Thread Joe Darcy
On Thu, 8 Jul 2021 15:53:18 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has updated the pull request incrementally with one > additional commit since the last revision: > >

Re: RFR: 6506405: Math.abs(float) is slow [v4]

2021-07-08 Thread Brian Burkhalter
> Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision: 6506405: Set MAG_BIT_MASKs to bit-wise complements of SIGN_BIT_MASKs

Re: RFR: 6506405: Math.abs(float) is slow [v3]

2021-07-08 Thread Joe Darcy
On Thu, 8 Jul 2021 15:34:16 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has refreshed the contents of this pull request, and > previous commits have been removed. The increme

Re: RFR: 6506405: Math.abs(float) is slow [v3]

2021-07-08 Thread Brian Burkhalter
> Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Brian Burkhalter has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content

Re: RFR: 6506405: Math.abs(float) is slow [v2]

2021-07-08 Thread Brian Burkhalter
On Thu, 8 Jul 2021 01:05:16 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has updated the pull request incrementally with one > additional commit since the last revision: > >

Re: RFR: 6506405: Math.abs(float) is slow [v2]

2021-07-08 Thread Joe Darcy
On 7/8/2021 3:50 AM, Andrew Haley wrote: On Thu, 8 Jul 2021 09:43:35 GMT, Andrew Haley wrote: Moves between GPRs and FPRs are often slow. There's a 10-cycle latency on some AArch64, so we avoid it whenever we can. Mind you, we don't care about this patch because we always generate FABS from

Re: RFR: 6506405: Math.abs(float) is slow [v2]

2021-07-08 Thread Andrew Haley
On Thu, 8 Jul 2021 09:43:35 GMT, Andrew Haley wrote: > Moves between GPRs and FPRs are often slow. There's a 10-cycle latency on > some AArch64, so we avoid it whenever we can. Mind you, we don't care about > this patch because we always generate FABS from an intrinsic anyway. For avoidance of

Re: RFR: 6506405: Math.abs(float) is slow [v2]

2021-07-08 Thread Andrew Haley
On Thu, 8 Jul 2021 01:05:16 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has updated the pull request incrementally with one > additional commit since the last revision: > >

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-08 Thread Florian Weimer
On Thu, 8 Jul 2021 00:45:48 GMT, Joe Darcy wrote: > However, the bitwise conversion should now be fast everywhere. Doesn't it require moves between general-purpose and floating-point registers? Those have to go through memory for some targets (including old x86, where the ISA supports it, but

Re: RFR: 6506405: Math.abs(float) is slow [v2]

2021-07-08 Thread Uwe Schindler
On Thu, 8 Jul 2021 01:05:16 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has updated the pull request incrementally with one > additional commit since the last revision: > >

Re: RFR: 6506405: Math.abs(float) is slow [v2]

2021-07-08 Thread Uwe Schindler
On a quick review of version 2, I noticed that the double constant is declared as integer with same value like the float one. I think that's wrong, but I wonder why the asserts still pass. Uwe Am July 8, 2021 1:05:16 AM UTC schrieb Brian Burkhalter : >> Please consider this change to make the `

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Brian Burkhalter
On Jul 7, 2021, at 5:50 PM, Joe Darcy mailto:joe.da...@oracle.com>> wrote: There is no specific constant in `{Float,Double}Consts` to mask all but the sign bit, but I had thought it might be good to add one there The sign bit mask can be bit-wise complemented though :-) I had it that way in

Re: RFR: 6506405: Math.abs(float) is slow [v2]

2021-07-07 Thread Joe Darcy
On Thu, 8 Jul 2021 01:05:16 GMT, Brian Burkhalter wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > Brian Burkhalter has updated the pull request incrementally with one > additional commit since the last revision: > >

Re: RFR: 6506405: Math.abs(float) is slow [v2]

2021-07-07 Thread Brian Burkhalter
> Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision: 6506405: Add comments, use new consts for masking - Ch

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Joe Darcy
On 7/7/2021 5:43 PM, Brian Burkhalter wrote: On Thu, 8 Jul 2021 00:38:45 GMT, Joe Darcy wrote: Please consider this change to make the `float` and `double` versions of `java.lang.Math.abs()` branch-free. src/java.base/share/classes/java/lang/Math.java line 1530: 1528: @IntrinsicCandida

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Joe Darcy
On Wed, 7 Jul 2021 20:29:37 GMT, Brian Burkhalter wrote: > > > With this change there is no measurable effect on performance on macOS, but > on Linux there is approximately a 10% throughput improvement. The improvement is with the default options, without turning intrinsics off? I'm somewhat

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Joe Darcy
On Wed, 7 Jul 2021 20:28:37 GMT, Brian Burkhalter wrote: > Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. src/java.base/share/classes/java/lang/Math.java line 1530: > 1528: @IntrinsicCandidate > 1529: public static float a

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Brian Burkhalter
On Thu, 8 Jul 2021 00:38:45 GMT, Joe Darcy wrote: >> Please consider this change to make the `float` and `double` versions of >> `java.lang.Math.abs()` branch-free. > > src/java.base/share/classes/java/lang/Math.java line 1530: > >> 1528: @IntrinsicCandidate >> 1529: public static float

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Brian Burkhalter
On Wed, 7 Jul 2021 20:28:37 GMT, Brian Burkhalter wrote: > Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. On Jul 7, 2021, at 3:44 PM, Rémi Forax ***@***.**@***.***>> wrote: Your patch change the semantics, actually Math.abs(I

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Rémi Forax
On Wed, 7 Jul 2021 22:22:45 GMT, Joe Darcy wrote: > > > Your patch change the semantics, actually > > `Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE` > > with your patch > > `Math.abs(Integer.MIN_VALUE) == Integer.MAX_VALUE` > > Does it? The overriding of int arguments shouldn't be affected.

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Joe Darcy
On Wed, 7 Jul 2021 20:28:37 GMT, Brian Burkhalter wrote: > Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. > > Good catch. Well that’s not good. If it needs to catch a special case it’s > probably not worth doing. given the small

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Brian Burkhalter
On Wed, 7 Jul 2021 20:28:37 GMT, Brian Burkhalter wrote: > Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Good catch. Well that’s not good. If it needs to catch a special case it’s probably not worth doing. given the small improve

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Rémi Forax
On Wed, 7 Jul 2021 20:28:37 GMT, Brian Burkhalter wrote: > Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. Your patch change the semantics, actually `Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE` with your patch `Math.abs(In

RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Brian Burkhalter
Please consider this change to make the `float` and `double` versions of `java.lang.Math.abs()` branch-free. - Commit messages: - 6506405: Math.abs(float) is slow Changes: https://git.openjdk.java.net/jdk/pull/4711/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4711&r

Re: RFR: 6506405: Math.abs(float) is slow

2021-07-07 Thread Brian Burkhalter
On Wed, 7 Jul 2021 20:28:37 GMT, Brian Burkhalter wrote: > Please consider this change to make the `float` and `double` versions of > `java.lang.Math.abs()` branch-free. With this change there is no measurable effect on performance on macOS, but on Linux there is approximately a 10% throughput