View Full Version : Double precision floats and built in math functions?

06-03-2010, 02:55 PM

I'm trying to do computations with double precision floats. I have figured out how to enable them - but the code will not compile if I try to use any of the built in math functions on these variables :S

See below code for an example:

#pragma OPENCL EXTENSION cl_khr_fp64 : enable
kernel void TestAll(global write_only double* a)
int index = get_global_id(0);
double x, y;
x = trunc(index / pow(4, 2));
y = trunc(index / 4) - (x * 4);
a[index] = hypot(x, y);

If anyone could tell me how to fix / get round this issue I would be most gratefull.

Thank you!

06-03-2010, 06:28 PM
It is always useful if you tell us which OpenCL implementation are you using. Apple/AMD/NVidia?

Also, could you post the build error log?

06-03-2010, 10:51 PM

Sorry. I am running on an ATI HD5870.

When I try compile this code in Stream KernelAnalyzer 1.5, I get:

OpenCL Compile Error: clBuildProgram failed (CL_BUILD_PROGRAM_FAILURE).

Error: Undeclared function index 1207

In my app it compiles but as soon as the application executes the kernel it crashes.


06-04-2010, 05:12 AM
That's pretty clearly a bug (Captain Obvious to the rescue!). I suggest contacting customer support from that vendor.

06-11-2010, 08:54 PM
Not a bug. You are using pow function wrongly. From the spec:

gentype pow (gentype x, gentype y)
gentype pown (gentype x, intn y)

See what's wrong? You have pow(4, 2) where you should have pown(4, 2) since 2 is an integer and not a gentype.