[Libclc-dev] [PATCH 2/2] r600/rootn: Flush denormal inputs

Jan Vesely via Libclc-dev libclc-dev at lists.llvm.org
Mon Apr 23 13:44:55 PDT 2018


It's OK to either flush to 0 or return denormal result if the device
does not support denormals. See sec 7.2 and 7.5.3 of OCL specs
Fixes CTS on turks.
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
 r600/lib/SOURCES       |  1 +
 r600/lib/math/rootn.cl | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 r600/lib/math/rootn.cl

diff --git a/r600/lib/SOURCES b/r600/lib/SOURCES
index 826919c..b99f8d1 100644
--- a/r600/lib/SOURCES
+++ b/r600/lib/SOURCES
@@ -1,5 +1,6 @@
 math/exp.cl
 math/fma.cl
+math/rootn.cl
 synchronization/barrier_impl.ll
 workitem/get_global_offset.cl
 workitem/get_group_id.cl
diff --git a/r600/lib/math/rootn.cl b/r600/lib/math/rootn.cl
new file mode 100644
index 0000000..5790b86
--- /dev/null
+++ b/r600/lib/math/rootn.cl
@@ -0,0 +1,26 @@
+
+#include <clc/clc.h>
+#include "math/clc_rootn.h"
+#include "../../generic/lib/math/math.h"
+#include "../../generic/lib/clcmacro.h"
+#include "config.h"
+
+_CLC_DEF _CLC_OVERLOAD float rootn(float x, int ny)
+{
+    // Flush denormal
+    int ix = as_int(x);
+    if (((ix & EXPBITS_SP32) == 0) && ((ix & MANTBITS_SP32) != 0) && !__clc_fp32_subnormals_supported()) {
+	ix &= SIGNBIT_SP32;
+	x = as_float(ix);
+    }
+    return __clc_rootn(x, ny);
+}
+_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, rootn, float, int)
+
+#ifdef cl_khr_fp64
+_CLC_DEF _CLC_OVERLOAD double __clc_rootn(double x, int ny)
+{
+	return __clc_rootn(x, ny);
+}
+_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, rootn, double, int)
+#endif
-- 
2.14.3



More information about the Libclc-dev mailing list