如何将uuu CUDACC_VER_uuuuu值转换为主要、次要的构建三元组?

如何将uuu CUDACC_VER_uuuuu值转换为主要、次要的构建三元组?,cuda,nvcc,Cuda,Nvcc,当一个较新的(CUDA 9)版本的nvcc遇到\uuuuu CUDACC\u VER\uuuuu时,它会放弃,并告诉您如下信息: /usr/local/cuda/include/crt/common_functions.h:64:24: error: token ""__CUDACC_VER__ is no longer supported. Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ ins

当一个较新的(CUDA 9)版本的nvcc遇到
\uuuuu CUDACC\u VER\uuuuu
时,它会放弃,并告诉您如下信息:

/usr/local/cuda/include/crt/common_functions.h:64:24: error: token ""__CUDACC_VER__ is no longer supported.  Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."" is not valid in preprocessor expressions
 #define __CUDACC_VER__ "__CUDACC_VER__ is no longer supported.  Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."
那么,我如何将
\uuuuu CUDACC\u VER\uuuuu
的用法转换成既适用于旧版NVCC又适用于新版NVCC的用法呢?

部分答案:

至少对于较新的版本,公式告诉我们(第3页)公式是什么:

因此,例如,从CUDA 7.5或更高版本检查nvcc意味着检查

(__CUDACC_VER__ > 70500)
用这三组值,你可以写

(__CUDACC_VER_MAJOR__ > 7) or ((__CUDACC_VER_MAJOR__ == 7) and (__CUDACC_VER_MINOR__ >= 5))
相反

(__CUDACC_VER_MAJOR__ > 7) or ((__CUDACC_VER_MAJOR__ == 7) and (__CUDACC_VER_MINOR__ >= 5))