[Libclc-dev] [PATCH 2/3] relational: Add isequal(floatN) builtin

Aaron Watry awatry at gmail.com
Wed Jun 11 14:59:58 PDT 2014


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

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 0a1503a..167cbfa 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -105,6 +105,7 @@
 #include <clc/relational/all.h>
 #include <clc/relational/any.h>
 #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>
diff --git a/generic/include/clc/relational/isequal.h b/generic/include/clc/relational/isequal.h
new file mode 100644
index 0000000..6f7b3aa
--- /dev/null
+++ b/generic/include/clc/relational/isequal.h
@@ -0,0 +1,18 @@
+
+#define _CLC_ISEQUAL_DECL(TYPE, RETTYPE) \
+  _CLC_OVERLOAD _CLC_DECL RETTYPE isequal(TYPE x, TYPE y);
+
+#define _CLC_VECTOR_ISEQUAL_DECL(TYPE, RETTYPE) \
+  _CLC_ISEQUAL_DECL(TYPE##2, RETTYPE##2)  \
+  _CLC_ISEQUAL_DECL(TYPE##3, RETTYPE##3)  \
+  _CLC_ISEQUAL_DECL(TYPE##4, RETTYPE##4)  \
+  _CLC_ISEQUAL_DECL(TYPE##8, RETTYPE##8)  \
+  _CLC_ISEQUAL_DECL(TYPE##16, RETTYPE##16)
+
+_CLC_ISEQUAL_DECL(float, int)
+_CLC_VECTOR_ISEQUAL_DECL(float, int)
+
+#ifdef cl_khr_fp64
+_CLC_ISEQUAL_DECL(double, int)
+_CLC_VECTOR_ISEQUAL_DECL(double, long)
+#endif
\ No newline at end of file
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 6a8e34d..553a9b9 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -36,6 +36,7 @@ math/nextafter.cl
 math/sincos.cl
 relational/all.cl
 relational/any.cl
+relational/isequal.cl
 relational/isgreater.cl
 relational/isgreaterequal.cl
 relational/isnotequal.cl
diff --git a/generic/lib/relational/isequal.cl b/generic/lib/relational/isequal.cl
new file mode 100644
index 0000000..9d79ba6
--- /dev/null
+++ b/generic/lib/relational/isequal.cl
@@ -0,0 +1,30 @@
+#include <clc/clc.h>
+
+#define _CLC_DEFINE_ISEQUAL(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_ISEQUAL(int, isequal, float, float)
+_CLC_DEFINE_ISEQUAL(int2, isequal, float2, float2)
+_CLC_DEFINE_ISEQUAL(int3, isequal, float3, float3)
+_CLC_DEFINE_ISEQUAL(int4, isequal, float4, float4)
+_CLC_DEFINE_ISEQUAL(int8, isequal, float8, float8)
+_CLC_DEFINE_ISEQUAL(int16, isequal, float16, float16)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isequal(double) returns an int, but the vector versions
+// return long.
+_CLC_DEFINE_ISEQUAL(int, isequal, double, double)
+_CLC_DEFINE_ISEQUAL(long2, isequal, double2, double2)
+_CLC_DEFINE_ISEQUAL(long3, isequal, double3, double3)
+_CLC_DEFINE_ISEQUAL(long4, isequal, double4, double4)
+_CLC_DEFINE_ISEQUAL(long8, isequal, double8, double8)
+_CLC_DEFINE_ISEQUAL(long16, isequal, double16, double16)
+
+#endif
+
+#undef _CLC_DEFINE_ISEQUAL
\ No newline at end of file
-- 
1.9.1





More information about the Libclc-dev mailing list