[Libclc-dev] [PATCH 4/5] add isunordered builtin

Jan Vesely jan.vesely at rutgers.edu
Thu Sep 4 08:50:13 PDT 2014


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

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index d868c5e..6fcf344 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -124,6 +124,7 @@
 #include <clc/relational/isnan.h>
 #include <clc/relational/isnormal.h>
 #include <clc/relational/isnotequal.h>
+#include <clc/relational/isunordered.h>
 #include <clc/relational/select.h>
 #include <clc/relational/signbit.h>
 
diff --git a/generic/include/clc/relational/isunordered.h b/generic/include/clc/relational/isunordered.h
new file mode 100644
index 0000000..f0957c0
--- /dev/null
+++ b/generic/include/clc/relational/isunordered.h
@@ -0,0 +1,10 @@
+#undef isunordered
+
+#define __CLC_FUNCTION isunordered
+#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 3ece265..04c50d4 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -59,6 +59,7 @@ relational/islessgreater.cl
 relational/isnan.cl
 relational/isnormal.cl
 relational/isnotequal.cl
+relational/isunordered.cl
 relational/signbit.cl
 shared/clamp.cl
 shared/max.cl
diff --git a/generic/lib/relational/isunordered.cl b/generic/lib/relational/isunordered.cl
new file mode 100644
index 0000000..8bc5e3f
--- /dev/null
+++ b/generic/lib/relational/isunordered.cl
@@ -0,0 +1,22 @@
+#include <clc/clc.h>
+#include "relational.h"
+
+//Note: It would be nice to use __builtin_isunordered 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, isunordered, __builtin_isunordered, float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isunordered(double, double) returns an int, but the vector versions
+// return long.
+
+_CLC_DEF _CLC_OVERLOAD int isunordered(double x, double y){
+	return __builtin_isunordered(x, y);
+}
+
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, isunordered, double, double)
+
+#endif
-- 
1.9.3





More information about the Libclc-dev mailing list