CUDA_ARCH and templates

According to CUDA C++ Programming Guide

  1. The type signature of the following entities shall not depend on whether __CUDA_ARCH__ is defined or not, or on a particular value of __CUDA_ARCH__:
  • __global__ functions and function templates
  • __device__ and __constant__ variables
  • textures and surfaces
  1. If a __global__ function template is instantiated and launched from the host, then the function template must be instantiated with the same template arguments irrespective of whether __CUDA_ARCH__ is defined and regardless of the value of __CUDA_ARCH__.

I have two questions:

  • Does the second point only apply to __global__ functions? Thus, it is allowed to instantiate __device__ functions with values dependent on __CUDA_ARCH__?

  • Is it allowed to make a __global__ or __device__ function dependent on __CUDA_ARCH__ in an if constexpr clause? E.g. like in the following coda

#ifdef __CUDA_ARCH__
static constexpr bool cudaarch = true;
#else
static constexpr bool cudaarch = false;
#endif

__device__ void func() {
    if constexpr ( cudaarch ) {
         /* code */
    } else {
         /* code */
    }
}