[Libclc-dev] [PATCH 6/7] relational: Implement isnotequal

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


v2: Use relational macros instead of hand-rolled ones

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

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index fd5c323..c280798 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -113,6 +113,7 @@
 #include <clc/relational/isgreater.h>
 #include <clc/relational/isgreaterequal.h>
 #include <clc/relational/isnan.h>
+#include <clc/relational/isnotequal.h>
 #include <clc/relational/select.h>
 #include <clc/relational/signbit.h>
 
diff --git a/generic/include/clc/relational/isnotequal.h b/generic/include/clc/relational/isnotequal.h
new file mode 100644
index 0000000..f2ceea2
--- /dev/null
+++ b/generic/include/clc/relational/isnotequal.h
@@ -0,0 +1,9 @@
+#undef isnotequal
+
+#define __CLC_FUNCTION isnotequal
+#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 dfe1016..9d678b2 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -44,6 +44,7 @@ relational/isequal.cl
 relational/isgreater.cl
 relational/isgreaterequal.cl
 relational/isnan.cl
+relational/isnotequal.cl
 relational/signbit.cl
 shared/clamp.cl
 shared/max.cl
diff --git a/generic/lib/relational/isnotequal.cl b/generic/lib/relational/isnotequal.cl
new file mode 100644
index 0000000..787fd8d
--- /dev/null
+++ b/generic/lib/relational/isnotequal.cl
@@ -0,0 +1,23 @@
+#include <clc/clc.h>
+#include "relational.h"
+
+#define _CLC_DEFINE_ISNOTEQUAL(RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE) \
+_CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \
+  return (x != y); \
+} \
+
+_CLC_DEFINE_ISNOTEQUAL(int, isnotequal, float, float)
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(int, isnotequal, float, float)
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isnotequal(double, double) returns an int, but the vector versions
+// return long.
+
+_CLC_DEFINE_ISNOTEQUAL(int, isnotequal, double, double)
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, isnotequal, double, double)
+
+#endif
+
+#undef _CLC_DEFINE_ISNOTEQUAL
-- 
1.9.1





More information about the Libclc-dev mailing list