How to set up a project correctly?

Hi guys,

I am very confused how the structure of a CUDA project in Visual Studio 2008 should look like.
The samples often use different ways and I don’t know which one is the best now.

Quickly to my project: It will be possible to switch between CUDA, Singlecore and Multicore in my program at runtime.
I do not want to write everything twice - so I use “host device” in front of every function.
Since my program is based on classes and the samples don’t show a way to realise this, I do not know how I should structure my project.

Some questions:

  1. When do I have to exclude a file from the project?
  2. Which Build Rule has to be used in which case? (C++, CUDA Build Rule, Custom Build)?
  3. is it true that “extern c” is out-of-date and does not have to be used anymore, since I write my code in C++?


The programming pattern is coherent across the SDK examples. Take a second close look.

Since C code is serial in nature, you have to make it parallel so re-writing cannot be avoided. Besides, you need to have sound knowledge of the GPU architecture (Kernels, Inter Thread Communication and Memory hierarchy) to exploit GPUs for getting good speedups.

  1. I did not get it?

  2. Use the CUDA Build rule located in your GPU Computing SDK (Cuda.rules file)

  3. Not sure


thanks for the answer - it helped me to go on working.
My problem was that i tried to separate header from body, what isn’t supported by CUDA yet.

the body has to be in the same file where the definition is - correct? i didn’t find any specification about that - just got this from forum entries.
Can someone confirm, that the body MUST be in the same file where the definition is? If not - could you post a example please