Data sharing between c++ and CUDA programs

I have a c++ file that captures images and converts them to a usable 2D matrix, and I have a separate CUDA file that uses the cuFFT library to perform fourier transforms on the GPU. I would like to compile these into a single file, but I am not sure how to ‘call’ and utilize the CUDA program to perform the fft on the image captured from the c++ program. I am aware of the cudaMemCpy() functions that will transfer data between the host and device, but I am not sure if this is the correct way to share variables and data between separate files. Is there possibly a way to define a function in the CUDA file to be called in the c++ program? Any insight appreciated.

cudaMemCpy() is correct.

A basic cuda program will be:

  1. copy data from cpu to gpu
  2. execute gpu kernel code
  3. copy results from gpu back to cpu

Here is a tutorial:

In advanced,
You can use unified memory to avoid memory copy since cpu and gpu share same memory on Tegra.
But you should modify your camera driver to output um format memory.