[Libclc-dev] [PATCH 11/14] math: Use precomputed constant for log2(10.0)

Jan Vesely via Libclc-dev libclc-dev at lists.llvm.org
Mon Nov 13 10:56:47 PST 2017


On Sun, 2017-11-12 at 23:13 +0100, Jeroen Ketema via Libclc-dev wrote:
> LGTM (I did not check the correctness of the constant definitions)

thanks.

> 
> With regard to the CTS failure: there isn’t a exp10 implementation in
> the AMD contributed code?

There is. Fixing/adding math builtins is next on my todo list (after
half_).

Jan

> 
> Jeroen
> 
> > On 4 Nov 2017, at 00:07, Jan Vesely via Libclc-dev <libclc-dev at lists.llvm.org> wrote:
> > 
> > exp10 CTS fails with or withoput this change
> > 
> > Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> > ---
> > generic/include/clc/float/definitions.h | 8 ++++++++
> > generic/lib/math/exp10.inc              | 4 ++--
> > generic/lib/math/native_exp10.inc       | 2 +-
> > 3 files changed, 11 insertions(+), 3 deletions(-)
> > 
> > diff --git a/generic/include/clc/float/definitions.h b/generic/include/clc/float/definitions.h
> > index 6010ed2..84a102e 100644
> > --- a/generic/include/clc/float/definitions.h
> > +++ b/generic/include/clc/float/definitions.h
> > @@ -31,6 +31,10 @@
> > #define M_SQRT2_F       0x1.6a09e6p+0f
> > #define M_SQRT1_2_F     0x1.6a09e6p-1f
> > 
> > +#ifdef __CLC_INTERNAL
> > +#define M_LOG210_F      0x1.a934f0p+1f
> > +#endif
> > +
> > #ifdef cl_khr_fp64
> > 
> > #define HUGE_VAL        __builtin_huge_val()
> > @@ -59,6 +63,10 @@
> > #define M_SQRT2         0x1.6a09e667f3bcdp+0
> > #define M_SQRT1_2       0x1.6a09e667f3bcdp-1
> > 
> > +#ifdef __CLC_INTERNAL
> > +#define M_LOG210	0x1.a934f0979a371p+1
> > +#endif
> > +
> > #endif
> > 
> > #ifdef cl_khr_fp16
> > diff --git a/generic/lib/math/exp10.inc b/generic/lib/math/exp10.inc
> > index a592c19..f5482e4 100644
> > --- a/generic/lib/math/exp10.inc
> > +++ b/generic/lib/math/exp10.inc
> > @@ -1,9 +1,9 @@
> > _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE exp10(__CLC_GENTYPE val) {
> >   // exp10(x) = exp2(x * log2(10))
> > #if __CLC_FPSIZE == 32
> > -  return exp2(val * log2(10.0f));
> > +  return exp2(val * M_LOG210_F);
> > #elif __CLC_FPSIZE == 64
> > -  return exp2(val * log2(10.0));
> > +  return exp2(val * M_LOG210);
> > #else
> > #error unknown _CLC_FPSIZE
> > #endif
> > diff --git a/generic/lib/math/native_exp10.inc b/generic/lib/math/native_exp10.inc
> > index 7f9cb15..9826b4e 100644
> > --- a/generic/lib/math/native_exp10.inc
> > +++ b/generic/lib/math/native_exp10.inc
> > @@ -1,3 +1,3 @@
> > _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_exp10(__CLC_GENTYPE val) {
> > -  return native_exp2(val * M_LOG10E_F);
> > +  return native_exp2(val * M_LOG210_F);
> > }
> > -- 
> > 2.13.6
> > 
> > _______________________________________________
> > Libclc-dev mailing list
> > Libclc-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/libclc-dev
> 
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/libclc-dev
-------------- 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/20171113/87d2744d/attachment-0001.sig>


More information about the Libclc-dev mailing list