Layout of source code


i am very new to GPU computing and i use Visual Studio 2008 with SDK Version 3.2.

I am wondering if it is correct to get linking errors when calling for example cudaMalloc() from a .cpp file.
If yes, all calls to the CUDA runtime API need to be done from .cu files, correct?

Thanks in advance, best regards

You will need to explicitly specific the cuda runtime API library to the linker if you are not going to use nvcc to link your application.

Is it considered bad practice to have every file end with .cuh or .cu although they might not need it?

I keep the CUDA parts of my projects separate as I’ve found that some libraries do not play well when used from nvcc, while linking together with nvcc-generated code worked fine. Just so I won’t find myself in the position that some library suddenly does not work together with CUDA anymore and the CUDA code is spread all over the project.