diff options
author | Jan Vesely <jan.vesely@rutgers.edu> | 2020-02-04 20:09:12 -0500 |
---|---|---|
committer | Jan Vesely <jano.vesely@gmail.com> | 2020-02-09 14:42:09 -0500 |
commit | 4b23a2e8e971876d075d3ae322754dbc0495413d (patch) | |
tree | d666f8e43e2f1bdce969f1e14727bd525792b2e2 /libclc | |
parent | 0ae119f83560c694d6b1f17e32dc7a6b8be16bc1 (diff) | |
download | llvm-4b23a2e8e971876d075d3ae322754dbc0495413d.tar.gz |
libclc: Move rsqrt implementation to a .cl file
Reviewer: awatry
Differential Revision: https://reviews.llvm.org/D74013
Diffstat (limited to 'libclc')
-rw-r--r-- | libclc/generic/include/clc/math/rsqrt.h | 8 | ||||
-rw-r--r-- | libclc/generic/lib/SOURCES | 1 | ||||
-rw-r--r-- | libclc/generic/lib/math/rsqrt.cl | 23 |
3 files changed, 31 insertions, 1 deletions
diff --git a/libclc/generic/include/clc/math/rsqrt.h b/libclc/generic/include/clc/math/rsqrt.h index 9d49ee652262..41b9fd7572b9 100644 --- a/libclc/generic/include/clc/math/rsqrt.h +++ b/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 diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES index df7f68f040f3..ee2736b5fbc5 100644 --- a/libclc/generic/lib/SOURCES +++ b/libclc/generic/lib/SOURCES @@ -176,6 +176,7 @@ math/rint.cl math/clc_rootn.cl math/rootn.cl math/round.cl +math/rsqrt.cl math/sin.cl math/sincos.cl math/sincos_helpers.cl diff --git a/libclc/generic/lib/math/rsqrt.cl b/libclc/generic/lib/math/rsqrt.cl new file mode 100644 index 000000000000..131ffc194a90 --- /dev/null +++ b/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 |