1717# define _NV_COMPILER_NVCC
1818#elif defined(__NVCOMPILER) && __cplusplus >= 201103L
1919# define _NV_COMPILER_NVCXX
20+ #endif
21+
22+ #if defined(__CUDACC_RTC__)
23+ # define _NV_FUNCTION_ANNOTATION __device__
2024#else
25+ # define _NV_FUNCTION_ANNOTATION
2126#endif
2227
2328#if defined(_NV_COMPILER_NVCXX)
@@ -61,6 +66,7 @@ namespace nv {
6166 // Store a set of targets as a set of bits
6267 struct _NV_BITSET_ATTRIBUTE target_description {
6368 base_int_t targets;
69+ _NV_FUNCTION_ANNOTATION
6470 constexpr target_description(base_int_t a) : targets(a) { }
6571 };
6672
@@ -72,9 +78,11 @@ namespace nv {
7278 sm_70 = 70, sm_72 = 72, sm_75 = 75,
7379 sm_80 = 80, sm_86 = 86,
7480 };
81+ _NV_FUNCTION_ANNOTATION
7582 constexpr base_int_t toint(sm_selector a) {
7683 return static_cast<base_int_t>(a);
7784 }
85+ _NV_FUNCTION_ANNOTATION
7886 constexpr base_int_t bitexact(sm_selector a) {
7987 return toint(a) == 35 ? sm_35_bit :
8088 toint(a) == 37 ? sm_37_bit :
@@ -90,6 +98,7 @@ namespace nv {
9098 toint(a) == 80 ? sm_80_bit :
9199 toint(a) == 86 ? sm_86_bit : 0;
92100 }
101+ _NV_FUNCTION_ANNOTATION
93102 constexpr base_int_t bitrounddown(sm_selector a) {
94103 return toint(a) >= 86 ? sm_86_bit :
95104 toint(a) >= 80 ? sm_80_bit :
@@ -108,26 +117,31 @@ namespace nv {
108117
109118 // Public API for NVIDIA GPUs
110119
120+ _NV_FUNCTION_ANNOTATION
111121 constexpr target_description is_exactly(sm_selector a) {
112122 return target_description(bitexact(a));
113123 }
114124
125+ _NV_FUNCTION_ANNOTATION
115126 constexpr target_description provides(sm_selector a) {
116127 return target_description(~(bitrounddown(a) - 1) & all_devices);
117128 }
118129
119130 // Boolean operations on target sets
120131
132+ _NV_FUNCTION_ANNOTATION
121133 constexpr target_description operator&&(target_description a,
122134 target_description b) {
123135 return target_description(a.targets & b.targets);
124136 }
125137
138+ _NV_FUNCTION_ANNOTATION
126139 constexpr target_description operator||(target_description a,
127140 target_description b) {
128141 return target_description(a.targets | b.targets);
129142 }
130143
144+ _NV_FUNCTION_ANNOTATION
131145 constexpr target_description operator!(target_description a) {
132146 return target_description(~a.targets & (all_devices | all_hosts));
133147 }
0 commit comments