[libclc] 13/291: Add fma, hypot builtins.

Andreas Beckmann anbe at moszumanska.debian.org
Tue Sep 8 10:53:27 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 0d9bead544e7bd9b7312989dffe9e73c95810542
Author: Peter Collingbourne <peter at pcc.me.uk>
Date:   Tue May 29 13:35:28 2012 +0000

    Add fma, hypot builtins.
    
    git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@157613 91177308-0d34-0410-b5e6-96231b3b80d8
---
 generic/include/clc/clc.h                   |  2 ++
 generic/include/clc/math/fma.h              |  6 ++++++
 generic/include/clc/math/hypot.h            |  2 ++
 generic/include/clc/math/hypot.inc          |  1 +
 generic/include/clc/math/ternary_intrin.inc | 18 ++++++++++++++++++
 generic/lib/SOURCES                         |  1 +
 generic/lib/math/hypot.cl                   |  8 ++++++++
 generic/lib/math/hypot.inc                  |  3 +++
 8 files changed, 41 insertions(+)

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 3b78d29..65e4090 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -36,6 +36,8 @@
 #include <clc/math/exp.h>
 #include <clc/math/exp2.h>
 #include <clc/math/fabs.h>
+#include <clc/math/fma.h>
+#include <clc/math/hypot.h>
 #include <clc/math/log.h>
 #include <clc/math/log2.h>
 #include <clc/math/mad.h>
diff --git a/generic/include/clc/math/fma.h b/generic/include/clc/math/fma.h
new file mode 100644
index 0000000..8d862fa
--- /dev/null
+++ b/generic/include/clc/math/fma.h
@@ -0,0 +1,6 @@
+#undef fma
+#define fma __clc_fma
+
+#define FUNCTION __clc_fma
+#define INTRINSIC "llvm.fma"
+#include <clc/math/ternary_intrin.inc>
diff --git a/generic/include/clc/math/hypot.h b/generic/include/clc/math/hypot.h
new file mode 100644
index 0000000..9ffda48
--- /dev/null
+++ b/generic/include/clc/math/hypot.h
@@ -0,0 +1,2 @@
+#define BODY <clc/math/hypot.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/include/clc/math/hypot.inc b/generic/include/clc/math/hypot.inc
new file mode 100644
index 0000000..2f97ee5
--- /dev/null
+++ b/generic/include/clc/math/hypot.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE hypot(GENTYPE x, GENTYPE y);
diff --git a/generic/include/clc/math/ternary_intrin.inc b/generic/include/clc/math/ternary_intrin.inc
new file mode 100644
index 0000000..7d451e9
--- /dev/null
+++ b/generic/include/clc/math/ternary_intrin.inc
@@ -0,0 +1,18 @@
+_CLC_OVERLOAD float FUNCTION(float, float, float) __asm(INTRINSIC ".f32");
+_CLC_OVERLOAD float2 FUNCTION(float2, float2, float2) __asm(INTRINSIC ".v2f32");
+_CLC_OVERLOAD float3 FUNCTION(float3, float3, float3) __asm(INTRINSIC ".v3f32");
+_CLC_OVERLOAD float4 FUNCTION(float4, float4, float4) __asm(INTRINSIC ".v4f32");
+_CLC_OVERLOAD float8 FUNCTION(float8, float8, float8) __asm(INTRINSIC ".v8f32");
+_CLC_OVERLOAD float16 FUNCTION(float16, float16, float16) __asm(INTRINSIC ".v16f32");
+
+#ifdef cl_khr_fp64
+_CLC_OVERLOAD double FUNCTION(double, double, double) __asm(INTRINSIC ".f64");
+_CLC_OVERLOAD double2 FUNCTION(double2, double2, double2) __asm(INTRINSIC ".v2f64");
+_CLC_OVERLOAD double3 FUNCTION(double3, double3, double3) __asm(INTRINSIC ".v3f64");
+_CLC_OVERLOAD double4 FUNCTION(double4, double4, double4) __asm(INTRINSIC ".v4f64");
+_CLC_OVERLOAD double8 FUNCTION(double8, double8, double8) __asm(INTRINSIC ".v8f64");
+_CLC_OVERLOAD double16 FUNCTION(double16, double16, double16) __asm(INTRINSIC ".v16f64");
+#endif
+
+#undef FUNCTION
+#undef INTRINSIC
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 1da1c91..0608116 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -7,4 +7,5 @@ integer/abs.cl
 integer/add_sat.cl
 integer/add_sat.ll
 integer/add_sat_impl.ll
+math/hypot.cl
 math/mad.cl
diff --git a/generic/lib/math/hypot.cl b/generic/lib/math/hypot.cl
new file mode 100644
index 0000000..dcdc1ed
--- /dev/null
+++ b/generic/lib/math/hypot.cl
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define BODY <hypot.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/lib/math/hypot.inc b/generic/lib/math/hypot.inc
new file mode 100644
index 0000000..3f529c8
--- /dev/null
+++ b/generic/lib/math/hypot.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE hypot(GENTYPE x, GENTYPE y) {
+  return sqrt(x*x + y*y);
+}

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