diff --git a/libclc/generic/include/clc/math/rsqrt.h b/libclc/generic/include/clc/math/rsqrt.h --- 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 +#define __CLC_FUNCTION rsqrt + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES --- a/libclc/generic/lib/SOURCES +++ b/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 diff --git a/libclc/generic/lib/math/rsqrt.cl b/libclc/generic/lib/math/rsqrt.cl new file mode 100644 --- /dev/null +++ b/libclc/generic/lib/math/rsqrt.cl @@ -0,0 +1,23 @@ +#include + +#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