AnsweredAssumed Answered

memcpy in OpenCL kernel

Question asked by shingoxlf on Mar 8, 2012
Latest reply on Mar 16, 2012 by notzed

Hi, I was trying to implement a simple memcpy function in the opencl kernel:

 

void memcpyint(__global int *dest, const __global int *src, int len)

{

    for(int i=0;i<len;i++) dest[i]=src[i];

    return;

}

 

and here is my kenel:

__kernel void simple(__global int *a; __global int *b)

{

int id=get_global_id(0);

memcpyint(a[id*10],b[id*10],10)

return;

}

 

But I got error "CL_OUT_OF_RESOURCES " when I try to copy GPU memory back to CPU

 

 

If I do not call the memcpyint function and change the kernel to:

__kernel void simple(__global int *a; __global int *b)

{

int id=get_global_id(0);

for(int i =0;i<10;i++)

    {

        a[id*10+i] = b[id*10+i];

    }

 

return;

}

 

the code is working. Can anyone tell me why the function memcpyint does not work? Thanks!

Outcomes