[libclc] r233713 - Implement fmax using __builtin_fmax
Tom Stellard
thomas.stellard at amd.com
Tue Mar 31 09:59:23 PDT 2015
Author: tstellar
Date: Tue Mar 31 11:59:23 2015
New Revision: 233713
URL: http://llvm.org/viewvc/llvm-project?rev=233713&view=rev
Log:
Implement fmax using __builtin_fmax
This ensures correct handling of NaNi.
This has been tested with piglit, OpenCV, and the ocl conformance tests.
Added:
libclc/trunk/generic/lib/math/fmax.inc
Modified:
libclc/trunk/generic/include/clc/math/fmax.h
libclc/trunk/generic/lib/math/fmax.cl
Modified: libclc/trunk/generic/include/clc/math/fmax.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fmax.h?rev=233713&r1=233712&r2=233713&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/math/fmax.h (original)
+++ libclc/trunk/generic/include/clc/math/fmax.h Tue Mar 31 11:59:23 2015
@@ -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>
Modified: libclc/trunk/generic/lib/math/fmax.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/fmax.cl?rev=233713&r1=233712&r2=233713&view=diff
==============================================================================
--- libclc/trunk/generic/lib/math/fmax.cl (original)
+++ libclc/trunk/generic/lib/math/fmax.cl Tue Mar 31 11:59:23 2015
@@ -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>
Added: libclc/trunk/generic/lib/math/fmax.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/fmax.inc?rev=233713&view=auto
==============================================================================
--- libclc/trunk/generic/lib/math/fmax.inc (added)
+++ libclc/trunk/generic/lib/math/fmax.inc Tue Mar 31 11:59:23 2015
@@ -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)
More information about the cfe-commits
mailing list