[libclc] r213318 - relational: Implement isgreater

Aaron Watry awatry at gmail.com
Thu Jul 17 15:07:22 PDT 2014


Author: awatry
Date: Thu Jul 17 17:07:19 2014
New Revision: 213318

URL: http://llvm.org/viewvc/llvm-project?rev=213318&view=rev
Log:
relational: Implement isgreater

v2: Use relational macros instead of hand-rolled macros

Signed-off-by: Aaron Watry <awatry at gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard at amd.com>

Added:
    libclc/trunk/generic/include/clc/relational/isgreater.h
    libclc/trunk/generic/lib/relational/isgreater.cl
Modified:
    libclc/trunk/generic/include/clc/clc.h
    libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=213318&r1=213317&r2=213318&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jul 17 17:07:19 2014
@@ -110,6 +110,7 @@
 #include <clc/relational/any.h>
 #include <clc/relational/bitselect.h>
 #include <clc/relational/isequal.h>
+#include <clc/relational/isgreater.h>
 #include <clc/relational/isnan.h>
 #include <clc/relational/select.h>
 #include <clc/relational/signbit.h>

Added: libclc/trunk/generic/include/clc/relational/isgreater.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/isgreater.h?rev=213318&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/relational/isgreater.h (added)
+++ libclc/trunk/generic/include/clc/relational/isgreater.h Thu Jul 17 17:07:19 2014
@@ -0,0 +1,9 @@
+#undef isgreater
+
+#define __CLC_FUNCTION isgreater
+#define __CLC_BODY <clc/relational/binary_decl.inc>
+
+#include <clc/relational/floatn.inc>
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=213318&r1=213317&r2=213318&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jul 17 17:07:19 2014
@@ -41,6 +41,7 @@ math/sincos.cl
 relational/all.cl
 relational/any.cl
 relational/isequal.cl
+relational/isgreater.cl
 relational/isnan.cl
 relational/signbit.cl
 shared/clamp.cl

Added: libclc/trunk/generic/lib/relational/isgreater.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/relational/isgreater.cl?rev=213318&view=auto
==============================================================================
--- libclc/trunk/generic/lib/relational/isgreater.cl (added)
+++ libclc/trunk/generic/lib/relational/isgreater.cl Thu Jul 17 17:07:19 2014
@@ -0,0 +1,22 @@
+#include <clc/clc.h>
+#include "relational.h"
+
+//Note: It would be nice to use __builtin_isgreater with vector inputs, but it seems to only take scalar values as
+//      input, which will produce incorrect output for vector input types.
+
+_CLC_DEFINE_RELATIONAL_BINARY(int, isgreater, __builtin_isgreater, float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isgreater(double, double) returns an int, but the vector versions
+// return long.
+
+_CLC_DEF _CLC_OVERLOAD int isgreater(double x, double y){
+	return __builtin_isgreater(x, y);
+}
+
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, isgreater, double, double)
+
+#endif





More information about the cfe-commits mailing list