[PATCH] XCore fix for SingleSource/Benchmarks/Misc-C++/Large/sphereflake

Daniel Dunbar daniel at zuster.org
Mon Mar 10 12:46:32 PDT 2014


Is this a problem in newlib? Shouldn't its sin() compute the same result as
other platforms?

 - Daniel


On Mon, Mar 10, 2014 at 3:43 AM, robert lytton <robert at xmos.com> wrote:

> Hi rengolin, ddunbar,
>
> Newlib sin() needed rounding down instead of up on one calculation.
> Without this fix, rounding is compounded affecting 3 output values and
> hence the expected hash.
>
> Alternatively, the rounding mechanism could be changed to round the bottom
> 2 bits for all targets for both sin & cos.
> (Also why do we round up instead of down?)
> viz:
>    u.ll  &= ~3ULL;
>
>
>
>
> http://llvm-reviews.chandlerc.com/D3022
>
> Files:
>   SingleSource/Benchmarks/Misc-C++/Large/Makefile
>   SingleSource/Benchmarks/Misc-C++/Large/sphereflake.cpp
>
> Index: SingleSource/Benchmarks/Misc-C++/Large/Makefile
> ===================================================================
> --- SingleSource/Benchmarks/Misc-C++/Large/Makefile
> +++ SingleSource/Benchmarks/Misc-C++/Large/Makefile
> @@ -4,9 +4,4 @@
>  FP_ABSTOLERANCE := 0.01
>  HASH_PROGRAM_OUTPUT := 1
>
> -ifeq ($(ARCH),XCore)
> -# XCore diffs output on 3 of the 65536 numbers
> -PROGRAMS_TO_SKIP := sphereflake
> -endif
> -
>  include $(LEVEL)/SingleSource/Makefile.singlesrc
> Index: SingleSource/Benchmarks/Misc-C++/Large/sphereflake.cpp
> ===================================================================
> --- SingleSource/Benchmarks/Misc-C++/Large/sphereflake.cpp
> +++ SingleSource/Benchmarks/Misc-C++/Large/sphereflake.cpp
> @@ -151,6 +151,12 @@
>  static double LLVMsin(double d) {
>    dbl_ll_union u;
>    u.d = sin(d);
> +#ifdef __XS1B__
> +  if (u.ll == 13829347719771606185ULL)
> +    // XCore's newlib result needs rounding down instead of up.
> +    u.ll = 13829347719771606184ULL;
> +  else
> +#endif
>    u.ll = (u.ll + 1) & ~1ULL;
>    return u.d;
>  }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140310/b2c84147/attachment.html>


More information about the llvm-commits mailing list