It turns out the problem was with using sqrtf
. Once changed to sqrt
it works perfectly.
Accessing variable by pointer in OpenCL kernel
문제
I am writing a raytracing program in OpenCL and I have a function in my Kernel, Quadratic, that takes in 3 float variables and two pointers to float values.
Function:
bool Quadratic(float A, float B, float C, float *t0, float *t1) {
float discrim = B * B - ( 4.0 * A * C );
if (discrim <= 0.0) return false;
float rootDiscrim = sqrtf(discrim);
float q;
if (B < 0) q = -0.5f * ( B - rootDiscrim);
else q = -0.5f * ( B + rootDiscrim);
*t0 = q / A;
*t1 = C / q;
float temp;
return true;
}
Calling the Function:
float t0;
float t1;
if (Quadratic(A, B, C, &t0, &t1)) c[(i*dimy)+j] = t0;
else c[(i*dimy)+j] = 0.0;
Produces the following error:
pyopencl.RuntimeError: clBuildProgram failed: build program failure -
Build on <pyopencl.Device 'ATI Radeon HD 6750M' on 'Apple' at 0x1021b00>:
Error returned by cvms_element_build_from_source
In trying to work out what the problem was I created the following test function which seems to work:
bool TestFunc(float Y, float *x) {
*x = Y;
return true;
}
float x;
if (TestFunc(50.0, &x)) c[(i*dimy)+j] = x;
As far as I can see both functions have the same types of inputs and outputs, any help would be greatly appreciated.
해결책
제휴하지 않습니다 StackOverflow