[libclc] 11/79: math: Use precomputed constant for log2(10.0)
Andreas Boll
aboll-guest at moszumanska.debian.org
Mon Mar 19 16:50:55 UTC 2018
This is an automated email from the git hooks/post-receive script.
aboll-guest pushed a commit to branch master
in repository libclc.
commit d66c58061c51054ccb09cc8b7c9de53a9da295f9
Author: Jan Vesely <jan.vesely at rutgers.edu>
Date: Mon Nov 13 18:28:45 2017 +0000
math: Use precomputed constant for log2(10.0)
exp10 CTS fails with or without this change
Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@318063 91177308-0d34-0410-b5e6-96231b3b80d8
---
generic/include/clc/float/definitions.h | 8 ++++++++
generic/lib/math/exp10.inc | 4 ++--
generic/lib/math/native_exp10.inc | 2 +-
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/generic/include/clc/float/definitions.h b/generic/include/clc/float/definitions.h
index 6010ed2..84a102e 100644
--- a/generic/include/clc/float/definitions.h
+++ b/generic/include/clc/float/definitions.h
@@ -31,6 +31,10 @@
#define M_SQRT2_F 0x1.6a09e6p+0f
#define M_SQRT1_2_F 0x1.6a09e6p-1f
+#ifdef __CLC_INTERNAL
+#define M_LOG210_F 0x1.a934f0p+1f
+#endif
+
#ifdef cl_khr_fp64
#define HUGE_VAL __builtin_huge_val()
@@ -59,6 +63,10 @@
#define M_SQRT2 0x1.6a09e667f3bcdp+0
#define M_SQRT1_2 0x1.6a09e667f3bcdp-1
+#ifdef __CLC_INTERNAL
+#define M_LOG210 0x1.a934f0979a371p+1
+#endif
+
#endif
#ifdef cl_khr_fp16
diff --git a/generic/lib/math/exp10.inc b/generic/lib/math/exp10.inc
index a592c19..f5482e4 100644
--- a/generic/lib/math/exp10.inc
+++ b/generic/lib/math/exp10.inc
@@ -1,9 +1,9 @@
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE exp10(__CLC_GENTYPE val) {
// exp10(x) = exp2(x * log2(10))
#if __CLC_FPSIZE == 32
- return exp2(val * log2(10.0f));
+ return exp2(val * M_LOG210_F);
#elif __CLC_FPSIZE == 64
- return exp2(val * log2(10.0));
+ return exp2(val * M_LOG210);
#else
#error unknown _CLC_FPSIZE
#endif
diff --git a/generic/lib/math/native_exp10.inc b/generic/lib/math/native_exp10.inc
index b82a650..9826b4e 100644
--- a/generic/lib/math/native_exp10.inc
+++ b/generic/lib/math/native_exp10.inc
@@ -1,3 +1,3 @@
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_exp10(__CLC_GENTYPE val) {
- return native_exp2(val * native_log2(10));
+ return native_exp2(val * M_LOG210_F);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/libclc.git
More information about the Pkg-opencl-commits
mailing list