* gcc/egcs C optimization @ 1998-10-31 5:00 Berk Sensoy 1998-11-02 5:00 ` Conrad Sanderson 0 siblings, 1 reply; 15+ messages in thread From: Berk Sensoy @ 1998-10-31 5:00 UTC (permalink / raw) Hi, Does anyone have any suggestions as to what would be the best compiler options to optimize (make the fastest at run-time) my code on an Alpha/Linux machine? I have a code that solves a biharmonic PDE by calling a Fortran subroutine. Our group just acquired an Alpha/Linux and we are trying to figure out how best to opimize its various capabilities vis-a-vis an Intel machine. Thanks, Berk Sensoy Berk Sensoy Duke University, Dept. of Physics bas7@phy.duke.edu Box 90305, Durham N.C. 27708-0305, USA ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-10-31 5:00 gcc/egcs C optimization Berk Sensoy @ 1998-11-02 5:00 ` Conrad Sanderson 1998-11-02 5:00 ` Murx 1998-11-03 5:00 ` Adam C. Powell, IV 0 siblings, 2 replies; 15+ messages in thread From: Conrad Sanderson @ 1998-11-02 5:00 UTC (permalink / raw) Berk Sensoy <bas7@lemur.phy.duke.edu> wrote: > Does anyone have any suggestions as to what would be the best >compiler options to optimize (make the fastest at run-time) my code on an >Alpha/Linux machine? I have a >code that solves a biharmonic PDE by calling a Fortran subroutine. Our >group just acquired an Alpha/Linux and we are trying to figure out how >best to opimize its various capabilities vis-a-vis an Intel machine. -O3 -funroll-all-loops -fexpensive-optimizations (may need to add -mieee depending on how the code is written) Getting a decent math library will make the most difference: http://people.frankfurt.netsurf.de/Joachim.Wesner/ Note that with the current state of free compilers on Alpha, you will probably end up getting better performance on a Intel P2/450. -- Conrad Sanderson - Microelectronic Signal Processing Laboratory Griffith University, Queensland, Australia http://spl.me.gu.edu.au [ under construction ] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-02 5:00 ` Conrad Sanderson @ 1998-11-02 5:00 ` Murx 1998-11-03 5:00 ` Adam C. Powell, IV 1 sibling, 0 replies; 15+ messages in thread From: Murx @ 1998-11-02 5:00 UTC (permalink / raw) Conrad Sanderson wrote: > Berk Sensoy <bas7@lemur.phy.duke.edu> wrote: > > > Does anyone have any suggestions as to what would be the best > >compiler options to optimize (make the fastest at run-time) my code on an > >Alpha/Linux machine? I have a > >code that solves a biharmonic PDE by calling a Fortran subroutine. Our > >group just acquired an Alpha/Linux and we are trying to figure out how > >best to opimize its various capabilities vis-a-vis an Intel machine. > > -O3 -funroll-all-loops -fexpensive-optimizations > (may need to add -mieee depending on how the code is written) > > > Getting a decent math library will make the most difference: > > http://people.frankfurt.netsurf.de/Joachim.Wesner/ > My favourite is: g77 -O3 -funroll-loops -fno-schedule-insns -fschedule-insns2 -o foo.x foo.f -lffm -lfm -lm Our code yields a factor of three on a 533 Mhz linux alpha as compared to a 350 Pentium II, both egcs-1.1b. For a real fast code, you'll probably need to handoptimize the inner loops (cache-blocking, and loop-unrolling by four helps a *lot*) Christian ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-02 5:00 ` Conrad Sanderson 1998-11-02 5:00 ` Murx @ 1998-11-03 5:00 ` Adam C. Powell, IV 1998-11-03 5:00 ` Greg Lindahl 1998-11-04 5:00 ` C.Simmendinger 1 sibling, 2 replies; 15+ messages in thread From: Adam C. Powell, IV @ 1998-11-03 5:00 UTC (permalink / raw) Conrad Sanderson wrote: > Berk Sensoy <bas7@lemur.phy.duke.edu> wrote: > > > Does anyone have any suggestions as to what would be the best > >compiler options to optimize (make the fastest at run-time) my code on an > >Alpha/Linux machine? I have a > >code that solves a biharmonic PDE by calling a Fortran subroutine. Our > >group just acquired an Alpha/Linux and we are trying to figure out how > >best to opimize its various capabilities vis-a-vis an Intel machine. > > -O3 -funroll-all-loops -fexpensive-optimizations > (may need to add -mieee depending on how the code is written) Thanks! This is a big help. > Getting a decent math library will make the most difference: > > http://people.frankfurt.netsurf.de/Joachim.Wesner/ Likewise, if your problem involves dense matrix multiply, or anything using it (e.g. LU-decomposition), Kazushige Goto's assembler gemm truly screams. Like 1.5 double-precision FLOPS/clock sustained! (Just under 2 peak.) Blows away everything else on the planet within 5-10 times the price. ftp://ftp.eni.co.jp/.2/Linux-Alpha-JP/ftp.statabo.rim.or.jp/BLAS/ > Note that with the current state of free compilers on Alpha, > you will probably end up getting better performance on > a Intel P2/450. Really?? Even for floating point? Do you have a P2/450 vs. alpha bnchmark? All of the programs I have built unmodified with egcs-1.0.3a and libffm run slightly faster (10-30%) than an SGI Origin 2000! (Goto's gemm is about 4 times faster than the hand-coded R10K BLAS gemm.) I'd have to see a convincing benchmark to believe P2 is any faster- for floating point (integer I'd believe)- everything I've seen says otherwise. Zeen, -Adam `Cold Fusion' Powell, IV _/\_ http://www.ctcms.nist.gov/~powell/ Call with Netscape Conference! \/ http://dls.netscape.com/ ____ USDoC, National Institute of Standards & Technology (NIST) |\ ||< | Center for Theoretical and Computational Materials Science | \||_> | ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-03 5:00 ` Adam C. Powell, IV @ 1998-11-03 5:00 ` Greg Lindahl 1998-11-04 5:00 ` Steven G. Johnson 1998-11-04 5:00 ` C.Simmendinger 1 sibling, 1 reply; 15+ messages in thread From: Greg Lindahl @ 1998-11-03 5:00 UTC (permalink / raw) "Adam C. Powell, IV" <adam.powell@nist.gov> writes: > > Note that with the current state of free compilers on Alpha, > > you will probably end up getting better performance on > > a Intel P2/450. > > Really?? Even for floating point? Do you have a P2/450 vs. alpha bnchmark? > All of the programs I have built unmodified with egcs-1.0.3a and libffm run > slightly faster (10-30%) than an SGI Origin 2000! (Goto's gemm is about 4 > times faster than the hand-coded R10K BLAS gemm.) I'd have to see a > convincing benchmark to believe P2 is any faster- for floating point (integer > I'd believe)- everything I've seen says otherwise. I believe that FFTW would be an example where a 450 mhz PII can be faster than a 533 mhz Alpha. FFTW generates FFT routines with huge basic blocks of adds and multiplies, and the instruction scheduler with egcs is unable to effectively schedule them. If anyone wants to hack on the the haifa scheduler, that would be the place to start. BTW, note that your SGI is at most 250 mhz for its R10k; although the R10k is a semi-brainiac, you shouldn't extrapolate from R10k results to PII results without measuring... But you are right that "compilers always make the alpha lose" is not correct. If you do linear algebra, the alpha rules. -- g ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-03 5:00 ` Greg Lindahl @ 1998-11-04 5:00 ` Steven G. Johnson 0 siblings, 0 replies; 15+ messages in thread From: Steven G. Johnson @ 1998-11-04 5:00 UTC (permalink / raw) lindahl@pbm.com (Greg Lindahl) wrote: > I believe that FFTW would be an example where a 450 mhz PII can be > faster than a 533 mhz Alpha. FFTW generates FFT routines with huge > basic blocks of adds and multiplies, and the instruction scheduler > with egcs is unable to effectively schedule them. If anyone wants to > hack on the the haifa scheduler, that would be the place to start. Regarding FFTW and haifa, we actually had to turn off one of the scheduler passes (-fno-schedule-insns -fschedule-insns2) in order to get good performance on PowerPC/MIPS/UltraSPARC (haven't tried Alpha with egcs/gcc yet)! With these options, egcs was able to beat the SGI and Sun compilers on MIPS and UltraSPARC. For really long blocks, it seems that the default egcs scheduler isn't very good. Someone else on this thread apparently made the same observation, as they also suggested using these options with egcs. On the other hand, using these options does not uniformly produce benefits (e.g. I tried using them with the PhiPAC self-optimizing BLAS routines on a PowerPC, and they slowed things down). I'd be interested in seeing FFT benchmark results from egcs-1.1 on an Alpha if anyone cares to send some to me. (We have a big FFT benchmark program at http://theory.lcs.it.edu/~benchfft that you can download and run.) I'll post any results on our web page. (You will need to grab FFTW, too, at http://theory.lcs.mit.edu/~fftw.) Note that we have already posted results from the DEC compilers on Alpha. Cordially, Steven G. Johnson (FFTW co-author) ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-03 5:00 ` Adam C. Powell, IV 1998-11-03 5:00 ` Greg Lindahl @ 1998-11-04 5:00 ` C.Simmendinger 1998-11-04 5:00 ` Greg Lindahl ` (2 more replies) 1 sibling, 3 replies; 15+ messages in thread From: C.Simmendinger @ 1998-11-04 5:00 UTC (permalink / raw) Adam C. Powell, IV wrote: > Conrad Sanderson wrote: > > > Berk Sensoy <bas7@lemur.phy.duke.edu> wrote: > > > Really?? Even for floating point? Do you have a P2/450 vs. alpha bnchmark? > All of the programs I have built unmodified with egcs-1.0.3a and libffm run > slightly faster (10-30%) than an SGI Origin 2000! (Goto's gemm is about 4 > times faster than the hand-coded R10K BLAS gemm.) I'd have to see a > convincing benchmark to believe P2 is any faster- for floating point (integer > I'd believe)- everything I've seen says otherwise. > The only thing which is sort of sad about egcs ist the absolutely poor performance of g77 with respect to complex numbers. I'm just trying to optimize the BLAS a bit more, i.e. just wrote a faster cgemv/zgemv. Had to do all calculations in floats with the corresponding conversions complex->float, float->complex. In doing so i got a speedup of *4-6*. I just keep wondering why the performace is so embarrassing with respect to this ? Since a lot of numerical stuff (e.g LAPACK) is written in fortran, improvements on this sector would help quite a bit. Christian ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-04 5:00 ` C.Simmendinger @ 1998-11-04 5:00 ` Greg Lindahl 1998-11-05 5:00 ` C.Simmendinger 1998-11-04 5:00 ` Craig Burley 1998-11-05 5:00 ` Toon Moene 2 siblings, 1 reply; 15+ messages in thread From: Greg Lindahl @ 1998-11-04 5:00 UTC (permalink / raw) "C.Simmendinger" <chrisi@theo.physik.uni-stuttgart.de> writes: > The only thing which is sort of sad about egcs ist the absolutely poor > performance of g77 with respect to complex numbers. Have you tried the -fno-emulate-complex switch discussed in the g77 documentation? -- g ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-04 5:00 ` Greg Lindahl @ 1998-11-05 5:00 ` C.Simmendinger 1998-11-05 5:00 ` Greg Lindahl 0 siblings, 1 reply; 15+ messages in thread From: C.Simmendinger @ 1998-11-05 5:00 UTC (permalink / raw) Greg Lindahl wrote: > "C.Simmendinger" <chrisi@theo.physik.uni-stuttgart.de> writes: > > > The only thing which is sort of sad about egcs ist the absolutely poor > > performance of g77 with respect to complex numbers. > > Have you tried the -fno-emulate-complex switch discussed in the g77 > documentation? Yes .....internal compiler error ..... Apart from that: who would want to use a switch, which might produce incorrect results, especially with numerical code.... Well, for the BLAS this isn't a problem, it's actually an advantage. You are more free to arrange for the scheduling yourself. But as a standard procedure that's not a good approach i think. Christian ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-05 5:00 ` C.Simmendinger @ 1998-11-05 5:00 ` Greg Lindahl 1998-11-05 5:00 ` C.Simmendinger 0 siblings, 1 reply; 15+ messages in thread From: Greg Lindahl @ 1998-11-05 5:00 UTC (permalink / raw) "C.Simmendinger" <chrisi@theo1.physik.uni-stuttgart.de> writes: > > Have you tried the -fno-emulate-complex switch discussed in the g77 > > documentation? > > Yes .....internal compiler error ..... > Apart from that: who would want to use a switch, If you want a commercial-quality compiler, you're looking at the wrong place. > which might produce incorrect results, especially with > numerical code.... The error should not be dependent on the data values. In _my_ codes, the control path does not change with the data, so I can test and be 100% sure that my test means I got correct code for all values. > But as a standard procedure that's not a good approach i think. I didn't suggest it be a standard procedure. I suggested it was a possible workaround for your case. -- g ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-05 5:00 ` Greg Lindahl @ 1998-11-05 5:00 ` C.Simmendinger 0 siblings, 0 replies; 15+ messages in thread From: C.Simmendinger @ 1998-11-05 5:00 UTC (permalink / raw) Greg Lindahl wrote: > "C.Simmendinger" <chrisi@theo1.physik.uni-stuttgart.de> writes: > > > > Have you tried the -fno-emulate-complex switch discussed in the g77 > > > documentation? > > > > Yes .....internal compiler error ..... > > Apart from that: who would want to use a switch, > > If you want a commercial-quality compiler, you're looking at the wrong > place. > Hey now, Hush, Hush ;-) I was trying to improve the speed of our codes. As a byproduct i wrote a wrapper to Goto's neat sgemm/dgemm. So the zgemm/cgemm now also performs with > 700 mflops. Since the zgemv/cgemv is okayish too now (200-300 mflops), Lapack really flies, not just on real/double but also on complex . Helped our code to fly too ..... Since i'm of coz releasing this micro-patch under whatever you like, no need to get angry. I'm in fact rather pleased with egcs. I just don't seem able to understand where the factor 4-6 i mentioned is lost. Christian P.S. Still don't trust that switch. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-04 5:00 ` C.Simmendinger 1998-11-04 5:00 ` Greg Lindahl @ 1998-11-04 5:00 ` Craig Burley 1998-11-05 5:00 ` Toon Moene 2 siblings, 0 replies; 15+ messages in thread From: Craig Burley @ 1998-11-04 5:00 UTC (permalink / raw) "C.Simmendinger" <chrisi@theo.physik.uni-stuttgart.de> writes: > I just keep wondering why the performace is so > embarrassing with respect to this ? Probably because -femulate-complex is still the default option. Once the gcc/egcs back end is fixed with respect to the "native" complex type, -fno-emulate-complex option can become the default, which might lead to improvements in performance in complex-using apps. You can try the option in the meantime, and might even get lucky and avoid the code-generation bugs.... -- "Practice random senselessness and act kind of beautiful." James Craig Burley, Software Craftsperson burley@gnu.org ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-04 5:00 ` C.Simmendinger 1998-11-04 5:00 ` Greg Lindahl 1998-11-04 5:00 ` Craig Burley @ 1998-11-05 5:00 ` Toon Moene 1998-11-06 5:00 ` C.Simmendinger 1998-11-06 5:00 ` C.Simmendinger 2 siblings, 2 replies; 15+ messages in thread From: Toon Moene @ 1998-11-05 5:00 UTC (permalink / raw) "C.Simmendinger" <chrisi@theo.physik.uni-stuttgart.de> wrote: > The only thing which is sort of sad about egcs ist the absolutely poor > performance of g77 with respect to complex numbers. > I'm just trying to optimize the BLAS a bit more, i.e. just wrote > a faster cgemv/zgemv. Had to do all calculations in floats > with the corresponding conversions complex->float, float->complex. > In doing so i got a speedup of *4-6*. > I just keep wondering why the performace is so > embarrassing with respect to this ? > Since a lot of numerical stuff (e.g LAPACK) is written in fortran, > improvements on this sector would help quite a bit. The cause is not exactly known - it is related to the way complex numbers are treated in the "middle-end" of the compiler, i.e. as a (real, imag) pair. On 64-bit hosts (Alpha, MIPS-4000 and higher, UltraSPARC, etc.) a COMPLEX number is a 2x32 bits entity, which (for optimisation purposes) sometimes is treated as a single 64 bit quantity. When storing/retrieving this from memory that's not a problem - however, when trying to stuff a COMPLEX number in a 64 bit register, you're asking for trouble. The corollary of this is that for DOUBLE COMPLEX, this shouldn't be an issue. Unfortunately, although I haven't seen evidence of the contrary, I cannot proof this. HTH, -- Toon Moene (mailto:toon@moene.indiv.nluug.nl) Saturnushof 14, 3738 XG Maartensdijk, The Netherlands Phone: +31 346 214290; Fax: +31 346 214286 g77 Support: mailto:fortran@gnu.org; egcs: mailto:egcs-bugs@cygnus.com ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-05 5:00 ` Toon Moene @ 1998-11-06 5:00 ` C.Simmendinger 1998-11-06 5:00 ` C.Simmendinger 1 sibling, 0 replies; 15+ messages in thread From: C.Simmendinger @ 1998-11-06 5:00 UTC (permalink / raw) Toon Moene wrote: > The corollary of this is that for DOUBLE COMPLEX, this shouldn't be an issue. > Unfortunately, although I haven't seen evidence of the contrary, I cannot > proof this. Hehhe ;-) -fno-emulate-complex really rocks ! Beats the float/double routines now. (Auto-cache-blocking, sort of) Uhm, this makes me think it would be nice if egcs had a flag float->double, etc ;-) Cheers, Christian ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: gcc/egcs C optimization 1998-11-05 5:00 ` Toon Moene 1998-11-06 5:00 ` C.Simmendinger @ 1998-11-06 5:00 ` C.Simmendinger 1 sibling, 0 replies; 15+ messages in thread From: C.Simmendinger @ 1998-11-06 5:00 UTC (permalink / raw) Toon Moene wrote: > "C.Simmendinger" <chrisi@theo.physik.uni-stuttgart.de> wrote: > > The cause is not exactly known - it is related to the way complex numbers are > treated in the "middle-end" of the compiler, i.e. as a (real, imag) pair. On > 64-bit hosts (Alpha, MIPS-4000 and higher, UltraSPARC, etc.) a COMPLEX number > is a 2x32 bits entity, which (for optimisation purposes) sometimes is treated > as a single 64 bit quantity. When storing/retrieving this from memory that's > not a problem - however, when trying to stuff a COMPLEX number in a 64 bit > register, you're asking for trouble. > > The corollary of this is that for DOUBLE COMPLEX, this shouldn't be an issue. > Unfortunately, although I haven't seen evidence of the contrary, I cannot > proof this. > Thx ! Sounds reasonable. Moreover it seems to work ;-) Haven't tested performance yet, but will do so. Uhm, btw. ... I have a *request* concerning egcs. Think i'm speaking for a vast majority. Most fortran code these days is used on fast numbercrunchers i.e. alpha and above (cray, nec, whatever) (one reason for fortran is that it can be easily vectorized) Now to my request/suggestion: The compilers on those machines all are able to convert single-> double and the same for complex with some compiler flag. Unfortunately egcs lacks this ? Of coz you might argue that i'm just a lazy boy, but if you are dealing with some 10k lines of fortran code this becomes real work, since you also need to change constants plus all conversions kind=1->kind=2 ... This flag might then also turn off -femulate-complex ? Uhm, btw, this is just something on the wishlist ;-) Christian ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~1998-11-06 5:00 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1998-10-31 5:00 gcc/egcs C optimization Berk Sensoy 1998-11-02 5:00 ` Conrad Sanderson 1998-11-02 5:00 ` Murx 1998-11-03 5:00 ` Adam C. Powell, IV 1998-11-03 5:00 ` Greg Lindahl 1998-11-04 5:00 ` Steven G. Johnson 1998-11-04 5:00 ` C.Simmendinger 1998-11-04 5:00 ` Greg Lindahl 1998-11-05 5:00 ` C.Simmendinger 1998-11-05 5:00 ` Greg Lindahl 1998-11-05 5:00 ` C.Simmendinger 1998-11-04 5:00 ` Craig Burley 1998-11-05 5:00 ` Toon Moene 1998-11-06 5:00 ` C.Simmendinger 1998-11-06 5:00 ` C.Simmendinger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox