[PATCH] D74013: libclc: Move rsqrt implementation to a .cl file

Jan Vesely via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 9 11:47:05 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b23a2e8e971: libclc: Move rsqrt implementation to a .cl file (authored by jvesely).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74013/new/

https://reviews.llvm.org/D74013

Files:
  libclc/generic/include/clc/math/rsqrt.h
  libclc/generic/lib/SOURCES
  libclc/generic/lib/math/rsqrt.cl


Index: libclc/generic/lib/math/rsqrt.cl
===================================================================
--- /dev/null
+++ libclc/generic/lib/math/rsqrt.cl
@@ -0,0 +1,23 @@
+#include <clc/clc.h>
+
+#include "../clcmacro.h"
+
+_CLC_OVERLOAD _CLC_DEF float rsqrt(float x)
+{
+    return 1.0f / sqrt(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 1.0 / sqrt(x);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, rsqrt, double);
+
+#endif
Index: libclc/generic/lib/SOURCES
===================================================================
--- libclc/generic/lib/SOURCES
+++ libclc/generic/lib/SOURCES
@@ -176,6 +176,7 @@
 math/clc_rootn.cl
 math/rootn.cl
 math/round.cl
+math/rsqrt.cl
 math/sin.cl
 math/sincos.cl
 math/sincos_helpers.cl
Index: libclc/generic/include/clc/math/rsqrt.h
===================================================================
--- libclc/generic/include/clc/math/rsqrt.h
+++ libclc/generic/include/clc/math/rsqrt.h
@@ -1 +1,7 @@
-#define rsqrt(x) (1.f/sqrt(x))
+#define __CLC_BODY <clc/math/unary_decl.inc>
+#define __CLC_FUNCTION rsqrt
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74013.243454.patch
Type: text/x-patch
Size: 1317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200209/42a8d3e4/attachment.bin>


More information about the llvm-commits mailing list