CL_OUT_OF_RESOURCES 在 Nvidia Quadro M2000M 上

CL_OUT_OF_RESOURCES on Nvidia Quadro M2000M

昨天我运行 在新笔记本上对我们当前的应用程序进行了单元测试,但遇到了 CL_OUT_OF_RESOURCES 错误。代码本身 运行s 在 ATI 卡或英特尔 CPU 上没有错误。

让我怀疑的是 M2000M 支持 'OpenCL 1.2 CUDA'。这是标准 'OpenCL 1.2' 还是有所不同,我需要修改代码吗?

这里是代码:

__kernel void pointNormals(__global const uint* cellLinkIds, __global const uint* cellLinks,
                                    __global const float3* cellnormals, __global float3* pointnormals,
                                    const uint nrPoints)
{
    const uint gid = get_global_id(0);
    if(gid < nrPoints)
    {
        const uint first = select(cellLinkIds[gid-1], (uint)0, gid==0);
        const uint last = cellLinkIds[gid];

        float3 pointnormal = (float3)0.f;

        for(uint i = first; i < last; ++i)
        {
            pointnormal += cellnormals[cellLinks[i]];
        }

        pointnormals[gid] = normalize(pointnormal);
    }
}

/编辑: 在测试中我得到 6 个错误,首先是在 clWaitForEvents 的调用中,其他错误来自 clEnqueueWriteBuffer

找到原因...

gid0(第一个元素 afaik)时,带有 const uint first = select(cellLinkIds[gid-1], (uint)0, gid==0); 的行导致无效的内存访问。

const uint first = gid == 0 ? (uint)0 : cellLinkIds[gid - 1]; 修复了它。但我不明白的是为什么 AMD 卡确实可以解决该错误,而 Nvidia 却 return 出错了。