copying cl_mem directly to GPU

Discussion created by mihzaha on Aug 25, 2010
Latest reply on Aug 26, 2010 by mihzaha

if I have a structure like this:

struct x


    cl_mem a;

    cl_mem b;



struct x cpu_struct_x;

cl_mem gpu_struct_x;


gpu_struct_x = clCreateBuffer(..., sizeof(struct x), ...);


cpu_struct_x.a =  clCreateBuffer(..., sizeof(cl_uint) * N, ...);

cpu_struct_x.b =  clCreateBuffer(..., sizeof(cl_float) * M, ...);


and on the GPU:

struct x


    uint *a;

    float *b;



can I do:

clEnqueueWriteBuffer(..., gpu_struct_x, ...,  sizeof(struct x), &cpu_struct_x, ...); ?

I need this, because I have many lists, and I just want to pass a pointer to a structure which contains pointers to all the lists to the kernels.

I thought this, because I understand cl_mem objects as simple pointers, and I'm not sure that's true...


Thank you


[edit] And what about pointer arithmetics? If I want to copy from element 2 can I do 

clEnqueueReadBuffer(..., cl_mem_vector + sizeof(dim_element) * 2 , ...); ?

-I found out I can't do that, so how could I read only a part of a vector, starting with index N ?