Which function should be put into which file?.c or .cu

I have one openmp function and one GPU kernel.

I plan to put openmp function in the .c file, compiled with icc.
and GPU kernel in the .cu file, compiled with “NVCC -ccbin icc”.
And the main function can be put in the .c file or .cu file? Right?

If a CPU function calls cudaMalloc or cudaMemcpy, is it required for this function to be in .cu file or compiled with NVCC?

Thanks.

I put my main function in .c file and allocate some memory on the GPU and then pass their address to the wrapper function of the kernel in .cu file.

I don’t know whether this works or is a valid strategy to organize all the functions.

You can call CUDA runtime API functions like cudaMalloc() or cudaMemcpy() from C code if you include cuda_runtime.h, you do not need to put them into a .cu file. Kernel launches using <<<>>> would have to be in a .cu file compiled with nvcc, however.