[Libclc-dev] [PATCH v2 3/5] add islessgreater builtin
Jan Vesely
jan.vesely at rutgers.edu
Thu Sep 4 12:24:12 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/islessgreater.h | 7 +++++++
generic/lib/SOURCES | 1 +
generic/lib/relational/islessgreater.cl | 22 ++++++++++++++++++++++
4 files changed, 31 insertions(+)
create mode 100644 generic/include/clc/relational/islessgreater.h
create mode 100644 generic/lib/relational/islessgreater.cl
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index f04b41a..d7c32bd 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -121,6 +121,7 @@
#include <clc/relational/isinf.h>
#include <clc/relational/isless.h>
#include <clc/relational/islessequal.h>
+#include <clc/relational/islessgreater.h>
#include <clc/relational/isnan.h>
#include <clc/relational/isnormal.h>
#include <clc/relational/isnotequal.h>
diff --git a/generic/include/clc/relational/islessgreater.h b/generic/include/clc/relational/islessgreater.h
new file mode 100644
index 0000000..005ba10
--- /dev/null
+++ b/generic/include/clc/relational/islessgreater.h
@@ -0,0 +1,7 @@
+#define __CLC_FUNCTION islessgreater
+#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 105d18f..add48a4 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -56,6 +56,7 @@ relational/isgreaterequal.cl
relational/isinf.cl
relational/isless.cl
relational/islessequal.cl
+relational/islessgreater.cl
relational/isnan.cl
relational/isnormal.cl
relational/isnotequal.cl
diff --git a/generic/lib/relational/islessgreater.cl b/generic/lib/relational/islessgreater.cl
new file mode 100644
index 0000000..fc029f3
--- /dev/null
+++ b/generic/lib/relational/islessgreater.cl
@@ -0,0 +1,22 @@
+#include <clc/clc.h>
+#include "relational.h"
+
+//Note: It would be nice to use __builtin_islessgreater 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, islessgreater, __builtin_islessgreater, float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of islessgreater(double, double) returns an int, but the vector versions
+// return long.
+
+_CLC_DEF _CLC_OVERLOAD int islessgreater(double x, double y){
+ return __builtin_islessgreater(x, y);
+}
+
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, islessgreater, double, double)
+
+#endif
--
1.9.3
More information about the Libclc-dev
mailing list