[Libclc-dev] [PATCH 5/7] relational: Implement isgreaterequal

Aaron Watry awatry at gmail.com
Tue Jul 15 15:24:49 PDT 2014


v2: Use relational macros instead of hand-rolled macros

Signed-off-by: Aaron Watry <awatry at gmail.com>
---
 generic/include/clc/clc.h                       |  1 +
 generic/include/clc/relational/isgreaterequal.h |  9 +++++++++
 generic/lib/SOURCES                             |  1 +
 generic/lib/relational/isgreaterequal.cl        | 22 ++++++++++++++++++++++
 4 files changed, 33 insertions(+)
 create mode 100644 generic/include/clc/relational/isgreaterequal.h
 create mode 100644 generic/lib/relational/isgreaterequal.cl

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 34123d9..fd5c323 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -111,6 +111,7 @@
 #include <clc/relational/bitselect.h>
 #include <clc/relational/isequal.h>
 #include <clc/relational/isgreater.h>
+#include <clc/relational/isgreaterequal.h>
 #include <clc/relational/isnan.h>
 #include <clc/relational/select.h>
 #include <clc/relational/signbit.h>
diff --git a/generic/include/clc/relational/isgreaterequal.h b/generic/include/clc/relational/isgreaterequal.h
new file mode 100644
index 0000000..8353328
--- /dev/null
+++ b/generic/include/clc/relational/isgreaterequal.h
@@ -0,0 +1,9 @@
+#undef isgreaterequal
+
+#define __CLC_FUNCTION isgreaterequal
+#define __CLC_BODY <clc/relational/binary_decl.inc>
+
+#include <clc/relational/floatn.inc>
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 671fff2..dfe1016 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -42,6 +42,7 @@ relational/all.cl
 relational/any.cl
 relational/isequal.cl
 relational/isgreater.cl
+relational/isgreaterequal.cl
 relational/isnan.cl
 relational/signbit.cl
 shared/clamp.cl
diff --git a/generic/lib/relational/isgreaterequal.cl b/generic/lib/relational/isgreaterequal.cl
new file mode 100644
index 0000000..2d5ebe5
--- /dev/null
+++ b/generic/lib/relational/isgreaterequal.cl
@@ -0,0 +1,22 @@
+#include <clc/clc.h>
+#include "relational.h"
+
+//Note: It would be nice to use __builtin_isgreaterequal 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, isgreaterequal, __builtin_isgreaterequal, float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isgreaterequal(double, double) returns an int, but the vector versions
+// return long.
+
+_CLC_DEF _CLC_OVERLOAD int isgreaterequal(double x, double y){
+	return __builtin_isgreaterequal(x, y);
+}
+
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, isgreaterequal, double, double)
+
+#endif
-- 
1.9.1





More information about the Libclc-dev mailing list