title: OpenCL, manage device buffer pointer from host?
body: <p>I'm trying to implement a code previously written in CUDA using OpenCL to run on Altera FPGA. I'm having problem reading back data that are supposed to be in the buffer. I use the same structure as CUDA version, only thing different is cudaMalloc can allocate memory for all types of pointer while for clCreateBuffer I have to use cl_mem. My code looks like this:</p>
  
  <pre><code>cl_mem d_buffer=clCreateBuffer(...);
   //CUDA version:
   //float* d_buffer;
   //cudaMalloc((void **)&amp;d_buffer, MemSz);
  
  clEnqueueWriteBuffer(queue, d_buffer, ..., h_data, );
   //cudaMemcpy(d_buffer, h_Data, MemSz, cudaMemcpyHostToDevice);
  
  #define d_buffer(index1, index2, index3) &amp;d_buffer + index1/index2*index3
   //#define d_buffer(index1, index2, index3) d_buffer + index1/index2*index3
  
  cl_mem* d_data=d_buffer(1,2,3);
  
  clEnqueueReadBuffer(queue, *d_data,...)// Error reading d_data
  </code></pre>
  
  <p>I tried clEnqueueMapBuffer or CL_MEM_ALLOC_HOST_PTR for the clCreateBuffer, it doesn't work either.</p>