[libclc] 243/291: Implement fmax using __builtin_fmax

Andreas Beckmann anbe at moszumanska.debian.org
Tue Sep 8 10:53:55 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 b00c16bce6a2849b50679a39ec4c74ff151fad1e
Author: Tom Stellard <thomas.stellard at amd.com>
Date:   Tue Mar 31 16:59:23 2015 +0000

    Implement fmax using __builtin_fmax
    
    This ensures correct handling of NaNi.
    
    This has been tested with piglit, OpenCV, and the ocl conformance tests.
    
    git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@233713 91177308-0d34-0410-b5e6-96231b3b80d8
---
 generic/include/clc/math/fmax.h |  5 +----
 generic/lib/math/fmax.cl        | 13 +++++++++----
 generic/lib/math/fmax.inc       | 18 ++++++++++++++++++
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/generic/include/clc/math/fmax.h b/generic/include/clc/math/fmax.h
index d6956af..71ee859 100644
--- a/generic/include/clc/math/fmax.h
+++ b/generic/include/clc/math/fmax.h
@@ -1,8 +1,5 @@
-#undef fmax
-#define fmax __clc_fmax
-
 #define __CLC_BODY <clc/math/binary_decl.inc>
-#define __CLC_FUNCTION __clc_fmax
+#define __CLC_FUNCTION fmax
 
 #include <clc/math/gentype.inc>
 
diff --git a/generic/lib/math/fmax.cl b/generic/lib/math/fmax.cl
index 58583d6..239da3d 100644
--- a/generic/lib/math/fmax.cl
+++ b/generic/lib/math/fmax.cl
@@ -1,11 +1,16 @@
 #include <clc/clc.h>
 
+#include "../clcmacro.h"
+
+_CLC_DEFINE_BINARY_BUILTIN(float, fmax, __builtin_fmaxf, float, float);
+
 #ifdef cl_khr_fp64
+
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
-#endif
 
-#define FUNCTION __clc_fmax
-#define FUNCTION_IMPL(x, y) ((x) < (y) ? (y) : (x))
+_CLC_DEFINE_BINARY_BUILTIN(double, fmax, __builtin_fmax, double, double);
+
+#endif
 
-#define __CLC_BODY <binary_impl.inc>
+#define __CLC_BODY <fmax.inc>
 #include <clc/math/gentype.inc>
diff --git a/generic/lib/math/fmax.inc b/generic/lib/math/fmax.inc
new file mode 100644
index 0000000..8315c5f
--- /dev/null
+++ b/generic/lib/math/fmax.inc
@@ -0,0 +1,18 @@
+
+#if !defined(__CLC_SCALAR)
+
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmax(__CLC_GENTYPE x, float y) {
+  return fmax(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y));
+}
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmax(__CLC_GENTYPE x, double y) {
+  return fmax(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y));
+}
+
+#endif // ifdef cl_khr_fp64
+
+#endif // !defined(__CLC_SCALAR)

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