WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
62204
Master bug for rounding issues which cause 1px difference on 32/64 bit architectures
https://bugs.webkit.org/show_bug.cgi?id=62204
Summary
Master bug for rounding issues which cause 1px difference on 32/64 bit archit...
Zoltan Herczeg
Reported
2011-06-07 05:15:49 PDT
Such bugs are mostly caused by rounding. But what does exactly happen there? And how? The answer is here, let's divide 400000 by 600 If the input arguments are float: 400000/600 = 666.666687 If the input arguments are double: 400000/600 = 666.666667 This is nice, but shouldn't the same rounding error should happen on ALL machines? The understand this better, we need to see what exactly happen on lower (machine code) levels. The systems use registers to temporary keep the values of arithmetic. On x86, these registers have fixed size (10 byte for x87 fpu, and 8 byte for SSE2), and all arithmetic operations are executed using the highest precision. However, results are rounded to the storage size if we move the data to the memory. Let's we have a super simple x86 machine with 2 double precision registers, d1 and d2, and we want to evaluate: (A*B)+(C*D). The following pesudo code show this: LOAD A to d1 MULTIPLY B to d1 LOAD C to d2 MULTIPLY D to d2 ADD d1 and d2 However, what does happen, if let's say, d2 is reserved for some reasons: LOAD A to d1 MULTIPLY B to d1 STORE d1 to [4 byte mem area] // CONVERSION HERE!!! LOAD C to d2 MULTIPLY D to d2 ADD d1 and [4 byte mem area] There are several versions of such code, but the issue is the same: moving data to a storage with different precision cause rounding. However, if the data is not need to be moved (because it is in the right register at the moment), the rounding is ALSO optimized out by the compiler, and you may get a different result on different platforms. Solution? I can't see a good solution. Storing everything on the highest precision would increase the memory consumption too much. Furthermore, these differences are hardly visible to the user. However, it is a nightmare for platform maintainers, you need to maintain too many expected files. I think we should live with it now, and try to reduce these bugs.
Attachments
Add attachment
proposed patch, testcase, etc.
Zoltan Herczeg
Comment 1
2011-06-07 05:28:47 PDT
> LOAD A to d1 > MULTIPLY B to d1 > STORE d1 to [4 byte mem area] // CONVERSION HERE!!! > LOAD C to d2 > MULTIPLY D to d2 > ADD d1 and [4 byte mem area]
My bad, the second example was wrong. It should look like: LOAD A to d1 MULTIPLY B to d1 STORE d1 to [4 byte mem area] // CONVERSION HERE!!! LOAD C to d1 MULTIPLY D to d1 ADD d1 and [4 byte mem area]
Ami Fischman
Comment 2
2011-06-07 08:52:04 PDT
FTR, chromium/linux/ia32 builds with -mfpmath=sse -msse2 to avoid this sort of problem:
http://codesearch.google.com/codesearch/p?hl=en#OAMlx_jo-ck/src/build/common.gypi&q=file:build/common.gypi&exact_package=chromium&l=1211
vanuan
Comment 3
2011-11-13 04:45:36 PST
Please add this bug
https://bugs.webkit.org/show_bug.cgi?id=54474
as a dependency
Nikolas Zimmermann
Comment 4
2011-11-14 03:24:22 PST
Add more dependencies.
Ahmad Saleem
Comment 5
2023-01-06 18:05:40 PST
All dependent bugs are fixed now, do we need to track anything else here? Thanks!
Ahmad Saleem
Comment 6
2024-01-02 09:17:43 PST
All dependent bugs are fixed. So marking this as 'RESOLVED CONFIGURATION CHANGED'. Please reopen renew bug as needed.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug