Egor Pasko wrote: > On the 0x385 day of Apache Harmony Tim Ellison wrote: >> Harmony 5.0 M3 prints >> Result = 6.666661664588418E8 in 1352ms >> IBM 5.0 SR5a prints >> Result = 6.666661664588418E8 in 40ms >> Sun 1.6.0-b105 prints >> Result = 6.666661664588418E8 in 40ms > > Wow, good catching microbenchmark! Tim++
Credit to Xiao-Feng for that, not me. >> Can we squeeze a bit more out of the JIT? > > actually, Math.sqrt() is native and taken from the slow and portable > FDLIBM. I guess that was my point -- I'm making the assumption, given the orders of magnitude difference in time, that we are going through JNI and IBM/Sun are recognizing the method in the JIT compiler and creating code for it directly. > I believe, libc implementation is supposed to be > faster. -ffast-math does not suit us because sqrt() is a part of > IEEE754 standard which is a part of Java (with signalling exception). I defer to you for the compatibility between the hardware instructions and Java standard, but looks like others are doing the 'right thing', or am I making a wrong assumption here? > In fact, NBody multiplies by 1/sqrt(x) function, and this is where > both JIT and native implementation could help. multiplication and > 1/sqrt(x) must be cheaper than sqrt(x) and division, but I am not sure > it would make an IEEE754 compatible solution. ack. Regards, Tim
