[Llvm-bgq-discuss] rint() with -ffast-math

Hal Finkel hfinkel at anl.gov
Wed Jun 19 12:34:30 CDT 2013


----- Original Message -----
> 
> On Wed, Jun 19, 2013 at 1:24 PM, Hal Finkel < hfinkel at anl.gov >
> wrote:
> 
> 
> 
> 
> 
> 
> ----- Original Message -----
> > 
> > On Wed, Jun 19, 2013 at 1:15 PM, Hal Finkel < hfinkel at anl.gov >
> > wrote:
> > 
> > 
> > 
> > 
> > 
> > ----- Original Message -----
> > > 
> > > Actually, the Intel AVX instructions have a similar issue: rint()
> > > has
> > > a fast instruction, but round() does not. On this architecture,
> > > round() still does the "right thing", even with -ffast-math, both
> > > with gcc and clang.
> > > 
> > > 
> > > Actually, as I just see, gcc generates a short sequence of
> > > instructions (five or so) to implement round() properly, whereas
> > > clang calls _round.
> > 
> > LLVM only seems to have special handling of:
> > FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR
> > (as there is no FROUND and so round() will always give you the
> > library call).
> > 
> > 
> > > 
> > > 
> > > Given this, the behaviour on BGQ is indeed special. I would
> > > expect
> > > clang to behave consistently -- to either apply this optimization
> > > across the board, or nowhere. Do you want to raise the issue on
> > > the
> > > llvm mailing list?
> > 
> > Unfortunately, this optimization (as are many low-level fast-math
> > optimizations) is target-specific. As a result, I'm not sure that
> > you'll even really get the cross-platform consistency that you'd
> > like. That having been said, if this change is too strong, then we
> > should back it out.
> > 
> > 
> > 
> > Yes, it's target specific. Nevertheless, whether rint's
> > tie-breaking
> > can be influenced by __FAST_MATH__ should be a consensus decision.
> > Either BGQ is over-zealous, or Intel is missing a possible
> > optimisation, or llvm makes different speed/accuracy trade-offs on
> > different architectures. And the latter would be bad for users.
> 
> Agreed. Would you like to write to the list or should I?
> 
> 
> 
> I'd prefer if you did it -- I'd hope that your asking has less chance
> of being told off via "don't complain, that's what you get when you
> use __FAST_MATH__".

And you think that I'll get a different response ;) -- Well, we'll see...

 -Hal

> 
> 
> -erik
> 
> --
> Erik Schnetter < schnetter at cct.lsu.edu >
> http://www.perimeterinstitute.ca/personal/eschnetter/

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory


More information about the llvm-bgq-discuss mailing list