Bug 89049 - fmod returns wrong values
Summary: fmod returns wrong values
Status: RESOLVED NOTABUG
Alias: None
Product: Beignet
Classification: Unclassified
Component: Beignet (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium major
Assignee: Zhigang Gong
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-09 23:45 UTC by Pavan Yalamanchili
Modified: 2015-02-10 18:41 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
source code to reproduce the bug (4.16 KB, text/plain)
2015-02-09 23:45 UTC, Pavan Yalamanchili
Details

Description Pavan Yalamanchili 2015-02-09 23:45:31 UTC
Created attachment 113290 [details]
source code to reproduce the bug

A simple kernel performing fmod returns wrong results when compared to the C's math library. The attached file can reproduce this problem.



System tested on:

Device: Intel(R) HD Graphics IvyBridge GT2
Beignet version: Release_v1.0.0
Linux Kernel: 3.18.4-1-ARCH
Comment 1 Zhigang Gong 2015-02-10 03:27:28 UTC
I just tried the test case with strict conformance mode, and it could pass.
The difference between strict conformance mode and the normal mode[default]
is that the normal mode will try to use Gen instruction to implement a fast
but less accuracy math library. For this example:

fmod(3.0, 0.3), the theoritical result should be 0. But considering that
the 0.3 could not be represented accurately by float point data. 

Actually 0.3f is 0.30000001, so fmod (3.0, 0.30000001) should be 0.29999989.

This accuracy requirement exceeds the default mode's range.

If your applications require numerical accurate result, I'd recommend you to
always enable the strict conformance mode by set the following envirnment variabe before you call into beignet to compile ocl kernels.

export OCL_STRICT_CONFORMACE=1

I you found its performance is very bad for some important applications, you are welcome to file performance bug here.

Thanks.
Comment 2 Pavan Yalamanchili 2015-02-10 18:41:28 UTC
yes, running with strict conformance fixed the issue.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.