[Libclc-dev] [PATCH 1/2] relational: Add isless(floatN) builtin

Jan Vesely jan.vesely at rutgers.edu
Thu Jul 31 17:09:38 PDT 2014


Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---

Based on Aaron's isgreater/isgreaterequal.

 generic/include/clc/clc.h               |  1 +
 generic/include/clc/relational/isless.h |  9 +++++++++
 generic/lib/SOURCES                     |  1 +
 generic/lib/relational/isless.cl        | 22 ++++++++++++++++++++++
 4 files changed, 33 insertions(+)
 create mode 100644 generic/include/clc/relational/isless.h
 create mode 100644 generic/lib/relational/isless.cl

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 60b5a6c..83bf8fa 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -115,6 +115,7 @@
 #include <clc/relational/isequal.h>
 #include <clc/relational/isgreater.h>
 #include <clc/relational/isgreaterequal.h>
+#include <clc/relational/isless.h>
 #include <clc/relational/isnan.h>
 #include <clc/relational/isnotequal.h>
 #include <clc/relational/select.h>
diff --git a/generic/include/clc/relational/isless.h b/generic/include/clc/relational/isless.h
new file mode 100644
index 0000000..1954a59
--- /dev/null
+++ b/generic/include/clc/relational/isless.h
@@ -0,0 +1,9 @@
+#undef isless
+
+#define __CLC_FUNCTION isless
+#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 7efe08c..7faba40 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -48,6 +48,7 @@ relational/any.cl
 relational/isequal.cl
 relational/isgreater.cl
 relational/isgreaterequal.cl
+relational/isless.cl
 relational/isnan.cl
 relational/isnotequal.cl
 relational/signbit.cl
diff --git a/generic/lib/relational/isless.cl b/generic/lib/relational/isless.cl
new file mode 100644
index 0000000..56a3e13
--- /dev/null
+++ b/generic/lib/relational/isless.cl
@@ -0,0 +1,22 @@
+#include <clc/clc.h>
+#include "relational.h"
+
+//Note: It would be nice to use __builtin_isless 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, isless, __builtin_isless, float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isless(double, double) returns an int, but the vector versions
+// return long.
+
+_CLC_DEF _CLC_OVERLOAD int isless(double x, double y){
+	return __builtin_isless(x, y);
+}
+
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, isless, double, double)
+
+#endif
-- 
1.9.3





More information about the Libclc-dev mailing list