You are not logged in.

#1 2003-11-10 01:36:48

vande198
Member
From: East Lansing, MI, USA
Registered: 2003-09-12
Posts: 98

Optimization Flags

According to this article (http://articles.linmagau.org/modules.ph … 437&page=1) it seems that this would probably the best CFLAG line for a pentium4:  -march=pentium4 -O2 -pipe -fomit-frame-pointer -falign-functions=4 -mmmx -msse -msse2 -mfpmath=sse,387

What's your take on this?  What flags do you use?


"To be a Spartan is to be a philosopher much more than to be an athlete."
Plato, the <i>Protagoras</i>, 342e-343a

Offline

#2 2003-11-10 03:06:45

sarah31
Member
From: Middle of Canada
Registered: 2002-08-20
Posts: 2,975
Website

Re: Optimization Flags

i suppose you can use them but in all honesty i have run both highly optimized and conservative (in arch i only use the default CFLAGS) and noticed ANY performance differences. in fact when i used highly optimed flags stability lacked.

but personally i don't see anything wrong with those flags.


AKA uknowme

I am not your friend

Offline

#3 2003-11-10 04:10:10

sud_crow
Member
From: Argentina
Registered: 2003-06-30
Posts: 545

Re: Optimization Flags

vande198 wrote:

According to this article (http://articles.linmagau.org/modules.ph … 437&page=1) it seems that this would probably the best CFLAG line for a pentium4:  -march=pentium4 -O2 -pipe -fomit-frame-pointer -falign-functions=4 -mmmx -msse -msse2 -mfpmath=sse,387

What's your take on this?  What flags do you use?

Well, as Sarah i dont have any "custom flageg" in my Arch system, but in my Linux From Scratch (soon trying 5.0 wink) i got everything --or almost smile-- working with this:

export CFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer -mmmx -msse -mfpmath=sse,387"
export CXXFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer -mmmx -msse -mfpmath=sse,387"

As you see, i have a P3, once in a while i had to turn off the -fomit-frame-pointer one couse it wouldnt compile, but just from time to time.

Any way, my LFS runs pretty stable, except for some of the devel pkgs (as the latest Fluxbox or such) but all in all, works quite good.
About the performance, i DID notice a good improvement, but this came as a result of the optimizations and being an LFS i assume.
It wont change your life thats for sure, but i enjoy the faster response i get.


Leonardo Andrés Gallego
www.archlinux-es.org || Comunidad Hispana de Arch Linux

Offline

#4 2003-11-10 05:34:56

sarah31
Member
From: Middle of Canada
Registered: 2002-08-20
Posts: 2,975
Website

Re: Optimization Flags

i would recommend sticking with the -O2. -O3 is fine but some packages may not function as well or be a little larger than planned. from everything i have learned -O2 maybe conservative but be your best bet for a system that is optimized with less problems.

that being said i do know lots of people that get by just fine with -O3 and lots more optimizations than you inquired about.


AKA uknowme

I am not your friend

Offline

#5 2003-11-10 05:40:58

vande198
Member
From: East Lansing, MI, USA
Registered: 2003-09-12
Posts: 98

Re: Optimization Flags

According to this article:  http://articles.linmagau.org/modules.ph … 448&page=1 -O3 seems to be slightly slower than -O2 w/ the gcc at this time anyway.


"To be a Spartan is to be a philosopher much more than to be an athlete."
Plato, the <i>Protagoras</i>, 342e-343a

Offline

#6 2003-11-10 07:08:48

sud_crow
Member
From: Argentina
Registered: 2003-06-30
Posts: 545

Re: Optimization Flags

Yes that seems....

Well, those where my flags for my LFS 4.1, and thats quite old now...

Anyway, those things (reviews and tests) may vary depending on your system, and -03 is supposed to be better than -02 but, as always, one never know until it tryes!!!

One thing is for sure, you will make me recompile LFS 5 becouse of this. :evil:

8)


Leonardo Andrés Gallego
www.archlinux-es.org || Comunidad Hispana de Arch Linux

Offline

#7 2003-11-10 20:03:57

vande198
Member
From: East Lansing, MI, USA
Registered: 2003-09-12
Posts: 98

Re: Optimization Flags

sorry about that....ever since seeing those articles I've been bit by bit recompiling my whole arch system.


"To be a Spartan is to be a philosopher much more than to be an athlete."
Plato, the <i>Protagoras</i>, 342e-343a

Offline

#8 2004-07-28 06:44:40

Mindaugas
Member
From: Ireland
Registered: 2004-03-25
Posts: 95

Re: Optimization Flags

How to optimize for Pentium4?
What need in /etc/makepkg.conf ?

Now is: #
# /etc/makepkg.conf
#
export CARCH="i686"
export CHOST="i686-pc-linux-gnu"

export CFLAGS="-march=pentium4 -O3 -pipe"
export CXXFLAGS="-march=pentium4 -O3 -pipe"

Offline

#9 2004-07-28 11:27:46

Abaddon
Member
From: Poland
Registered: 2004-05-03
Posts: 232

Re: Optimization Flags

Duron 800 mhz smile

export CFLAGS="-Os -march=athlon-tbird -mtune=athlon-tbird -pipe -fomit-frame-pointer -funroll-loops -ffast-math -mmmx -m3dnow -fmove-all-movables -s -DNDEBUG -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
export CXXFLAGS="-Os -march=athlon-tbird -mtune=athlon-tbird -pipe -funroll-loops -ffast-math -mmmx -m3dnow -fmove-all-movables -s -DNDEBUG -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"

Gnome - The weakest link!
Linux, *not* GNU/Linux!

Offline

#10 2004-07-28 11:35:53

Fox
Member
Registered: 2004-07-28
Posts: 124

Re: Optimization Flags

Disabling features is maybe somtimes fast, but if you disable checking features I wouldn't wonder if you get some kernel panic if you compile kernel modules.

Offline

#11 2004-07-28 23:40:04

jlvsimoes
Member
From: portugal
Registered: 2002-12-23
Posts: 392
Website

Re: Optimization Flags

#!/bin/sh

# Author: pixelbeat

#This script is Linux specific
#It should work on any gcc >= 2.95 at least

#these apply to any arch (just here for reference)
unsafe_math_opts="-ffast-math -fno-math-errno -funsafe-math-optimizations -fno-trapping-math"

gcc_version=`gcc -dumpversion | sed 's/([0-9]{1,}.[0-9]{1,}).*([0-9]{1,}){0,1}/12/'`

IFS=":"
while read name value; do
    unset IFS
    name=`echo $name`
    value=`echo $value`
    IFS=":"
    if [ "$name" == "vendor_id" ]; then
        vendor_id="$value"
    elif [ "$name" == "cpu family" ]; then
        cpu_family="$value"
    elif [ "$name" == "model" ]; then
        cpu_model="$value"
    elif [ "$name" == "flags" ]; then
        flags="$value"
    fi
done < /proc/cpuinfo
unset IFS
if [ "$vendor_id" == "AuthenticAMD" ]; then
    if [ "$cpu_family" == "4" ]; then
        _CFLAGS="$_CFLAGS -march=i486"
    elif [ "$cpu_family" == "5" ]; then
        if [ "$cpu_model" -lt "4" ]; then
            _CFLAGS="$_CFLAGS -march=pentium"
        elif [ "$cpu_model" == "6" ] || [ "$cpu_model" == "7" ]; then
            _CFLAGS="$_CFLAGS -march=k6"
        elif [ "$cpu_model" == "8" ] || [ "$cpu_model" == "12" ]; then
            if expr $gcc_version '>=' 3.1 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=k6-2"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        elif [ "$cpu_model" == "9" ] || [ "$cpu_model" == "13" ]; then
            if expr $gcc_version '>=' 3.1 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=k6-3"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        fi
    elif [ "$cpu_family" == "6" ]; then
        if [ "$cpu_model" -le "3" ]; then
            if expr $gcc_version '>=' 3.0 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        elif [ "$cpu_model" == "4" ]; then
            if expr $gcc_version '>=' 3.1 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon-tbird"
            elif expr $gcc_version '>=' 3.0 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        elif [ "$cpu_model" -ge "6" ]; then #athlon-{4,xp,mp}
            if expr $gcc_version '>=' 3.1 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon-xp"
            elif expr $gcc_version '>=' 3.0 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        fi
    fielse #everything else "GenuineIntel"
    if [ "$cpu_family" == "3" ]; then
        _CFLAGS="$_CFLAGS -march=i386"
    elif [ "$cpu_family" == "4" ]; then
        _CFLAGS="$_CFLAGS -march=i486"
    elif [ "$cpu_family" == "5" ] && expr $gcc_version '<' 3.1 >/dev/null; then
        _CFLAGS="$_CFLAGS -march=pentium"
    elif [ "$cpu_family" -ge "6" ] && expr $gcc_version '<' 3.1 >/dev/null; then
        _CFLAGS="$_CFLAGS -march=pentiumpro"
    elif [ "$cpu_family" == "5" ]; then
        if [ "$cpu_model" != "4" ]; then
            _CFLAGS="$_CFLAGS -march=pentium"
        else
            _CFLAGS="$_CFLAGS -march=pentium-mmx" #No overlap with other vendors
        fi
    elif [ "$cpu_family" == "6" ]; then
        if echo "$flags" | grep -vq cmov; then #gcc incorrectly assumes i686 always has cmov
            _CFLAGS="$_CFLAGS -march=pentium -mcpu=pentiumpro" #VIA CPUs exhibit this
        else
            if [ "$cpu_model" == "0" ] || [ "$cpu_model" == "1" ]; then
                _CFLAGS="$_CFLAGS -march=pentiumpro"
            elif [ "$cpu_model" -ge "3" ] && [ "$cpu_model" -le "6" ]; then #4=TM5600 at least
                _CFLAGS="$_CFLAGS -march=pentium2"
            elif [ "$cpu_model" -ge "7" ] && [ "$cpu_model" -le "11" ]; then #9 invalid
                _CFLAGS="$_CFLAGS -march=pentium3"
            fi
        fi
    elif [ "$cpu_family" == "15" ]; then
        _CFLAGS="$_CFLAGS -march=pentium4"
    fi
fi

if expr $gcc_version '>=' 3.1 >/dev/null; then
    if echo "$flags" | grep -q sse2; then
        _CFLAGS="$_CFLAGS -mfpmath=sse -msse2"
    elif echo "$flags" | grep -q sse; then
        _CFLAGS="$_CFLAGS -mfpmath=sse -msse"
    fi
    if echo "$flags" | grep -q mmx; then
        _CFLAGS="$_CFLAGS -mmmx"
    fi
    if echo "$flags" | grep -q 3dnow; then
        _CFLAGS="$_CFLAGS -m3dnow"
    fi
fi

echo "$_CFLAGS"


-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GU/ d- s: a- C L U P+ L+++ E--- W+
N 0+ K- W-- !O !M V-- PS+ PE- V++ PGP T 5 Z+ R* TV+ B+
DI-- D- G-- e-- h! r++ z+ z*
------END GEEK CODE BLOCK------

Offline

#12 2004-07-29 00:18:20

dp
Member
From: Zürich, Switzerland
Registered: 2003-05-27
Posts: 3,363
Website

Re: Optimization Flags

jlvsimoes wrote:

    fielse #everything else "GenuineIntel"

has a litttle typo ... fi else

if anybody wants to try it, use this:

#!/bin/sh

# Author: pixelbeat

#This script is Linux specific
#It should work on any gcc >= 2.95 at least

#these apply to any arch (just here for reference)
unsafe_math_opts="-ffast-math -fno-math-errno -funsafe-math-optimizations -fno-trapping-math"

gcc_version=`gcc -dumpversion | sed 's/([0-9]{1,}.[0-9]{1,}).*([0-9]{1,}){0,1}/12/'`

IFS=":"
while read name value; do
    unset IFS
    name=`echo $name`
    value=`echo $value`
    IFS=":"
    if [ "$name" == "vendor_id" ]; then
        vendor_id="$value"
    elif [ "$name" == "cpu family" ]; then
        cpu_family="$value"
    elif [ "$name" == "model" ]; then
        cpu_model="$value"
    elif [ "$name" == "flags" ]; then
        flags="$value"
    fi
done < /proc/cpuinfo
unset IFS
if [ "$vendor_id" == "AuthenticAMD" ]; then
    if [ "$cpu_family" == "4" ]; then
        _CFLAGS="$_CFLAGS -march=i486"
    elif [ "$cpu_family" == "5" ]; then
        if [ "$cpu_model" -lt "4" ]; then
            _CFLAGS="$_CFLAGS -march=pentium"
        elif [ "$cpu_model" == "6" ] || [ "$cpu_model" == "7" ]; then
            _CFLAGS="$_CFLAGS -march=k6"
        elif [ "$cpu_model" == "8" ] || [ "$cpu_model" == "12" ]; then
            if expr $gcc_version '>=' 3.1 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=k6-2"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        elif [ "$cpu_model" == "9" ] || [ "$cpu_model" == "13" ]; then
            if expr $gcc_version '>=' 3.1 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=k6-3"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        fi
    elif [ "$cpu_family" == "6" ]; then
        if [ "$cpu_model" -le "3" ]; then
            if expr $gcc_version '>=' 3.0 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        elif [ "$cpu_model" == "4" ]; then
            if expr $gcc_version '>=' 3.1 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon-tbird"
            elif expr $gcc_version '>=' 3.0 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        elif [ "$cpu_model" -ge "6" ]; then #athlon-{4,xp,mp}
            if expr $gcc_version '>=' 3.1 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon-xp"
            elif expr $gcc_version '>=' 3.0 >/dev/null; then
                _CFLAGS="$_CFLAGS -march=athlon"
            else
                _CFLAGS="$_CFLAGS -march=k6"
            fi
        fi
    fi
else #everything else "GenuineIntel"
    if [ "$cpu_family" == "3" ]; then
        _CFLAGS="$_CFLAGS -march=i386"
    elif [ "$cpu_family" == "4" ]; then
        _CFLAGS="$_CFLAGS -march=i486"
    elif [ "$cpu_family" == "5" ] && expr $gcc_version '<' 3.1 >/dev/null; then
        _CFLAGS="$_CFLAGS -march=pentium"
    elif [ "$cpu_family" -ge "6" ] && expr $gcc_version '<' 3.1 >/dev/null; then
        _CFLAGS="$_CFLAGS -march=pentiumpro"
    elif [ "$cpu_family" == "5" ]; then
        if [ "$cpu_model" != "4" ]; then
            _CFLAGS="$_CFLAGS -march=pentium"
        else
            _CFLAGS="$_CFLAGS -march=pentium-mmx" #No overlap with other vendors
        fi
    elif [ "$cpu_family" == "6" ]; then
        if echo "$flags" | grep -vq cmov; then #gcc incorrectly assumes i686 always has cmov
            _CFLAGS="$_CFLAGS -march=pentium -mcpu=pentiumpro" #VIA CPUs exhibit this
        else
            if [ "$cpu_model" == "0" ] || [ "$cpu_model" == "1" ]; then
                _CFLAGS="$_CFLAGS -march=pentiumpro"
            elif [ "$cpu_model" -ge "3" ] && [ "$cpu_model" -le "6" ]; then #4=TM5600 at least 
                _CFLAGS="$_CFLAGS -march=pentium2"
            elif [ "$cpu_model" -ge "7" ] && [ "$cpu_model" -le "11" ]; then #9 invalid
                _CFLAGS="$_CFLAGS -march=pentium3"
            fi
        fi
    elif [ "$cpu_family" == "15" ]; then
        _CFLAGS="$_CFLAGS -march=pentium4"
    fi
fi

if expr $gcc_version '>=' 3.1 >/dev/null; then
    if echo "$flags" | grep -q sse2; then
        _CFLAGS="$_CFLAGS -mfpmath=sse -msse2"
    elif echo "$flags" | grep -q sse; then
        _CFLAGS="$_CFLAGS -mfpmath=sse -msse"
    fi
    if echo "$flags" | grep -q mmx; then
        _CFLAGS="$_CFLAGS -mmmx"
    fi
    if echo "$flags" | grep -q 3dnow; then
        _CFLAGS="$_CFLAGS -m3dnow"
    fi
fi

echo "$_CFLAGS"

The impossible missions are the only ones which succeed.

Offline

#13 2004-07-29 00:22:42

dp
Member
From: Zürich, Switzerland
Registered: 2003-05-27
Posts: 3,363
Website

Re: Optimization Flags

having a

[damir@Asteraceae damir]$ more /proc/cpuinfo | grep model
model           : 2
model name      : Mobile Intel(R) Pentium(R) 4 - M CPU 2.00GHz

it says this

[damir@Asteraceae damir]$ ./whatflag.sh 
 -march=pentium4 -mfpmath=sse -msse2 -mmmx

what i will for sure try when i manage to have enough resources (harddiskspace, compiletime) to have an own repo for the pkgs for arrch fo -march=pentium4


The impossible missions are the only ones which succeed.

Offline

#14 2004-07-29 18:32:52

jlvsimoes
Member
From: portugal
Registered: 2002-12-23
Posts: 392
Website

Re: Optimization Flags

ifelse if else copy paste error DP sorry


-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GU/ d- s: a- C L U P+ L+++ E--- W+
N 0+ K- W-- !O !M V-- PS+ PE- V++ PGP T 5 Z+ R* TV+ B+
DI-- D- G-- e-- h! r++ z+ z*
------END GEEK CODE BLOCK------

Offline

Board footer

Powered by FluxBB