From: jeff.sturm@appnet.com
To: axp-list@redhat.com
Subject: Re: FFTW performance
Date: Tue, 10 Apr 2001 14:33:22 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.21.0104101311030.13504-100000@neoavalon.sigma6.com> (raw)
In-Reply-To: <20010410091022.B26155@linux04.mro.cpqcorp.net>
On Tue, 10 Apr 2001, Jay Estabrook wrote:
> But please, refer to the following document for *lots* of tips,
> including a discussion of compiler flags and such:
>
> http://www.alphalinux.org/docs/perf.html
That's an excellent article. I appreciate the explanation of replay
traps, which aren't covered well in any other public document I've seen.
My only beef is that they aren't really fair to GCC, but I'll excuse it
because the article isn't meant to be a review, and after CCC is their
own. They don't say what version they use, but they called it EGCS, so
I'd guess it is 2-3 years old. The GCC backend has made a bit of progress
since then.
Besides the points in this article there are a couple of other things I
learned while tuning my code for Alpha that I haven't seen mentioned
anywhere else. Keep reading if you're interested...
1) Use both register sets where possible.
Somewhere, sometime long ago I got it into my head that floating-point
registers are best avoided for non-numeric computing. That probably comes
from the days of microprocessors without efficient fp units. So I tend to
always use `int' types (including short, long, etc.) to declare local
variables.
While tuning a large loop to avoid register spillage, I realized that some
of the locals didn't really need to be integers, i.e. that rounding errors
would be tolerable to the algorithm. Declaring these as double left
enough integer registers available to avoid spillage altogether. As a
result I got an instance 20% improvement.
Be careful about int<->fp conversions however; on some CPUs these require
a memory access (alphas prior to EV6, IIRC).
The same may hold true for mostly-FP programs; the integer set can go
underused.
2) Using extra operations to avoid memory accesses.
Another habit that dies hard is reducing the complexity of code, favoring
shorter, simpler instruction sequences everywhere. Common sense dictates
that removing a few instructions here and there helps optimize code. On
modering CPUs sometimes the reverse is true-- to a certain point, the more
instructions available inside a function or loop (i.e. the longer a basic
block) the better job a compiler or CPU can do to schedule. Sometimes the
compiler will even insert NOP instructions to help avoid pipeline stalls.
For most code I work on the critical bottleneck is not the processor's
pipeline but memory throughput. One block of code I experimented with
needed a large array of boolean values, declared as an int[]. I had
guessed it was memory limited, as my overall CPI was higher than 2. My
first attempt to help it allocated the boolean table as a
char[]. Surprisingly that had negligible effect. (The original int array
was not too large to fit in secondary cache anyway, and the real choke
point I suspect was the CPU's store buffer.)
Next I tried a bitmap of boolean values. I wasn't very confident this
would help, because although the array size became 1/32 its original size
the code to access random bits was littered with shift and mask
operations.
It ran twice as fast as the original, despite performing an equal count of
load/store instructions. My CPI shot down below 1, and the alpha now
performed the loop faster than equivalent code on x86 or sparc (it had
been slower before). One explanation for the improvement is that the
alpha could merge consecutive stores to the same location, which it could
apparently not do for consecutive locations, even to the same cache line
(not sure about that though). The alpha happily consumed the extra
instructions, feeding both of its integer units.
Another way to look at it is that the same optimizations we've known for
decades to avoid disk accesses are now becoming relevant for memory
access, since memory technology has not held pace with microprocessors.
--
Jeff Sturm
jeff.sturm@commerceone.com
next prev parent reply other threads:[~2001-04-10 18:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-10 7:32 FFTW performance Eugene Chu
2001-04-10 7:35 ` Linus Gasser
2001-04-10 10:49 ` T. Daniel Crawford
2001-04-10 13:10 ` Jay Estabrook
2001-04-10 18:33 ` jeff.sturm [this message]
2001-04-10 14:44 ` Greg Lindahl
-- strict thread matches above, loose matches on Subject: below --
2001-04-10 23:42 Tom Morris
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox