[Libclc-dev] [PATCH v2 2/5] add isnormal builtin

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


v2: simplify and remove isnan leftovers
    remove trailing newline

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

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 47b84b5..f04b41a 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -122,6 +122,7 @@
 #include <clc/relational/isless.h>
 #include <clc/relational/islessequal.h>
 #include <clc/relational/isnan.h>
+#include <clc/relational/isnormal.h>
 #include <clc/relational/isnotequal.h>
 #include <clc/relational/select.h>
 #include <clc/relational/signbit.h>
diff --git a/generic/include/clc/relational/isnormal.h b/generic/include/clc/relational/isnormal.h
new file mode 100644
index 0000000..f568c56
--- /dev/null
+++ b/generic/include/clc/relational/isnormal.h
@@ -0,0 +1,9 @@
+#undef isnormal
+
+#define __CLC_FUNCTION isnormal
+#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 22e735a..105d18f 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -57,6 +57,7 @@ relational/isinf.cl
 relational/isless.cl
 relational/islessequal.cl
 relational/isnan.cl
+relational/isnormal.cl
 relational/isnotequal.cl
 relational/signbit.cl
 shared/clamp.cl
diff --git a/generic/lib/relational/isnormal.cl b/generic/lib/relational/isnormal.cl
new file mode 100644
index 0000000..2e6b42d
--- /dev/null
+++ b/generic/lib/relational/isnormal.cl
@@ -0,0 +1,18 @@
+#include <clc/clc.h>
+#include "relational.h"
+
+_CLC_DEFINE_RELATIONAL_UNARY(int, isnormal, __builtin_isnormal, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isnormal(double) returns an int, but the vector versions
+// return long.
+_CLC_DEF _CLC_OVERLOAD int isnormal(double x) {
+  return __builtin_isnormal(x);
+}
+
+_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, isnormal, double)
+
+#endif
-- 
1.9.3





More information about the Libclc-dev mailing list