Native compilation article

Tom Tromey
Mon Jan 28 21:15:00 GMT 2002

Tom> I've been meaning to try the IBM `primes' code with loop
Tom> unrolling to see how that does.

Tonight I tried this.  I actually tried a bunch of combinations; see
the appended script.

Runs with `long' were uniformly much slower than `int'.
I've also appended some results.  I ran the script 3 times, massaged
the output, and sorted the results.

There's a fair amount of noise in the fastest category.  Overall the
int/long difference is really the significant one.


16364 int -O2 -funroll-all-loops
16364 int -O2 -funroll-loops --no-bounds-check
16369 int -O2 -funroll-all-loops --no-bounds-check
16380 int -O3 -funroll-all-loops
16384 int -O2 -funroll-all-loops
16385 int -O3 -funroll-loops
16386 int -O2 -funroll-all-loops --no-bounds-check
16386 int -O2 -funroll-loops --no-bounds-check
16387 int -O2 -funroll-loops
16388 int -O2 -funroll-loops
16400 int -O3 -funroll-loops --no-bounds-check
16405 int -O3 -funroll-all-loops --no-bounds-check
16450 int -O3  --no-bounds-check
16488 int -O3
16540 int -O2
16583 int -O2  --no-bounds-check
16608 int -O2  --no-bounds-check
16681 int -O2
18170 int -O3 -funroll-loops --no-bounds-check
18196 int -O2 -funroll-loops --no-bounds-check
18208 int -O3 -funroll-loops
18209 int -O2 -funroll-all-loops
18218 int -O3 -funroll-all-loops
18224 int -O3 -funroll-all-loops --no-bounds-check
18226 int -O3 -funroll-all-loops --no-bounds-check
18235 int -O2 -funroll-all-loops --no-bounds-check
18266 int -O3 -funroll-all-loops
18269 int -O3
18280 int -O3  --no-bounds-check
18303 int -O3 -funroll-loops
18322 int -O3 -funroll-loops --no-bounds-check
18349 int -O3  --no-bounds-check
18361 int -O2 -funroll-loops
18374 int -O2
18383 int -O2  --no-bounds-check
18383 int -O3
48362 long -O2
48517 long -O3
48528 long -O2 -funroll-loops --no-bounds-check
48530 long -O3 -funroll-loops --no-bounds-check
48542 long -O2  --no-bounds-check
48544 long -O3  --no-bounds-check
48551 long -O2  --no-bounds-check
48560 long -O2
48590 long -O3 -funroll-loops
48591 long -O2 -funroll-loops --no-bounds-check
48643 long -O2 -funroll-loops
48720 long -O2 -funroll-loops
49600 long -O3 -funroll-all-loops
49609 long -O3 -funroll-all-loops --no-bounds-check
49617 long -O2 -funroll-all-loops --no-bounds-check
49679 long -O2 -funroll-all-loops
49701 long -O2 -funroll-all-loops
51385 long -O2 -funroll-all-loops --no-bounds-check
53900 long -O3
53934 long -O3 -funroll-loops
53973 long -O2
54001 long -O3
54013 long -O2 -funroll-loops
54065 long -O3 -funroll-loops --no-bounds-check
54109 long -O3  --no-bounds-check
54139 long -O2 -funroll-loops --no-bounds-check
54154 long -O3  --no-bounds-check
54171 long -O2  --no-bounds-check
54246 long -O3 -funroll-loops --no-bounds-check
54277 long -O3 -funroll-loops
55067 long -O3 -funroll-all-loops --no-bounds-check
55091 long -O3 -funroll-all-loops
55209 long -O2 -funroll-all-loops --no-bounds-check
55252 long -O3 -funroll-all-loops --no-bounds-check
55261 long -O3 -funroll-all-loops
55281 long -O2 -funroll-all-loops

#! /bin/sh

args="--main=prime -o prime -Wl,-rpath,/x1/egcs/install/lib"

for level in -O2 -O3; do
   for loop in '' -funroll-loops -funroll-all-loops; do
      for cheat in '' --no-bounds-check; do
	 for type in int long; do
	    rm -f prime
	    sed -e "s/TYPE/$type/g" < >
	    echo "[type $type] gcj -g0 $level $loop $cheat $args"
	    gcj -g0 $level $loop $cheat $args

More information about the Java mailing list