CUDA e nvcc: usando o pré-processador para escolher entre float ou double

O problem:

Tendo um .h, quero definir real como duplo se estiver compilando para c / c ++ ou cuda com capacidade de computação> = 1.3. Se estiver compilando para cuda com capacidade de computação <1,3, defina real como flutuant

epois de muitas horas cheguei a isso (que não funciona)

#   if defined(__CUDACC__)

#       warning * making definitions for cuda

#       if defined(__CUDA_ARCH__)
#           warning __CUDA_ARCH__ is defined
#       else
#           warning __CUDA_ARCH__ is NOT defined
#       endif

#       if (__CUDA_ARCH__ >= 130)
#                       define real double
#                       warning using double in cuda
#       elif (__CUDA_ARCH__ >= 0)
#               define real float
#               warning using float in cuda
#               warning how the hell is this printed when __CUDA_ARCH__ is not defined?
#       else
#               define real 
#               error what the hell is the value of __CUDA_ARCH__ and how can I print it
#       endif

#   else
#       warning * making definitions for c/c++
#       define real double
#       warning using double for c/c++
#   endif

quando eu compilar (observe o sinalizador -arch)

nvcc -arch compute_13  -Ilibcutil testFloatDouble.cu 

Eu receb

* making definitions for cuda
__CUDA_ARCH__ is defined
using double in cuda

* making definitions for cuda
warning __CUDA_ARCH__ is NOT defined
warning using float in cuda
how the hell is this printed if __CUDA_ARCH__ is not defined now?

Undefined symbols for architecture i386:
  "myKernel(float*, int)", referenced from: ....

Eu sei que os arquivos são compilados duas vezes pelo nvcc. O primeiro está OK CUDACC definido e CUDA_ARCH> = 130) mas o que acontece na segunda vez? CUDA_DEFINED mas CUDA_ARCH indefinido ou com valor <130? Por quê

Obrigado pelo seu tempo

questionAnswers(2)

yourAnswerToTheQuestion