Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set CUDA compiler flags in Visual Studio 2010?

After persistently getting error : identifier "atomicAdd" is undefined, I've found the solution to be to compile with -arch sm_20 flag. But how to pass this compiler flag in VS 2010? I have tried like so under Project > Properties:

enter image description here

But this apparently has had no effect and the error persists - what am I doing wrong?

Many thanks.

like image 588
mchen Avatar asked Jan 19 '13 05:01

mchen


People also ask

Does CUDA work with Visual Studio 2010?

Now there’s a whole new bunch of modules that need to be specified in order to make a set of custom build rules to work with Visual Studio 2010 project. This blog explains the steps involved in making CUDA work on the new Visual Studio 2010.

How do I Configure my project's CUDA Properties page?

To configure your project's CUDA properties page: In the Solution Explorer, click on the project name so that it is highlighted. From the Project menu, choose Properties. The Property Pages window opens. Select CUDA C/C++ in the left pane.

Does CUDA toolkit support VS100 C compilers?

The latest CUDA Toolkit 3.2 does not has support for the VS100 C compiler and hence the reason why you still need to have Visual Studio 2008 installed on your machine. Also make sure you have the right Windows SDK (or at least anything below Windows SDK v7.0 which is automatically installed with VS 2010). Now we are ready to get started.

Why can’t I include CUDA code in NVCC?

You’re fundamentally trying to include CUDA code in a .cpp module, and that is basically a no-no. That won’t get compiled with the usual nvcc setup. nvcc passes that off to the host compiler, and the host compiler doesn’t know anything about the __CUDACC flags, nor does it know what a CUDA experimental extended lambda is.


3 Answers

You can select the options for the GPU Code Generation in this dialog:

GPU Code Generation

In this case "compute_20" means that i am compiling for the virtual compute architecture 2.0 - virtual architecture influences the PTX generation stage.

The second part that comes after the coma is "sm_21".This influences the CUBIN generation stage. It defines the real GPU architecture i want to compile the PTX to.

You can find detailed description of the nvcc command line parameters that control the code generation here.

like image 114
RoBiK Avatar answered Oct 14 '22 04:10

RoBiK


Go to the "Device" section under "CUDA C/C++". There, within "Code Generation" you can specify your sm_20. No need for the -arch.

like image 2
Bart Avatar answered Oct 14 '22 03:10

Bart


Be aware that there's separate properties for both the project and .cu files. Apparently they get merged before compilation.

I'd gotten caught by this trying to specify GPUs for compute 3.0 & greater, but .cu properties had some leftover specifications for 1.0 & 2.0

like image 2
DoctorBonzo Avatar answered Oct 14 '22 02:10

DoctorBonzo