Results 1 to 2 of 2

Thread: CUDA - OpenCL Interaction

  1. #1
    Join Date
    Mar 2014

    CUDA - OpenCL Interaction

    hey all,

    i've tried to enable shared memory between opencl and cuda functions. what i've done is allocating gpu memory using cudaMalloc and then providing this pointer to clCreateBuffer function as host pointer.

    in case when data is first copied from host memory to device memory using cudaMemcpy and the original cuda pointer, and then copying the data back to host memory using clEnqueueReadBuffer using the cl_mem object received from clCreateBuffer i was successfull in receiving the original data.

    however if i first copy the data form host memory to device memory using clEnqueueWriteBuffer and then copy the data back using cudaMemcpy, then i get invalid data.

    i'm now not sure what is the reason for this behaviour. is it just luck that it does function in first case or is it a valid approach of achieving shared memory for OpenCL and CUDA applications? does it have anything to do with the UVA support from CUDA?

    i would be glad if anybody would help me....



  2. #2
    Senior Member
    Join Date
    Dec 2011
    I don't think that's going to work, and if it does, it's unsupported and likely to break down the road.

    One thing you could try is to create an OpenGL context, and then make an OpenCL interop context from that and a CUDA interop context from that. Then create an OpenGL buffer and interop objects on the OpenCL and CUDA sides. Finally, using the various interop commands, you can move ownership between OpenCL, OpenGL, and CUDA. I've done this with images/textures and it worked, but I didn't try it with buffers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts