[libclc] 192/291: math: Add asin implementation

Andreas Beckmann anbe at moszumanska.debian.org
Tue Sep 8 10:53:48 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 8aa236d7057925d66b44c1fe5f5bfea60dc86698
Author: Aaron Watry <awatry at gmail.com>
Date:   Wed Sep 10 15:43:32 2014 +0000

    math: Add asin implementation
    
    asin(x) = atan2(x, sqrt( 1-x^2 ))
    
    alternatively:
    asin(x) = PI/2 - acos(x)
    
    Use the atan2 implementation since it produces slightly shorter bitcode and
    R600 machine code.
    
    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@217510 91177308-0d34-0410-b5e6-96231b3b80d8
---
 generic/include/clc/clc.h         | 1 +
 generic/include/clc/math/asin.h   | 2 ++
 generic/include/clc/math/asin.inc | 1 +
 generic/lib/SOURCES               | 1 +
 generic/lib/math/asin.cl          | 8 ++++++++
 generic/lib/math/asin.inc         | 3 +++
 6 files changed, 16 insertions(+)

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 0fc8530..d0c6e72 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -33,6 +33,7 @@
 
 /* 6.11.2 Math Functions */
 #include <clc/math/acos.h>
+#include <clc/math/asin.h>
 #include <clc/math/atan.h>
 #include <clc/math/atan2.h>
 #include <clc/math/copysign.h>
diff --git a/generic/include/clc/math/asin.h b/generic/include/clc/math/asin.h
new file mode 100644
index 0000000..2a85872
--- /dev/null
+++ b/generic/include/clc/math/asin.h
@@ -0,0 +1,2 @@
+#define __CLC_BODY <clc/math/asin.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/include/clc/math/asin.inc b/generic/include/clc/math/asin.inc
new file mode 100644
index 0000000..b4ad8ff
--- /dev/null
+++ b/generic/include/clc/math/asin.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE asin(__CLC_GENTYPE x);
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 577671c..385f22b 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -30,6 +30,7 @@ integer/sub_sat_if.ll
 integer/sub_sat_impl.ll
 integer/upsample.cl
 math/acos.cl
+math/asin.cl
 math/atan.cl
 math/atan2.cl
 math/copysign.cl
diff --git a/generic/lib/math/asin.cl b/generic/lib/math/asin.cl
new file mode 100644
index 0000000..d56dbd7
--- /dev/null
+++ b/generic/lib/math/asin.cl
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define __CLC_BODY <asin.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/lib/math/asin.inc b/generic/lib/math/asin.inc
new file mode 100644
index 0000000..a109c36
--- /dev/null
+++ b/generic/lib/math/asin.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE asin(__CLC_GENTYPE x) {
+  return atan2(x, sqrt( (__CLC_GENTYPE)1.0 -(x*x) ));
+}
\ No newline at end of file

-- 
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