mersenneforum.org List of nvcc compiler macros?
 Register FAQ Search Today's Posts Mark Forums Read

 2013-10-11, 00:24 #1 ewmayer ∂2ω=0     Sep 2002 República de California 11,743 Posts List of nvcc compiler macros? Is there a way to get nvcc to dump all its internally defined compile-time macros? The nVidia docs typically mention just one, __CUDA_ARCH__ . For example, I need a way to differentiate nvcc from gcc in my platform-identifying headers - right now nvcc trips the "compiler = gcc" #ifdefs. I need to tweak these to first look for nvcc-specific compiler-ID macros before testing for the gcc ones. Under gcc I can dump macros using gcc -dM -E - < /dev/null but nvcc doesn't recognize that: nvcc fatal : Unknown option 'dM' Last fiddled with by ewmayer on 2013-10-11 at 01:33
 2013-10-11, 03:27 #2 jasonp Tribal Bullet     Oct 2004 354710 Posts __CUDA_ARCH__ only appears in device code, and is used to select device-specific code generation. nvcc predefines __CUDACC__ in host code as an indication that you're compiling with nvcc. To pass compiler option Q through nvcc to gcc, pass '-Xcompiler Q' to nvcc.
2013-10-12, 02:38   #3
ewmayer
2ω=0

Sep 2002
República de California

11,743 Posts

Quote:
 Originally Posted by jasonp __CUDA_ARCH__ only appears in device code, and is used to select device-specific code generation. nvcc predefines __CUDACC__ in host code as an indication that you're compiling with nvcc.
Thanks - the former, I am acquainted with. The latter is what I need (at minimum) - I have a lot of inline ASM wrapped in "if x86 and gcc..." detection #ifdefs, which need to be disabled in the device-code generation phase of the 2-step nvcc compilation.

Quote:
 To pass compiler option Q through nvcc to gcc, pass '-Xcompiler Q' to nvcc.
You mean this will allow me to to use the above macro-dump method with nvcc? (But even if so, that would dump the gcc macros, which are not the ones of main interest here.)

 2013-10-12, 13:36 #4 WraithX     Mar 2006 20A16 Posts I'm not sure if this is very elegant, or if it will work across all versions of nvcc, but I just ran: strings nvcc | grep [-]D And that produced the following output on my (linux) machine: Code: -DFATBINFILE="\" -D__USE_FAST_MATH__ -D__CUDACC__ -D__NVCC__ -D__CUDABE__ -D__CUDANVVM__ -DREGISTERLINKBINARYFILE="\" -D__CUDA_PREC_SQRT -D__CUDA_PREC_DIV -D__CUDA_FTZ -DLL -D__CUDA_ARCH__=100 -D__CUDA_ARCH__=110 -D__CUDA_ARCH__=120 -D__CUDA_ARCH__=130 -D__CUDA_ARCH__=200 -D__CUDA_ARCH__=210 -D__CUDA_ARCH__=300 -D__CUDA_ARCH__=350 -DCUDA_DOUBLE_MATH_FUNCTIONS -DCUDA_FLOAT_MATH_FUNCTIONS -DCUDA_NO_SM_11_ATOMIC_INTRINSICS -DCUDA_NO_SM_12_ATOMIC_INTRINSICS -DCUDA_NO_SM_13_DOUBLE_INTRINSICS -DCUDA_FLOAT_MATH_FUNCTIONS -DCUDA_NO_SM_12_ATOMIC_INTRINSICS -DCUDA_NO_SM_13_DOUBLE_INTRINSICS -DCUDA_FLOAT_MATH_FUNCTIONS -DCUDA_NO_SM_13_DOUBLE_INTRINSICS -DCUDA_DOUBLE_MATH_FUNCTIONS -DCUDA_DOUBLE_MATH_FUNCTIONS -DCUDA_DOUBLE_MATH_FUNCTIONS I'm not sure if this method will give you all the predefined macros, but it looks like it gives you quite a few. Hopefully some of these will be helpful for you.
 2013-10-12, 20:40 #5 ewmayer ∂2ω=0     Sep 2002 República de California 11,743 Posts Yes, that looks to be along the lines of what I was asking for - just by way of a spot-check, I see 2 distinct nVidia-compiler strings, __CUDACC__ (as noted by Jason) and also __NVCC__ . I wonder if those are entirely interchangeable, or perhaps nVidia is allowing for future differentiation of some kind there. There are multiple __CUDA_ARCH__ in the list, which it seems represents all the ones this version of the compiler recognizes. Just out of curiosity, which one actually corresponds to the compute capacity of your GPU?
2013-10-12, 23:53   #6
TheJudger

"Oliver"
Mar 2005
Germany

100010110002 Posts

Quote:
 Originally Posted by ewmayer There are multiple __CUDA_ARCH__ in the list, which it seems represents all the ones this version of the compiler recognizes. Just out of curiosity, which one actually corresponds to the compute capacity of your GPU?
Actually none. This is just for which compute capability (CC) the compiler generates the code. This has nothing to do with your GPU, this is what you're requested during runtime of the compiler. They map directly to the CC, e.g. __CUDA_ARCH__ 100 = CC 1.0, 110 = CC 1.1, ...

Oliver

2013-10-13, 00:24   #7
ewmayer
2ω=0

Sep 2002
República de California

11,743 Posts

Quote:
 Originally Posted by TheJudger Actually none. This is just for which compute capability (CC) the compiler generates the code. This has nothing to do with your GPU, this is what you're requested during runtime of the compiler. They map directly to the CC, e.g. __CUDA_ARCH__ 100 = CC 1.0, 110 = CC 1.1, ... Oliver
Yes, I know - I assumed WraithX was doing actual GPU-hardware work, was just curious what the CC (in the sense of maximum hardware-usable value of __CUDA_ARCH__) of that was. I must've been mumbling. :)

2013-10-13, 00:30   #8
TheJudger

"Oliver"
Mar 2005
Germany

23×139 Posts

Quote:
 Originally Posted by ewmayer I must've been mumbling. :)
Or I didn't get the correct meaning of your previous post (english is not my primary language and when it is late...). To be honest, I though that you should know it already.

Oliver

2013-10-13, 00:46   #9
WraithX

Mar 2006

2×32×29 Posts

Quote:
 Originally Posted by ewmayer There are multiple __CUDA_ARCH__ in the list, which it seems represents all the ones this version of the compiler recognizes. Just out of curiosity, which one actually corresponds to the compute capacity of your GPU?
Well, my computer has a GTX570 and I'm running the 310.19 nVidia driver. If I'm reading the docs right, it looks like that card supports up to CC2.0. I'm not doing too much in the way of GPU-hardware work. My primary use of it so far was to do polynomial selection with msieve on this and on a GTX580 in another machine. The poly search finished a while ago and now I'm doing lots of ggnfs sieving.

 Similar Threads Thread Thread Starter Forum Replies Last Post Dubslow Programming 2 2016-02-27 06:55 R.D. Silverman Programming 17 2015-09-29 03:44 tichy Programming 1 2011-03-06 16:24 R.D. Silverman Cunningham Tables 30 2010-10-02 22:12 geoff Programming 3 2007-09-26 03:09

All times are UTC. The time now is 11:23.

Thu Sep 29 11:23:41 UTC 2022 up 42 days, 8:52, 0 users, load averages: 1.09, 1.19, 1.11