PDA

View Full Version : Built in math functions not working with double precision floats?


Morgan_272
04-Jun-2010, 14:16
Hi

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

I am running on an AMD Phenom3 CPU, with a Gigabyte Radeon HD5870.

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);
}

When my app executes the kernel it crashes, if I analyze the above code using Kernel StreamAnalyzer 1.5, I get the following compile error:

OpenCL Compile Error: clBuildProgram failed (CL_BUILD_PROGRAM_FAILURE).

Error: Undeclared function index 1207

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

Thank you!

Dade
04-Jun-2010, 15:18
If anyone could tell me how to fix / get round this issue I would be most gratefull.


ATI support double precision only via a proprietary extension. I'm afraid you can use only basic +, -, *, / operations and few more functions: http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=88

Mintmaster
07-Jun-2010, 19:31
ATI support double precision only via a proprietary extension. I'm afraid you can use only basic +, -, *, / operations and few more functions: http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=88It's not that bad. According to that link, DP supports:

The following geometric functions: min, max, clamp, degrees, radians, step, smoothstep, sign, dot, length.
The following math functions: cbrt, ceil, copysign, exp10, exp2, exp, fabs, fdim, floor, fmax, fmin, lgamma, log10, log2, log, mad, nextafter, rint, round, sinpi, sqrt, trunc.


Morgan272, maybe you just need to replace pow(4,2) with a constant or the exp2 equivalent.