Hi,
I do my first steps for local memory working and try to begin with this global memory working code :
datas : a={0,1,2,3,…}, b={0,3,6,9,…}
__kernel void localTest(__global const unsigned char *a,
__global const unsigned char *b,
__global unsigned char *c)
{
int x = get_global_id(0);
c[x] = a[x]+ b[x];
}
, where it’s OK. (c={0,4,8,12,…})
The following code generates wrong value :
#define TILE_DIM 16
__kernel void localTest(__global const unsigned char *a,
__global const unsigned char *b,
__global unsigned char *c)
{
int x = get_global_id(0);
__local unsigned char localTemp[2];
localTemp[0] = a[x]; //(*)
localTemp[1] = b[x]; //(**)
c[x] = localTemp[0] + localTemp[1];
}
If I only comment (**) and do (c[x]=localTemp[0];), values are correct,(c={0,1,2,3,…})
if I only comment (*) and do (c[x]=localTemp[1];), values are correct too.(c={0,3,6,9,…})
But the code above give : (c={15,18,21,24,…})
Can you help me to resolve this issue?
Thanks in advance.