Numerical accuracy of erfc function seems problematic
I am running some kind of Monte Carlo on GPU using opencl. I've got some strange results so I started to investigate problem. Seems that values of erfc function are wrong for some arguments.
Example: attached kernel run on CPU gives the correct result: 0.330402, but for GPU it gives a completely wrong answer: 0.0804025.
My system: Linux, kernel 2.6.28-16, gcc 4.3.3. CPU AMD64, quad core. GPU: ATI HD4770.
float phi(float z) { /* Standard statistical normal distribution*/ return erfc( -z/sqrt(2) )/2; } /*Simulates normal probabilities using quasi Monte Carlo*/ __kernel void qsimKernel(__global float * prob) { prob[0]=phi(-0.438802f); }