Hello, I have some doubt about the zerocopy function.
Suppose the code is something like below:
What I want to do is to zerocopy a pre-aligned memory M and transfer to a opencl function OpenCL_Foo, and after the calculation save the result to M.
Do I still get access to M(with the right calculation result from opencl function) even after the OpenCL_Foo ends?
#or do I need to memcopy it?
Thank you in advance for you kindly help.
//////////////////////////////////////////// void OpenCL_Foo(float*array_as_output,int SIZE, float*array_as_output_cpy) {//Some opencl process ... //set the parameter array as output buffer of some calculation. cl_mem buffer_out = clCreateBuffer(ctx, CL_MEM_WRITE | CL_MEM_USE_HOST_PTR,SIZE * sizeof(cl_float), array_as_output, &err); ... //is this part below necessay? or can I just access array_as_output outside this function? /* void* ptr1 = clEnqueueMapBuffer(queue, buffer_out , CL_TRUE, CL_MAP_READ, 0, SIZE*sizeof(float), 0, NULL, NULL, NULL); memcpy(array_as_output_cpy,ptr1,SIZE*sizeof(float)); err=clEnqueueUnmapMemObject(queue,buffer_out , ptr1, 0, NULL, NULL); */ }// end of OpenCL_Foo //////////////////////////////////////////// int main() { int SIZE = 1024; float*array_as_output; float*array_as_output_cpy; posix_memalign((void**)&array_as_output,4096,SIZE * sizeof (cl_float)); posix_memalign((void**)&array_as_output_cpy,4096,SIZE * sizeof (cl_float)); OpenCL_Foo(array_as_output,SIZE,array_as_output_cpy); ... }//end of main