View Full Version : how to use math.h functions in __kernel

12-01-2009, 10:15 PM
How do you evaluate fuctions like sqrt() in a __kernel function? I did a straightforward implementation but that does not work. Like:

__kernel void Calc(int *a, int *b){
b[0] = sqrt(a[0]);

is anything extra required?

12-02-2009, 02:37 AM
What is the problem?
You want to test opencl sqrt function, or use native kernel and test the C sqrt function?

12-02-2009, 05:05 AM
The OpenCL spec lists all the math functions that are included. You can find this on the Khronos site. To use them you simply call them with the appropriate arguments. There is no need to include/use math.h as these are built-in.