[Libclc-dev] [PATCH v2 1/5] add isfinite builtin

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


v2: simplify and remove isinf leftovers
    remove trailing newline

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

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 490893b..47b84b5 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -115,6 +115,7 @@
 #include <clc/relational/any.h>
 #include <clc/relational/bitselect.h>
 #include <clc/relational/isequal.h>
+#include <clc/relational/isfinite.h>
 #include <clc/relational/isgreater.h>
 #include <clc/relational/isgreaterequal.h>
 #include <clc/relational/isinf.h>
diff --git a/generic/include/clc/relational/isfinite.h b/generic/include/clc/relational/isfinite.h
new file mode 100644
index 0000000..48e261a
--- /dev/null
+++ b/generic/include/clc/relational/isfinite.h
@@ -0,0 +1,9 @@
+#undef isfinite
+
+#define __CLC_FUNCTION isfinite
+#define __CLC_BODY <clc/relational/unary_decl.inc>
+
+#include <clc/relational/floatn.inc>
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 8eaaa61..22e735a 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -50,6 +50,7 @@ math/sincos_helpers.cl
 relational/all.cl
 relational/any.cl
 relational/isequal.cl
+relational/isfinite.cl
 relational/isgreater.cl
 relational/isgreaterequal.cl
 relational/isinf.cl
diff --git a/generic/lib/relational/isfinite.cl b/generic/lib/relational/isfinite.cl
new file mode 100644
index 0000000..d0658c0
--- /dev/null
+++ b/generic/lib/relational/isfinite.cl
@@ -0,0 +1,18 @@
+#include <clc/clc.h>
+#include "relational.h"
+
+_CLC_DEFINE_RELATIONAL_UNARY(int, isfinite, __builtin_isfinite, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isfinite(double) returns an int, but the vector versions
+// return long.
+_CLC_DEF _CLC_OVERLOAD int isfinite(double x) {
+  return __builtin_isfinite(x);
+}
+
+_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, isfinite, double)
+
+#endif
-- 
1.9.3




More information about the Libclc-dev mailing list