Is the following legal in Cuda ?
foo.cu
#ifdef __CUDA_ARCH__
#define X 1
#else
#define X 0
#endif
__device__ __host__ int foo()
{
return X;
}
CUDA documentation says that the host should not use __CUDA_ARCH__
. So can we pretend the value is undefined? Also, can we use __CUDA_ARCH__
outsde a __device__
function? Even here in practice, it’s used inside, but the macro is defined outside the __device__
function.