[Libclc-dev] [PATCH 5/5] add isordered builtin

Jan Vesely jan.vesely at rutgers.edu
Thu Sep 4 12:24:14 PDT 2014


Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
 generic/include/clc/clc.h                  |  1 +
 generic/include/clc/relational/isordered.h |  9 +++++++++
 generic/lib/SOURCES                        |  1 +
 generic/lib/relational/isordered.cl        | 23 +++++++++++++++++++++++
 4 files changed, 34 insertions(+)
 create mode 100644 generic/include/clc/relational/isordered.h
 create mode 100644 generic/lib/relational/isordered.cl

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 2db23cf..0fc8530 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -125,6 +125,7 @@
 #include <clc/relational/isnan.h>
 #include <clc/relational/isnormal.h>
 #include <clc/relational/isnotequal.h>
+#include <clc/relational/isordered.h>
 #include <clc/relational/isunordered.h>
 #include <clc/relational/select.h>
 #include <clc/relational/signbit.h>
diff --git a/generic/include/clc/relational/isordered.h b/generic/include/clc/relational/isordered.h
new file mode 100644
index 0000000..89e9620
--- /dev/null
+++ b/generic/include/clc/relational/isordered.h
@@ -0,0 +1,9 @@
+#undef isordered
+
+#define __CLC_FUNCTION isordered
+#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 b894b70..577671c 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -60,6 +60,7 @@ relational/islessgreater.cl
 relational/isnan.cl
 relational/isnormal.cl
 relational/isnotequal.cl
+relational/isordered.cl
 relational/isunordered.cl
 relational/signbit.cl
 shared/clamp.cl
diff --git a/generic/lib/relational/isordered.cl b/generic/lib/relational/isordered.cl
new file mode 100644
index 0000000..ebda2eb
--- /dev/null
+++ b/generic/lib/relational/isordered.cl
@@ -0,0 +1,23 @@
+#include <clc/clc.h>
+#include "relational.h"
+
+#define _CLC_DEFINE_ISORDERED(RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE) \
+_CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \
+  return isequal(x, x) && isequal(y, y); \
+} \
+
+_CLC_DEFINE_ISORDERED(int, isordered, float, float)
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(int, isordered, float, float)
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isordered(double, double) returns an int, but the vector versions
+// return long.
+
+_CLC_DEFINE_ISORDERED(int, isordered, double, double)
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, isordered, double, double)
+
+#endif
+
+#undef _CLC_DEFINE_ISORDERED
-- 
1.9.3





More information about the Libclc-dev mailing list