【发布时间】:2016-03-13 20:07:04
【问题描述】:
我正在使用 OpenCL / OpenGL Interop 开发一个基本的光线追踪器。我在使用共享工作组内共享本地内存的内核时遇到了一些问题。
这是内核:
__kernel void ComputeDirectionalShadowTexture(
write_only image2d_t shadowTexture,
read_only image2d_t positionTexture,
__constant float3* lightDirection, __constant float4* spheres,
)
{
__local bool* shadowReduce[2];
__local size_t idX, idY, idZ, localID;
idX = get_global_id(0);
idY = get_global_id(1);
idZ = get_global_id(2);
localID = get_local_id(2);
//...Read Textures
//...Perform Computation
//...Write results
if(shadowReduce[localID])
write_imagef(shadowTexture, threadCoord.xy, (float4)(1.0f, 0.0f, 0.0f, 1.0f));
}
当运行它时,好像 get_local_id() 函数永远不会返回 0(或只返回 1)。
我希望问题与我调用内核的方式有关:
size_t numGlobal[3] =
{
rBuffer->textureWidth,
rBuffer->textureHeight,
numSpheres
};
size_t numLocal[3] = { 1, 1, numSpheres};
cl_event execution;
//Execute kernel
clError = clEnqueueNDRangeKernel
(
buffer->clQueue,
members->directionalShadowKernel,
3,
NULL,
&numGlobal,
&numLocal,
numBeforeExecution,
completeBeforeExecution,
&execution
);
其中numSpheres 是设置为2 的常量。
感谢任何/所有反馈。
【问题讨论】:
-
问题标题很好,答案确实匹配。但是,问题文本没有用,因为它太复杂了。该错误不应与光线跟踪有关。它应该可以通过更短的内核来重现。如果您将其简化为一个产生相同错误的小得多的示例,您的问题将对更多读者更有用。
-
我同意。我会尽快编辑和修复这个问题。过去几天我真的很忙,但在接下来的 24 小时内,我会继续进行这些更改。感谢您的建设性批评。
标签: c opencl local gpgpu nvidia