libclc/r600: Use target specific builtins to implement rsqrt and native_rsqrt
authorJan Vesely <jan.vesely@rutgers.edu>
Wed, 5 Feb 2020 01:14:04 +0000 (20:14 -0500)
committerJan Vesely <jano.vesely@gmail.com>
Sun, 9 Feb 2020 19:42:15 +0000 (14:42 -0500)
Fixes OCL CTS rsqrt and half_rsqrt (1 thread, scalaer) tests on AMD Turks.

Reviewer: awatry
Differential Revision: https://reviews.llvm.org/D74016

libclc/r600/lib/SOURCES
libclc/r600/lib/math/native_rsqrt.cl [new file with mode: 0644]
libclc/r600/lib/math/rsqrt.cl [new file with mode: 0644]

index 4342ac3..6e01bbb 100644 (file)
@@ -1,5 +1,7 @@
 math/fmax.cl
 math/fmin.cl
+math/native_rsqrt.cl
+math/rsqrt.cl
 synchronization/barrier.cl
 workitem/get_global_offset.cl
 workitem/get_group_id.cl
diff --git a/libclc/r600/lib/math/native_rsqrt.cl b/libclc/r600/lib/math/native_rsqrt.cl
new file mode 100644 (file)
index 0000000..edf473e
--- /dev/null
@@ -0,0 +1,10 @@
+#include <clc/clc.h>
+
+#include "../../../generic/lib/clcmacro.h"
+
+_CLC_OVERLOAD _CLC_DEF float native_rsqrt(float x)
+{
+    return __builtin_r600_recipsqrt_ieeef(x);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, native_rsqrt, float);
diff --git a/libclc/r600/lib/math/rsqrt.cl b/libclc/r600/lib/math/rsqrt.cl
new file mode 100644 (file)
index 0000000..37a8037
--- /dev/null
@@ -0,0 +1,23 @@
+#include <clc/clc.h>
+
+#include "../../../generic/lib/clcmacro.h"
+
+_CLC_OVERLOAD _CLC_DEF float rsqrt(float x)
+{
+    return __builtin_r600_recipsqrt_ieeef(x);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, rsqrt, float);
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_OVERLOAD _CLC_DEF double rsqrt(double x)
+{
+    return __builtin_r600_recipsqrt_ieee(x);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, rsqrt, double);
+
+#endif