[cfe-dev] Floating-point performance question

Hal Finkel hfinkel at anl.gov
Fri Sep 6 08:31:18 PDT 2013


----- Original Message -----
> 
> 
> On 09/05/2013 04:44 PM, Richard Hadsell wrote:
> 
> 
> Thanks for all the clues. Here is the stack trace:
> feholdexcept,
>  __ieee754_exp2,
>  exp2,
>  _ZN9cgi... Based on your various hints, I'm guessing that our code
>  'pow (2.0, x)' is being optimized by Clang++ to 'exp2 (x)' and not
>  by G++. We will try using exp2 explicitly and see what happens with
>  the G++ version.
> 
> Perhaps we are running into a floating-point standards issue that our
> old version of G++ is ignoring.
> 
> We'll continue investigating tomorrow.
> 
> We changed our code to use 'exp2 (x)' instead of 'pow (2.0, x)' and
> verified that the G++ version now calls feholdexcept. We'll also run
> our benchmarks again to compare Clang++ with G++ on our modified
> code.
> 
> So, the question for Clang developers is: how can we avoid the
> optimization that converts 'pow (2.0, x)' to 'exp2 (x)'?

This happens in Transforms/Utils/SimplifyLibCalls.cpp -- Maybe we should add a function to TargetLibraryInfo in order to mark exp2 as expensive on some platforms?

 -Hal

> 
> I don't know why the library functions differ in their need to call
> feholdexcept, but regardless of the explanation, I want to pick the
> faster one for this particular usage.
> 
> --
> Dick Hadsell			203-992-6320  Fax: 203-992-6001
> Reply-to: hadsell at blueskystudios.com Blue Sky Studios
> http://www.blueskystudios.com 1 American Lane, Greenwich, CT
> 06831-2560
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 

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




More information about the cfe-dev mailing list