CUDA y nvcc: uso del preprocesador para elegir entre flotante o doble
El problem:
Tener un .h, quiero definir real para que sea doble si compila para c / c ++ o para cuda con capacidad informática> = 1.3. Si compila para cuda con capacidad informática <1.3, defina real como flotante.
Después de muchas horas llegué a esto (que no 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
cuando compilo (tenga en cuenta la bandera -arch)
nvcc -arch compute_13 -Ilibcutil testFloatDouble.cu
Yo obteng
* 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: ....
Sé que los archivos se compilan dos veces por nvcc. El primero está bien CUDACC definido y CUDA_ARCH> = 130) pero ¿qué pasa la segunda vez? @ CUDA_DEFINED pero CUDA_ARCH indefinido o con valor <130? Por qué
Gracias por tu tiempo