Friday, 6 September 2013

OpenCL out of bounds errors

OpenCL out of bounds errors

This kernel works fine:
__kernel void test(__global float* a_Direction, __global float* a_Output,
const unsigned int a_Count)
{
int index = get_global_id(0);
if (index < a_Count)
{
a_Output[index * 3 + 0] = a_Direction[index * 3 + 0] * 0.5f + 0.5f;
a_Output[index * 3 + 1] = a_Direction[index * 3 + 1] * 0.5f + 0.5f;
a_Output[index * 3 + 2] = a_Direction[index * 3 + 2] * 0.5f + 0.5f;
}
}
This kernel produces out of bounds errors:
__kernel void test(__global float3* a_Direction, __global float3*
a_Output, const unsigned int a_Count)
{
int index = get_global_id(0);
if (index < a_Count)
{
a_Output[index].x = a_Direction[index].x * 0.5f + 0.5f;
a_Output[index].y = a_Direction[index].y * 0.5f + 0.5f;
a_Output[index].z = a_Direction[index].z * 0.5f + 0.5f;
}
}
To me it seems like they should both do the exact same thing. But for some
reason only one of the two works. Am I missing something obvious?
The exact error is: "CL_OUT_OF_RESOURCES error executing
CL_COMMAND_READ_BUFFER on GeForce GTX580M (Device 0).

No comments:

Post a Comment