Hello.
I wrote a very simple kernel that just copies the data from a source to a destination (e.g. image copy).
__kernel void copy_img(
__global unsigned char *src,
__global unsigned char *dst,
const int w
)
{
int gid_x = get_global_id(0) ;
int gid_y = get_global_id(1) ;
int index = gid_x + gid_y * w ;
dst[index] = src[index] ;
}
When I run this kernel with CPU (CL_DEVICE_CPU), it works well. However, the kernel above results in a weird result when it is run on GPU (CL_DEVICE_GPU). Most of the destination array is filled with garbage data…
An interesting thing is that the kernel work well when I changed the data type of destination array from ‘unsigned char *’ to ‘float *’ !!
__kernel void copy_img(
__global unsigned char *src,
__global float *dst,
const int w
)
{
int gid_x = get_global_id(0) ;
int gid_y = get_global_id(1) ;
int index = gid_x + gid_y * w ;
dst[index] = src[index] ;
}
This is very weird…
Is there anything I have to keep in my mind to work with unsigned char type ??
Thanks in advance.