[libclc] 193/291: math: Add tan implementation
Andreas Beckmann
anbe at moszumanska.debian.org
Tue Sep 8 10:53:49 UTC 2015
This is an automated email from the git hooks/post-receive script.
anbe pushed a commit to branch master
in repository libclc.
commit bdf923449400fc7e2a7de383650698a3fb9bfd89
Author: Aaron Watry <awatry at gmail.com>
Date: Wed Sep 10 15:43:35 2014 +0000
math: Add tan implementation
Uses the algorithm:
tan(x) = sin(x) / sqrt(1-sin^2(x))
An alternative is:
tan(x) = sin(x) / cos(x)
Which produces more verbose bitcode and longer assembly.
Either way, the generated bitcode seems pretty nasty and a more optimized
but still precise-enough solution is welcome.
Signed-off-by: Aaron Watry <awatry at gmail.com>
Reviewed-by: Jan Vesely <jan.vesely at rutgers.edu>
git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@217511 91177308-0d34-0410-b5e6-96231b3b80d8
---
generic/include/clc/clc.h | 1 +
generic/include/clc/math/tan.h | 2 ++
generic/include/clc/math/tan.inc | 1 +
generic/lib/SOURCES | 1 +
generic/lib/math/tan.cl | 8 ++++++++
generic/lib/math/tan.inc | 8 ++++++++
6 files changed, 21 insertions(+)
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index d0c6e72..b8c1cb9 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -60,6 +60,7 @@
#include <clc/math/sin.h>
#include <clc/math/sincos.h>
#include <clc/math/sqrt.h>
+#include <clc/math/tan.h>
#include <clc/math/trunc.h>
#include <clc/math/native_cos.h>
#include <clc/math/native_divide.h>
diff --git a/generic/include/clc/math/tan.h b/generic/include/clc/math/tan.h
new file mode 100644
index 0000000..d2d52a9
--- /dev/null
+++ b/generic/include/clc/math/tan.h
@@ -0,0 +1,2 @@
+#define __CLC_BODY <clc/math/tan.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/include/clc/math/tan.inc b/generic/include/clc/math/tan.inc
new file mode 100644
index 0000000..50c5b1d
--- /dev/null
+++ b/generic/include/clc/math/tan.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE tan(__CLC_GENTYPE x);
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 385f22b..e4ba1d1 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -48,6 +48,7 @@ math/pown.cl
math/sin.cl
math/sincos.cl
math/sincos_helpers.cl
+math/tan.cl
relational/all.cl
relational/any.cl
relational/isequal.cl
diff --git a/generic/lib/math/tan.cl b/generic/lib/math/tan.cl
new file mode 100644
index 0000000..a447999
--- /dev/null
+++ b/generic/lib/math/tan.cl
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define __CLC_BODY <tan.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/lib/math/tan.inc b/generic/lib/math/tan.inc
new file mode 100644
index 0000000..8d9d9fe
--- /dev/null
+++ b/generic/lib/math/tan.inc
@@ -0,0 +1,8 @@
+/*
+ * Note: tan(x) = sin(x)/cos(x) also, but the final assembly ends up being
+ * twice as long for R600 (maybe for others as well).
+ */
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE tan(__CLC_GENTYPE x) {
+ __CLC_GENTYPE sinx = sin(x);
+ return sinx / sqrt( (__CLC_GENTYPE) 1.0 - (sinx*sinx) );
+}
--
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