compile host code with gcc?

I am trying to reorganize a CUDA program I wrote into a better modularized structure. I separated the C from the CUDA bits, and compile each unit with their respective compilers, liking them in the end. Now I am trying to separate the CUDA kernels and the CUDA host code (the non-kernel part of the cuda call, such as cudaMalloc, cudaGetDeviceCount etc) in this unit [1].

Shall I compile the host code with nvcc as an cu file, or I can compile it with gcc as a C file?

I tried compiling the host code as a c file, but it always complains ‘cudaDeviceProp’ undeclared which I am pretty sure I’ve included the necessary header files.

thank you in advance for any suggestions.

[1] https://orbit.nmr.mgh.harvard.edu/plugins/s…amp;view=markup

I’m not seeing you include cuda_runtime.h (or is it cuda_runtime_api.h? I forget)

are you referring to the current mcx_core.cu? cuda.h is included in br2cu.h.

Indeed, I meant to split the mcx_core.cu you see on the svn into two units, mcx_kernel.cu and mcx_host.??

mcx_kernel.cu contains the kernels only, and mcx_host.?? contains the following host functions:

int mcx_set_gpu(int printinfo);

void mcx_cu_assess(cudaError_t cuerr);

void mcx_run_simulation(Config *cfg);

however, if I name it as mcx_host.c, and compile it with gcc -I/usr/local/cuda/include, I will get “cudaDeviceProp undeclared” error, even I include “cuda_runtime_api.h” or “driver_types.h”. This is similar to the following report:

http://forums.nvidia.com/index.php?showtopic=101198

any ideas why?