Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-performance
Navigation:
Lists: gentoo-performance: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-performance@g.o
From: Ervin NĂ©meth <ervin.nemeth@...>
Subject: Re: best Gcc compilzation flags
Date: Mon, 29 Nov 2004 22:34:22 +0100
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

Replies:
Re: best Gcc compilzation flags
-- Patrick Audley
References:
best Gcc compilzation flags
-- Server Tuneup mission
Re: best Gcc compilzation flags
-- Matthew Groote-Kirsch
Re: best Gcc compilzation flags
-- Server Tuneup mission
Re: best Gcc compilzation flags
-- Uwe Thiem
Navigation:
Lists: gentoo-performance: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: best Gcc compilzation flags
Next by thread:
Re: best Gcc compilzation flags
Previous by date:
Re: best Gcc compilzation flags
Next by date:
Re: best Gcc compilzation flags


Updated Jun 17, 2009

Summary: Archive of the gentoo-performance mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.