[Libclc-dev] [PATCH 2/2] Add native_recip(x) as ((1)/(x))

Jan Vesely via Libclc-dev libclc-dev at lists.llvm.org
Fri Sep 8 14:45:50 PDT 2017


On Wed, 2017-09-06 at 22:22 -0500, Aaron Watry via Libclc-dev wrote:
> Signed-off-by: Aaron Watry <awatry at gmail.com>
> ---
>  generic/include/clc/clc.h               | 1 +
>  generic/include/clc/math/native_recip.h | 1 +
>  2 files changed, 2 insertions(+)
>  create mode 100644 generic/include/clc/math/native_recip.h
> 
> diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> index a93c8ef..9c0e00c 100644
> --- a/generic/include/clc/clc.h
> +++ b/generic/include/clc/clc.h
> @@ -106,6 +106,7 @@
>  #include <clc/math/native_log.h>
>  #include <clc/math/native_log2.h>
>  #include <clc/math/native_powr.h>
> +#include <clc/math/native_recip.h>
>  #include <clc/math/native_sin.h>
>  #include <clc/math/native_sqrt.h>
>  #include <clc/math/native_rsqrt.h>
> diff --git a/generic/include/clc/math/native_recip.h b/generic/include/clc/math/native_recip.h
> new file mode 100644
> index 0000000..5187661
> --- /dev/null
> +++ b/generic/include/clc/math/native_recip.h
> @@ -0,0 +1 @@
> +#define native_recip(x) ((1) / (x))

I think this would need fast/unsafe math flag to actually generate
reciprocal, but since all our native_* functions are macros for now.
Acked-by: Jan Vesely <jan.vesely at rutgers.edu>

I think it'd be a good idea to come up with a plan to properly support
native_* functions. to me it looks like the options are:
a) Treat llvm intrinsics as native precision and use those
b) Treat llvm intrinsics as properly rounded and export device specific
__builtins via clang.

a) is less work (both in LLVM and libclc), but I think b) is what is
expected of us

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/libclc-dev/attachments/20170908/11c30a97/attachment.sig>


More information about the Libclc-dev mailing list