[libclc] 96/291: Implement sign() builtin
Andreas Beckmann
anbe at moszumanska.debian.org
Tue Sep 8 10:53:37 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 c002f62bf03f093521c52e2816e4881afc49ef40
Author: Tom Stellard <thomas.stellard at amd.com>
Date: Thu Oct 10 19:08:56 2013 +0000
Implement sign() builtin
git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@192384 91177308-0d34-0410-b5e6-96231b3b80d8
---
generic/include/clc/clc.h | 3 +++
generic/include/clc/common/sign.h | 5 +++++
generic/lib/SOURCES | 1 +
generic/lib/common/sign.cl | 27 +++++++++++++++++++++++++++
4 files changed, 36 insertions(+)
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 0e87ec7..7846ff7 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -86,6 +86,9 @@
#include <clc/shared/vload.h>
#include <clc/shared/vstore.h>
+/* 6.11.4 Common Functions */
+#include <clc/common/sign.h>
+
/* 6.11.5 Geometric Functions */
#include <clc/geometric/cross.h>
#include <clc/geometric/dot.h>
diff --git a/generic/include/clc/common/sign.h b/generic/include/clc/common/sign.h
new file mode 100644
index 0000000..fa9aa09
--- /dev/null
+++ b/generic/include/clc/common/sign.h
@@ -0,0 +1,5 @@
+#define __CLC_FUNCTION sign
+#define __CLC_BODY <clc/math/unary_decl.inc>
+#include <clc/math/gentype.inc>
+#undef __CLC_FUNCTION
+#undef __CLC_BODY
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index e1a2972..35b0739 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -1,5 +1,6 @@
atomic/atomic_impl.ll
convert.cl
+common/sign.cl
geometric/cross.cl
geometric/dot.cl
geometric/length.cl
diff --git a/generic/lib/common/sign.cl b/generic/lib/common/sign.cl
new file mode 100644
index 0000000..070abd5
--- /dev/null
+++ b/generic/lib/common/sign.cl
@@ -0,0 +1,27 @@
+#include <clc/clc.h>
+
+#define SIGN(TYPE, F) \
+_CLC_DEF _CLC_OVERLOAD TYPE sign(TYPE x) { \
+ if (isnan(x)) { \
+ return 0.0F; \
+ } \
+ if (x > 0.0F) { \
+ return 1.0F; \
+ } \
+ if (x < 0.0F) { \
+ return -1.0F; \
+ } \
+ return x; /* -0.0 or +0.0 */ \
+}
+
+SIGN(float, f)
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, sign, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+SIGN(double, )
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, sign, double)
+
+#endif
--
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