0
我在OpenCL中编写了一个光线跟踪程序,并且在我的内核中有一个函数,Quadratic,它接收3个浮点变量和两个指向浮点值的指针。在OpenCL内核中通过指针访问变量
功能:
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;
}
调用该函数:
float t0;
float t1;
if (Quadratic(A, B, C, &t0, &t1)) c[(i*dimy)+j] = t0;
else c[(i*dimy)+j] = 0.0;
产生以下错误:
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
在努力工作,出了什么问题,我创建了以下测试功能似乎工作:
bool TestFunc(float Y, float *x) {
*x = Y;
return true;
}
float x;
if (TestFunc(50.0, &x)) c[(i*dimy)+j] = x;
据我可以看到这两个函数具有相同类型的输入和输出,任何帮助将不胜感激。
使用clGetProgramBuildInfo()获取错误的详细信息。这直接指向像“sqrt()not defined”这样的问题。 – DarkZeros