[Libclc-dev] [PATCH v2 4/5] add isunordered builtin
Jan Vesely
jan.vesely at rutgers.edu
Thu Sep 4 12:24:13 PDT 2014
v2: remove trailing newline
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
generic/include/clc/clc.h | 1 +
generic/include/clc/relational/isunordered.h | 9 +++++++++
generic/lib/SOURCES | 1 +
generic/lib/relational/isunordered.cl | 22 ++++++++++++++++++++++
4 files changed, 33 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 d7c32bd..2db23cf 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/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..a6b8e25
--- /dev/null
+++ b/generic/include/clc/relational/isunordered.h
@@ -0,0 +1,9 @@
+#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 add48a4..b894b70 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/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