[Libclc-dev] [PATCH 2/6] maxmag: Condition variable needs to be the same bitwidth as operands
Jan Vesely via Libclc-dev
libclc-dev at lists.llvm.org
Wed Feb 28 11:50:14 PST 2018
No changes wrt CTS
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
generic/lib/math/maxmag.cl | 1 +
generic/lib/math/maxmag.inc | 22 ++++++++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/generic/lib/math/maxmag.cl b/generic/lib/math/maxmag.cl
index db23fc0..7b5902d 100644
--- a/generic/lib/math/maxmag.cl
+++ b/generic/lib/math/maxmag.cl
@@ -1,4 +1,5 @@
#include <clc/clc.h>
+#include <utils.h>
#define __CLC_BODY <maxmag.inc>
#include <clc/math/gentype.inc>
diff --git a/generic/lib/math/maxmag.inc b/generic/lib/math/maxmag.inc
index 88b0129..226316a 100644
--- a/generic/lib/math/maxmag.inc
+++ b/generic/lib/math/maxmag.inc
@@ -1,4 +1,22 @@
+#ifdef __CLC_SCALAR
+#define __CLC_VECSIZE
+#endif
+
+#if __CLC_FPSIZE == 64
+#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_long, __CLC_VECSIZE)
+#elif __CLC_FPSIZE == 32
+#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_int, __CLC_VECSIZE)
+#elif __CLC_FPSIZE == 16
+#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_short, __CLC_VECSIZE)
+#endif
+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE maxmag(__CLC_GENTYPE x, __CLC_GENTYPE y) {
- const __CLC_GENTYPE res = select(y, x, isgreater(fabs(x), fabs(y)));
- return select(res, fmax(x, y), isnan(x) | isnan(y) | isequal(fabs(x), fabs(y)));
+ const __CLC_GENTYPE res = select(y, x, __CLC_CONVERT_NATN(isgreater(fabs(x), fabs(y))));
+ return select(res, fmax(x, y), __CLC_CONVERT_NATN(isnan(x) | isnan(y) | isequal(fabs(x), fabs(y))));
}
+
+#undef __CLC_CONVERT_NATN
+
+#ifdef __CLC_SCALAR
+#undef __CLC_VECSIZE
+#endif
--
2.14.3
More information about the Libclc-dev
mailing list