sqrt function in CUDA kernel function call fails

Hello,

I’m having an 8800 GTX graphics card.

I’ve wrote a kernel for the same and I’m calling “sqrt” (squart function) from inside the kernel for a FLOAT value. sqrt does not give right result in that case.

If the same function is called from any other .cu file (i.e. Non-Kernel code), the function works fine.

Is it that one can’t call math functions from the kernel?

Thanks,
Tanmay Anjaria

You can.
There is something wrong with your code.

What do you mean by the right result? Can you give the original value and the value returned by square root? Keep in mind that Intel chips (unless you use SSE) store floats in extended 80 bit precision (instead of 32), so you’re bound to see different results. You can supply an option to the compiler to enforce stricter IEEE754 conformance on CPUs, in which case I believe the results will be quite close.

Paulius