I’m trying to call cudaGetDeviceCount and cudaDeviceProperties from my main.c code, compiled with GCC. I don’t use any other functions, this is just to see if there’s a supported CUDA device. All my runtime kernel launch and kernel itself are in a kernel.cu file which is compiled with nvcc and linked.
The problem is that I can’t use cudaGetDeviceCount() without including its header file, cuda_runtime_api.h .
But including that causes a chain of subincludes, which define many unneeded device specific types like float3… which has typename collisions with types in my main code.
Is it proper to be calling cudaGetDeviceCount() from a .c file that’s not compiled with NVCC?
Or is it fine but CUDA’s header files are not organized well and are bringing in lots of unneeded type definitions?
A workaround would for me to make my own function wrappers in my .cu files and call those wrappers from my .c code but that seems so ugly and arbitrary. And it gets worse since I want to examine the elements of the deviceProperties structure… it gets crazy to make a wrapper call for a getter for each structure element just to see what it’s set to!
I hope i’m missing something stupid… any ideas?