[Bug 110435] fp64 division gives imprecise results

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Apr 15 10:22:16 UTC 2019


https://bugs.freedesktop.org/show_bug.cgi?id=110435

            Bug ID: 110435
           Summary: fp64 division gives imprecise results
           Product: Mesa
           Version: git
          Hardware: x86 (IA32)
                OS: Linux (All)
            Status: NEW
          Severity: normal
          Priority: medium
         Component: Drivers/DRI/i965
          Assignee: intel-3d-bugs at lists.freedesktop.org
          Reporter: b7.10110111 at gmail.com
        QA Contact: intel-3d-bugs at lists.freedesktop.org

Created attachment 143969
  --> https://bugs.freedesktop.org/attachment.cgi?id=143969&action=edit
Test case

I was trying to make use of GL_ARB_gpu_shader_fp64 to improve precision of
calculation of angle between two vectors via dot product. On NVIDIA GeForce
750Ti (with binary driver) on Linux 4.14.105, as well as Mesa software renderer
it works nicely, while on Intel Core i7-4765T GPU with Mesa 19.1.0-devel
(git-1af7701666) it gives wrong results.

I've reduced the problem to imprecise division of a pair of large numbers. The
GLSL code is basically like this:

void runTest(vec2 numerator_, vec2 denominator_)
{
    // numerator_ and denominator_ are double-float32 pairs, so that
    // sum of the components casted to float64 gives final precise values.
    double numerator=double(numerator_.x)+double(numerator_.y);
    double denominator=double(denominator_.x)+double(denominator_.y);
    double ratio=numerator/denominator;
    // 1-ratio appears wrong
    // ...
}

I'm attaching the complete test code, which runs a function similar to the
above and outputs some results to a float32 texture for further examination.

Ideally (as e.g. on NVIDIA GPU mentioned above, and on Mesa software renderer)
columns 7 and 8 of the output (in CSV format) should be almost the same. The
values should decrease monotonically, staying positive. On Intel GPU mentioned
above I get piecewise-increasing values in column 7 instead, going from
negative to positive again and again.

This piecewise-increasing behavior is inconsistent not only with float64
calculations, but even with float32, where it should alternate between few
positive values and zero. I.e., I couldn't reproduce the pattern when I tried
to do this in an independent CPU program with rounding to different precisions.
So I suspect that some optimization might be misbehaving here.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/intel-3d-bugs/attachments/20190415/5e79eed7/attachment.html>


More information about the intel-3d-bugs mailing list