From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.redhat.com (mail.redhat.com [199.183.24.239]) by listman.redhat.com (Postfix) with ESMTP id 1F2D72F088 for ; Tue, 10 Apr 2001 14:14:22 -0400 (EDT) Received: (from mail@localhost) by mail.redhat.com (8.11.0/8.8.7) id f3AIGMD13755 for axp-list@listman.redhat.com; Tue, 10 Apr 2001 14:16:22 -0400 Received: from neoavalon.sigma6.com (neoavalon.sigma6.com [204.176.48.130]) by mail.redhat.com (8.11.0/8.8.7) with ESMTP id f3AIGLV13744 for ; Tue, 10 Apr 2001 14:16:21 -0400 Received: from localhost (jsturm@localhost) by neoavalon.sigma6.com (8.9.3/8.9.3) with ESMTP id OAA14238 for ; Tue, 10 Apr 2001 14:33:22 -0400 From: jeff.sturm@appnet.com X-Authentication-Warning: neoavalon.sigma6.com: jsturm owned process doing -bs Date: Tue, 10 Apr 2001 14:33:22 -0400 (EDT) X-Sender: jsturm@neoavalon.sigma6.com To: axp-list@redhat.com Subject: Re: FFTW performance In-Reply-To: <20010410091022.B26155@linux04.mro.cpqcorp.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Loop: axp-list@redhat.com Sender: axp-list-admin@redhat.com Errors-To: axp-list-admin@redhat.com X-BeenThere: axp-list@redhat.com X-Mailman-Version: 2.0.1 Precedence: bulk Reply-To: axp-list@redhat.com List-Help: List-Post: List-Subscribe: , List-Id: Linux and Red Hat on Alpha processors List-Unsubscribe: , List-Archive: 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