In The OpenCL 1.1 specification, i saw a function which is called “clCreateSubBuffer”. I think it makes what you want to do but i have never been able to test it since i wasn’t allowed to install beta Nvidia’s drivers for 1.1.
You are right as I want something more flexible and generic. Using clCreateSubBuffer can be an option but I am having problem with using it. Maybe, I am missing something:
cl_buffer_region *info= new cl_buffer_region();
info->size= (size_t)8;//in bytes for float
info->origin=(size_t)0; // in bytes for float
newBuffer = clCreateSubBuffer (newDevicePointer,CL_MEM_READ_WRITE, CL_BUFFER_CREATE_TYPE_REGION, info, NULL); //Segmentation fault
Last line gives me segmentation fault and I don’t know why and there is no help about it out there. I have ensured that parent buffer is not a subbuffer and other constraints but still, no clue.
Have someone used clCreateSubBuffer or know about this problems?
Err… you do realise in OpenCL you allocate a HANDLE to an opaque struct that contains important stuff for the OpenCL runtime (like what GPU and CL runtime you have loaded). Thus you cannot do any host side pointer arithmetic like you can in CUDA.