Integer micro-benchmarks [Smalltalk Multi-Precision Numerics vis-a-vis Highly Optimized Fixed Size Integer C++ Numerics]

Daniel Berlin dan at www.cgsoftware.com
Tue Apr 24 19:32:32 EDT 2001


>
> Despite it being in a different compilation unit, I had VC7 with all
> optimizations on to optimize everithing away and just precompute the final
> result and call std::cout with it as a constant!!!! So I disabled "Global
> Optimization" (that is I told it to not optimize across compilation units) and
> here we go:
>
> Time = 5585 result=4950
>
> The order of magnitude is the same as your case.
>
> However note: Smalltalk always has all the code at hand. C++ generally compiles
> one module at a time. If I tell VC7 to optimize across compilation units it goes
> to inline the triangle function and ... it does even optimize it out by pre
> computing the result!!
Of course, what did you expect it to do?

>
> Note that it is REALLY smart! I played with it and I could get it to a point
> that it did not optimize the call out completelly but noted that triangle had no
> side effect and always returned the same result for the same input so ... it
> translated
>
>  for ( int j=0; j<10; j++ ) {
>   int sum=0;
>   for (int i = 0; i != 9000000; ++i)
>    sum += triangle( 10 );
>   tot+=sum / 1000000;
>  }
>
> into something like
>
>  tot+= triangle( 10 )*9;
>
> Not bad for an optimizer!

Errr, this is pretty basic PRE and loop hoisting.

In other words, it's done by anyone taking a college compiler optimization
course.
--Dan





More information about the Python-list mailing list