CUDA from Scratch Starting with a blank canvas...


I have successfully created a particle accelerator tracking code using C++ and CUDA. In order to ensure a rapid development time, the CUDA components are basically the ‘template’ example modified to my needs.

However, it has become time to release this to the accelerator physics community. Unfortunately, the way the CUDA examples are structured is not how we would typically structure a code. What I would like to do is start a project from scratch and set up the custom build rules and additional dependencies manually. Is this possible? If so, is there a good tutorial that anyone can refer me to? I am using Visual Express C++ 2008, and want to build the CUDA parts into a DLL project.




Same question as you… except I can add that visual 2008 is not compatible with the CUDA SDK, try VS 2005 express.

So, how can one make a new VS project with the good configuration solutions (as nvidia samples) ?


Yes, the SDK is written for VS 2005. However, it converted to VS 2008 with no problems, so I am happy. I just love the idea of starting from scratch in whatever project I do.

Have you tried the wizard kyzhao made?

It’s designed for VS2005, I don’t know if it’s compatible with 2008.

According to me, the goal is to manage a vs project from scratch, without this wizard, in order to be sure all is understood.



The best tutorial for figuring out how to do the custom build rules needed for nvcc is the SDK examples. If you need something more complex (like the DLL compilation you mentioned), you’ll need to know the ins and outs of how custom build rules work and set them up to do what you need (check the output of nvcc --help for compilation options). I would stay away from this approach myself as there is a significant amount of setup required for each cuda file you add. As your project gets more and more complex, just managing all the build rules will require significant effort.

My suggestion is to use CMake and FindCUDA.cmake. Adding .cu files to the project and/or compiling DLLs requires almost no effort. Plus (if the rest of the app is linux/mac friendly) users on other platforms can build your code easily.

Read the nvcc manual, you can get more info.

But in my view, the Vs Express can’t make DLL. Only the prof. or team version can make DLL.

nvcc is not a true compiler, it just translate the cu into cpp or c. and the compiler compile them into obj. And then, the linker link the obj into DLL or lib or exe.

Read the nvcc manual and read the VS MSDN.