mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Hardware > GPU Computing

Reply
 
Thread Tools
Old 2013-10-11, 00:24   #1
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

11,743 Posts
Default 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
ewmayer is offline   Reply With Quote
Old 2013-10-11, 03:27   #2
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

354710 Posts
Default

__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.
jasonp is offline   Reply With Quote
Old 2013-10-12, 02:38   #3
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

11,743 Posts
Default

Quote:
Originally Posted by jasonp View Post
__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.)
ewmayer is offline   Reply With Quote
Old 2013-10-12, 13:36   #4
WraithX
 
WraithX's Avatar
 
Mar 2006

20A16 Posts
Default

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.
WraithX is offline   Reply With Quote
Old 2013-10-12, 20:40   #5
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

11,743 Posts
Default

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?
ewmayer is offline   Reply With Quote
Old 2013-10-12, 23:53   #6
TheJudger
 
TheJudger's Avatar
 
"Oliver"
Mar 2005
Germany

100010110002 Posts
Default

Quote:
Originally Posted by ewmayer View Post
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
TheJudger is offline   Reply With Quote
Old 2013-10-13, 00:24   #7
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

11,743 Posts
Default

Quote:
Originally Posted by TheJudger View Post
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. :)
ewmayer is offline   Reply With Quote
Old 2013-10-13, 00:30   #8
TheJudger
 
TheJudger's Avatar
 
"Oliver"
Mar 2005
Germany

23×139 Posts
Default

Quote:
Originally Posted by ewmayer View Post
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
TheJudger is offline   Reply With Quote
Old 2013-10-13, 00:46   #9
WraithX
 
WraithX's Avatar
 
Mar 2006

2×32×29 Posts
Default

Quote:
Originally Posted by ewmayer View Post
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.
WraithX is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
GCC/compiler warnings Dubslow Programming 2 2016-02-27 06:55
GNU specific macros R.D. Silverman Programming 17 2015-09-29 03:44
macros in nasm tichy Programming 1 2011-03-06 16:24
Help! Compiler bug R.D. Silverman Cunningham Tables 30 2010-10-02 22:12
Linux32 -> Windows64 C compiler? 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

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔