File tree Expand file tree Collapse file tree 1 file changed +11
-18
lines changed
libclc/ptx-nvidiacl/libspirv/math Expand file tree Collapse file tree 1 file changed +11
-18
lines changed Original file line number Diff line number Diff line change 19
19
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
20
20
21
21
int __clc_nvvm_reflect_arch ();
22
+ #define __USE_HALF_EXP2_APPROX (__clc_nvvm_reflect_arch() >= 750)
22
23
23
24
_CLC_DEF _CLC_OVERLOAD half __clc_native_exp2 (half x ) {
24
- if (__clc_nvvm_reflect_arch () >= 750 ) {
25
- return __nvvm_ex2_approx_f16 (x );
26
- } else {
27
- float upcast = x ;
28
- return __spirv_ocl_native_exp2 (upcast );
29
- }
25
+ return (__USE_HALF_EXP2_APPROX ) ? __nvvm_ex2_approx_f16 (x )
26
+ : __spirv_ocl_native_exp2 ((float )x );
30
27
}
31
28
32
29
_CLC_DEF _CLC_OVERLOAD half2 __clc_native_exp2 (half2 x ) {
33
- if (__clc_nvvm_reflect_arch () >= 750 ) {
34
- return __nvvm_ex2_approx_f16x2 (x );
35
- } else {
36
- float upcast0 = x [0 ];
37
- float upcast1 = x [1 ];
38
- half2 res ;
39
- res .s0 = __spirv_ocl_native_exp2 (upcast0 );
40
- res .s1 = __spirv_ocl_native_exp2 (upcast1 );
41
- return res ;
42
- }
30
+ return (__USE_HALF_EXP2_APPROX )
31
+ ? __nvvm_ex2_approx_f16x2 (x )
32
+ : (half2 )(__spirv_ocl_native_exp2 ((float )x .x ),
33
+ __spirv_ocl_native_exp2 ((float )x .y ));
43
34
}
44
35
45
- _CLC_UNARY_VECTORIZE_HAVE2 (_CLC_OVERLOAD _CLC_DEF , half ,
46
- __clc_native_exp2 , half )
36
+ _CLC_UNARY_VECTORIZE_HAVE2 (_CLC_OVERLOAD _CLC_DEF , half , __clc_native_exp2 ,
37
+ half )
38
+
39
+ #undef __USE_HALF_EXP2_APPROX
47
40
48
41
#endif // cl_khr_fp16
49
42
You can’t perform that action at this time.
0 commit comments