# AMD X2 applicable CFLAGS

## Vortigern

Hi everybody,

I've just bought my new AMD X2 5200+ 1Mb+1MB L2 cache, and I'm wondering what CFLAGS to use.

```

CHOST="x86_64-pc-linux-gnu"

CFLAGS="-march=athlon64 -O2 -pipe"

CXXFLAGS="${CFLAGS}"
```

Well the lines above are just a starting point, I would like to add to them other optimization for my machine.

Since I will install Gentoo from stage 1 (don't bother with stage 3 worth etc.: I will compile from stage 1) I would like to know how to squeeze as much juice as possible from my system!

-So, suggest me any CFLAGS and CXXFLAGS (I can also use CXXFLAGS different from CFLAGS if needed).

-Tell me if there is other CHOST usable (not i686-pc-linux-gnu or similar that will make my PC using 32bit).

-Tell me if I will take advantages from -falign-functions=64 (remeber that I have a 1+1MB of cache (1MB for each processor)) and from -mfpmath=sse,387 (is this last one still buggy?)

Thanks in advance!

P.S.

Last and secondary question, how can I benchmark the compile time with different MAKEOPTS without having to "compile and measure time"?

Has anyone tried -j4 or more?

P.P.S.

May I add sse, 3dnow etc. CFLAGS?

Which CPU instruction may I add? (I cannot check /proc/cpuinfo/ right now, but I can do it before compiling, so just suggest which one are suitable)

----------

## V-Man

The best place to start with CFLAGS/CHOST/etc is over at http://gentoo-wiki.com/Safe_Cflags.

Somebody with your processor can probably help with the rest.

----------

## Vortigern

Well, I have taken the falgs posted above from that page!

Then I posted here to have other help!

P.S.

-falign-functions=64 and -mfpmath=sse,387 come from http://gentoo-wiki.com/CFLAGS_matrix

----------

## V-Man

 *Vortigern wrote:*   

> Well, I have taken the falgs posted above from that page!

 

Sorry, I missed in your original post where you said you had already been to the wiki.

----------

## AaronPPC

 *Vortigern wrote:*   

> I've just bought my new AMD X2 5200+ 1Mb+1MB L2 cache, and I'm wondering what CFLAGS to use.

 

Congratulations!  You must have bought one of the last 1M/core L2 cache models.

 *Vortigern wrote:*   

> 
> 
> ```
> CFLAGS="-march=athlon64 -O2 -pipe"
> ```
> ...

 

I kept it simple and used:

```
CFLAGS="-march=k8 -msse3 -O2 -pipe"
```

 *Quote:*   

> May I add sse, 3dnow etc. CFLAGS?

 

As you can see, I added sse3.  The other sse's and 3dnow stuff is implied by CHOST.

----------

## Vortigern

Dear AaronPPC,

thanks for answering!

About 1MB+1MB I've chosen it, it's not by chance  :Very Happy:  (otherwise I hadn't asked for -falign-functions=64 that is detrimental on processors with smaller cache sizes, such as the Athlon XP (512k L2 cache)). Do you think it to be the best choice? or this model just a little bit more powerful than X2 with L2 512KB?

I read here: http://gentoo-wiki.com/CFLAGS_matrix that msse3 shouldn't be enabled in make.conf, and only used for compiling mesa drivers.

About -march=k8, which are the differences between it and athlon64?

----------

## AaronPPC

 *Quote:*   

> Do you think it to be the best choice? or this model just a little bit more powerful than X2 with L2 512KB?

 

AMD discontinued 1MB cache Athlons because the price of manufacture exceeds the performance gain.  I also saw benchmarks that support that argument.  However, I chose the X2 4800+ over the 4600+ because 1MB/core cache has to be better than 512K.  I actually was ready to settle for the 4600 when Newegg got their hands on some 4800s last fall.

 *Quote:*   

> I read here: http://gentoo-wiki.com/CFLAGS_matrix that msse3 shouldn't be enabled in make.conf, and only used for compiling mesa drivers.

 

Actually it only talks about -msse -mmmx -m3dnow.  This is from the safe CFLAG wiki:

 *Quote:*   

> If you have a newer Athlon64("Venice" or "San Diego")/Athlon64-X2("Manchester" or "Toledo") (check for pni in cat /proc/cpuinfo) you can also add -msse3 to your CFLAGS to enable SSE3 support. Any chip using the 90nm process except for the "Winchester" class Athlon64 supports SSE3.

 

 *Quote:*   

> About -march=k8, which are the differences between it and athlon64?

 

I like to know the difference myself.  After looking at the safe CFLAGS again, it says athlon64 for 64-bit X2, but k8 for 64-bit single-core Athlons.

----------

## Vortigern

Thanks for answering,

I've read the flags, so I asked why you suggested me to use k8 instead of athlon64! So, at the end, should I use -march=k8 or -march=athlon64?

Any other CXXFLAGS or CFLAGS to suggest?

Any news about -falign-functions=64? Did you tried tis last one?

About MAKEOPTS? Have you done any benchmark?

----------

## AaronPPC

 *Quote:*   

> So, at the end, should I use -march=k8 or -march=athlon64?

 

I'll leave that to someone more qualified than me to answer.  My guess is they are pretty much the same.  Either one will work.

 *Quote:*   

> Any other CXXFLAGS or CFLAGS to suggest?

 

The general wisdom around these forums is simple is best.

 *Quote:*   

> Any news about -falign-functions=64?

 

I never tried it.

 *Quote:*   

> About MAKEOPTS?

 

I use -j3.  I know of people that have gone -j4 and beyond.  It's easy to experiment with it.  The worst that will happen is a compiler crash.

 *Quote:*   

> Have you done any benchmark?

 

Nothing beyond noticing that my new computer is oodles faster than my old G4.   :Smile: 

----------

## Vortigern

Well, about  *Quote:*   

> I use -j3. I know of people that have gone -j4 and beyond. It's easy to experiment with it. The worst that will happen is a compiler crash. 

  there will be not be any compiler crashes! It can only happen that a bigger compile time will occur! I've tried also -j4 with my single core, but the compiling process was about the same! About the new one I was asking because not always jx with x as number of processors +1 is the better choice, and I was wondering if there are any programs that can make benchmark with several -jx options, so I can choose the fastest and gain time during the compiling process!

About the rest I'm waiting as you do, AaronPPC, for someone more qualified to answer!

----------

