How to set CUDA compiler flags in Visual Studio 2010?

烈酒焚心 提交于 2019-11-26 11:34:11

问题


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

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

Many thanks.


回答1:


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

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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/14411435/how-to-set-cuda-compiler-flags-in-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!