Gentoo Archives: gentoo-performance

From: "Ervin Németh" <ervin.nemeth@××××.hu>
To: gentoo-performance@l.g.o
Subject: Re: [gentoo-performance] best Gcc compilzation flags
Date: Mon, 29 Nov 2004 21:34:38
In Reply to: Re: [gentoo-performance] best Gcc compilzation flags by Uwe Thiem
Uwe Thiem wrote:
> -funroll-loops isn't that good an idea because an unrolled loop might the > cache.
All this started with Artur Grabowski's mail. And now everybody is repeating his idea. No, loop unrolling is not evil. Neither are inline functions. The following loop: do i=1,n sum=a(i) enddo is unrolled like do i=1,n,4 sum0=a(i) sum1=a(i+1) sum2=a(i+2) sum3=a(i+3) enddo sum=sum0+sum1+sum2+sum3 Some modulo logic must be added and I also omitted the after-loop cleanup. The gain is less frequent loop index variable comparison (and so a conditional jump), more register usage, less memory operations in more complex, nested loops, and a code which allows the scheduler to make more aggressive optimization in the code structure. And it also opens possibilities to other optimizations. All this compared to the increased instruction cache usage. And keep in mind that every program spends most of its runtime in loops. This was the theory. Practice shows that the optimizer in gcc was very weak before 3.4, and sill depends the efficiency of the scheduler. But remember: however good all this sounds, there are always programs where one or more optimization fails - there is no magic switch for a general, best performance. /Ervin -- gentoo-performance@g.o mailing list


Subject Author
Re: [gentoo-performance] best Gcc compilzation flags Patrick Audley <paudley@××××××××.ca>