|Summary:||fmod returns wrong values|
|Product:||Beignet||Reporter:||Pavan Yalamanchili <pavan>|
|Component:||Beignet||Assignee:||Zhigang Gong <zhigang.gong>|
|Status:||RESOLVED NOTABUG||QA Contact:|
|i915 platform:||i915 features:|
|Attachments:||source code to reproduce the bug|
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.