[libclc] 49/291: libclc: Add clamp() builtin for integer/floating point

Andreas Beckmann anbe at moszumanska.debian.org
Tue Sep 8 10:53:32 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 213e719bf2c298d99efda128d87c80f0cc737aa9
Author: Tom Stellard <thomas.stellard at amd.com>
Date:   Wed Jun 26 18:20:56 2013 +0000

    libclc: Add clamp() builtin for integer/floating point
    
    Created under a new shared/ directory for functions which are available for
    both integer and floating point types.
    
    Patch by: Aaron Watry
    
    git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@184994 91177308-0d34-0410-b5e6-96231b3b80d8
---
 generic/include/clc/clc.h            |  3 +++
 generic/include/clc/shared/clamp.h   |  5 +++++
 generic/include/clc/shared/clamp.inc |  1 +
 generic/lib/SOURCES                  |  1 +
 generic/lib/shared/clamp.cl          | 11 +++++++++++
 generic/lib/shared/clamp.inc         |  3 +++
 6 files changed, 24 insertions(+)

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index f6668a3..80ecd01 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -67,6 +67,9 @@
 #include <clc/integer/max.h>
 #include <clc/integer/sub_sat.h>
 
+/* 6.11.2 and 6.11.3 Shared Integer/Math Functions */
+#include <clc/shared/clamp.h>
+
 /* 6.11.5 Geometric Functions */
 #include <clc/geometric/cross.h>
 #include <clc/geometric/dot.h>
diff --git a/generic/include/clc/shared/clamp.h b/generic/include/clc/shared/clamp.h
new file mode 100644
index 0000000..5c2ebd0
--- /dev/null
+++ b/generic/include/clc/shared/clamp.h
@@ -0,0 +1,5 @@
+#define BODY <clc/shared/clamp.inc>
+#include <clc/integer/gentype.inc>
+
+#define BODY <clc/shared/clamp.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/include/clc/shared/clamp.inc b/generic/include/clc/shared/clamp.inc
new file mode 100644
index 0000000..3e3a435
--- /dev/null
+++ b/generic/include/clc/shared/clamp.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z);
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index a97213b..0d477ba 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -18,5 +18,6 @@ math/hypot.cl
 math/mad.cl
 math/max.cl
 relational/any.cl
+shared/clamp.cl
 workitem/get_global_id.cl
 workitem/get_global_size.cl
diff --git a/generic/lib/shared/clamp.cl b/generic/lib/shared/clamp.cl
new file mode 100644
index 0000000..0e8d223
--- /dev/null
+++ b/generic/lib/shared/clamp.cl
@@ -0,0 +1,11 @@
+#include <clc/clc.h>
+
+#define BODY <clamp.inc>
+#include <clc/integer/gentype.inc>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define BODY <clamp.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/lib/shared/clamp.inc b/generic/lib/shared/clamp.inc
new file mode 100644
index 0000000..ed49b8e
--- /dev/null
+++ b/generic/lib/shared/clamp.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z) {
+  return (x > z ? z : (x < y ? y : x));
+}

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