This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: numerical instability and estimate-probability


> 
> On Thursday, November 15, 2001, at 02:31 , mike stump wrote:
> 
> >One can `fix' this by doing the arithmetic in double, doing it safely,
> >and then chopping the number down to say, 5 or 10 digits at the end.
> >This way increase the odds that the numbers will be the same of all
> >platforms, and that the same code will be generated.  [ crossed
> >fingers we can do without a portible math library ]
> 
> In practice you will not achieve this. With probabilities, one
> might often end up in exact inbetween cases, where double rounding
> as is done on x86 when using double can wreak havoc. Even apart
> from the x86, it is hard to guarantee bit-identical results on
> different systems.
Actually the current code seems to produce same probabilities as on
mips.
I am rounding after each operations and the operantions are just dividing
by 10000 and summing. Perhaps if I get it dividing by ppower of 16 I get
stable result, but someone with more fp expirience can take a look.
> 
> I think GCC should just not use floating-point arithmetic at all
> for making code generation decisions. It might be best to define
> a probability type using integers and have some functions for adding
> and multiplying them.
Yes, this is an alternative I was mentinong in the parallel post to
gcc@.

Bascilly the question is, do we want to jump for GMP library?
We need large arithmetics elsewhere too.

The probabilities are already integer.  The estiimate-probabilities is
using floats only to compute frequencies of basic blocks. IT is done
so just because it is dificult to fit in integers for this purpose.
Imagine 10 nested loopos each predicted to iterate 10 times.

What I do is to compute frequencies in floats and then rescale them
in the range 0 to 10000 so I get accurate information in hot spots,
0 otherwise.

I am open to all suggestions.
Honza
> 
>   -Geert


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]