-2

I have been developing with CUDA v6.5 in Visual Studio 2012 and have run into a problem: When compiling a .cu file the compiler will output multiple warnings for a single line of source code. Normally this wouldn't be a huge deal, but it has started taking a very long time to build and I suspect this might be why. For example:

int unused = 0;

generates the following error four times:

1>.../GeometryManager.cu(188): warning : variable "unused" was declared but never referenced

These are the command line arguments that are being passed to nvcc:

-gencode=arch=compute_35,code=\"sm_35,compute_35\" --use-local-env --cl-version 2012
-ccbin "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include"
-G   --keep-dir Debug -maxrregcount=0  --machine 32 --compile
-cudart static -arch sm_20  -g   -DNDEBUG -DWIN32 -D_DEBUG -D_CONSOLE
-D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd  "
-o Debug\GeometryManager.cu.obj "C:\...\GeometryManager.cu" 

When compiling .cpp files, warnings seem to be issued normally. So far I tried changing the value for Code Generation in properties to compute_35,sm_35, (it previously had several of these listed) but it didn't help.

I'd appreciate if someone with CUDA or nvcc experience could shed some light on the situation. Any other advice on how to reduce build times with CUDA would be helpful as well. Thanks.

2
  • 1
    Maybe removing the unused variable from your code may help get rid of the warnings? Feb 12, 2015 at 11:25
  • Well, sure. It's not the warning I'm worried about; I'm worried that the compiler is doing extra work which is making my build times skyrocket. Feb 12, 2015 at 13:24

1 Answer 1

1

On reason it generates the warning multiple times is because it is compiling your code multiple times due to the specification of multiple targets:

-gencode=arch=compute_35,code=\"sm_35,compute_35\"

and

-arch sm_20

If you don't need both sets of targets, you can reduce the warning messages produced and shorten your compile time by deleting one of these (i.e. removing it from your visual studio project configuration). (I think you'll end up with 2 sets of warnings instead of 4, in this case.)

3
  • Thanks for your reply. I removed the -arch sm_20 option, which did indeed net me two warnings instead of four. Just to clarify my understanding, the sm_ parameters tell the compiler to generate binary code for actual hardware. The compute_ parameters tell the compiler to generate a particular kind of PTX code, which is compiled and loaded at runtime. I don't understand why, according to the NVCC manual, the sm_ and compute_ parameters have to be compatible. They seem to describe two mutually exclusive back-ends for the compiler. Much thanks for helping me sort this out. Feb 12, 2015 at 16:02
  • For a given target, the virtual and physical architectures must be compatible. You can specify the inclusion of "incompatible" architectures by specifying multiple targets (-- just as your example started out. One target was cc2.0 device plus PTX, the other target was a cc3.5 device plus PTX). It's already a fairly involved topic. It might have been possible for the compiler designers to allow you to specify a given PTX version and a different (incompatible) SASS version in a single "target" specification, but that (IMO) gets awfully confusing. Feb 12, 2015 at 16:37
  • 1
    Also, there are variations of the -gencode option which allow you to specify a PTX-only target (no SASS), and also other variations which allow you to specify a SASS-only (no PTX) target. So there is considerable flexibility already. Feb 12, 2015 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.