Status: Accepted
Owner: ----
CC: da...@chromium.org, jkumme...@chromium.org, yang...@chromium.org,
plin...@gmail.com, gerg...@homejinni.com, kilva...@homejinni.com
Labels: Type-Bug Priority-Medium
New issue 2928 by pal...@homejinni.com: ARM and MIPS simulator FP operation
precision is wrong on Linux
http://code.google.com/p/v8/issues/detail?id=2928
The default 387 FPU precision is 80-bit (extended) on Linux, therefore the
FP operations in the simulator computes slightly different results, than a
real ARM or MIPS device.
I've created a small javascript test, which tests the precision:
function precisionTest() {
// Max value of a 64-bit double (2^53 + 2)
var maxnum = 9007199254740994.0;
var smallnum = 1.0 - 1/65536.0;
var result = maxnum + smallnum;
print("Result: " + result);
var diff = result - maxnum;
print("Diff: " + diff);
assertEquals(9007199254740994.0, result);
assertEquals(0, diff);
}
precisionTest();
Result on ARM simulator:
$ out/arm.release/d8 test/mjsunit/mjsunit.js precision_test.js
Result: 9007199254740996
Diff: 2
test/mjsunit/mjsunit.js:174: Failure: expected <9007199254740996> found
<9007199254740994>
MIPS simulator:
$ out/mipsel.release/d8 test/mjsunit/mjsunit.js precision_test.js
Result: 9007199254740996
Diff: 2
test/mjsunit/mjsunit.js:174: Failure: expected <9007199254740996> found
<9007199254740994>
ARM HW (Snapdragon 600 Android):
shell@android:/data/local/tmp/v8 $ out/android_arm.release/d8
test/mjsunit/mjsunit.js precision_test.js
Result: 9007199254740994
Diff: 0
MIPS HW (Sigma 8911):
$ out/mipsel.release/d8 test/mjsunit/mjsunit.js precision_test.js
Result: 9007199254740994
Diff: 0
I've uploaded a CL for this issue
(https://codereview.chromium.org/24067002/), which explicitly set the 387
FPU precision mode to 64-bit double, but as it turned out, the libm library
requires extended precision, otherwise the pow function returns very
inaccurate result (http://www.sourceware.org/bugzilla/show_bug.cgi?id=706).
Another solution would be to force the g++ compiler to use sse2
instructions for FP operations (-msse2 -mfpmath=sse). Unfortunately, it
seems that this solution also does not solve all issues, because most Linux
distribution (Ubuntu 12.04 for example) compiles libm for 387 FPU,
therefore the libm functions (sqrt, pow, exp, etc.) would still use the 387
FPU operations with extended precision.
Attachments:
precision_test.js 354 bytes
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.