Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Oct 2000 03:08:24 -0600
From:      Chris Wasser <cwasser@v-wave.com>
To:        freebsd-questions@FreeBSD.ORG
Subject:   FreeBSD & GCC Optimizations & Other Suchness..
Message-ID:  <20001028030824.A36767@area51.v-wave.com>

next in thread | raw e-mail | index | archive | help
Now I'm fully aware of the ramifications of doing this, however I'm
one of those guys who says, "let's go for it" so here I am. My problem
is I can't quite understand what the manpage is making out on this:

http://gcc.gnu.org/onlinedocs/gcc_2.html#SEC34 is my reference.

"Attempt to keep the stack boundary aligned to a 2 raised to num byte
boundary. If `-mpreferred-stack-boundary' is not specified, the default
is 4 (16 bytes or 128 bits). The stack is required to be aligned on a 4
byte boundary. On Pentium and PentiumPro, double and long double values
should be aligned to an 8 byte boundary (see `-malign-double') or suffer
significant run time performance penalties. On Pentium III, the Streaming
SIMD Extension (SSE) data type __m128 suffers similar penalties if it is
not 16 byte aligned."

A little further up it states (in the -malign descriptions):

"Align the start of functions to a 2 raised to num byte boundary. If
`-malign-functions' is not specified, the default is 2 if optimizing
for a 386, and 4 if optimizing for a 486."

If I understand this correctly, PII's should have the stack aligned
to 8 bytes (2^3) and PIII's should be aligned to 16 bytes (2^4), the
kernel compile is set to the default "preferred" alignment of 2.

However, what about the -malign functions? PII/PIII according to the
manpage state that -malign-double should be invoked for preformance
reasons, but what about the actual values for the -malign directives:

2 = 386
4 = 486

What about 686+ ? (Such as PII/PIII/Athlon), using this information
I came up with:

-O3 -mpentiumpro -march=pentiumpro -malign-double -malign-loops=3
-malign-jumps=3 -malign-functions=3 -mpreferred-stack-boundary=3

Assuming that GCC takes the =3 as 2^3 = 8 Bytes for PII, or =4 as
2^4 for 16 bytes for PIII. Is this correct? (Both for the align
directives and the stack-boundary)

My basic question is for PII, PIII and Athlon optimization strings
(and yes, I'm aware it may break code) what should I be using? I'm
just sticking to these functions as I've had bad things happen to
me by going too far in the optimizations (-fomit-frame-pointer, etc)
and figured I'd try to get some input before I get too brave and
strike out on my own :)

Also, while I was searching the Net for information on this, I
stumbled across a Linux kernel diff containing MMX and KNI patches
as well as other Celeron/PII/PIII optimizations, is FreeBSD
equipped with these yet? Such as:

- Disable PII/PIII Serial Number at bootup
+  This makes the kernel disable the CPUID serial number that is
+  embedded on the new PIII CPUs at bootup.

- Enable PII/PIII Extended Fast FPU save and restore support
+  This enables use of the new PII/PIII FXSAVE/FXRSTOR support. This
+  item is required to make use of the new PIII 128bit XMM registers.
+  It is safe to leave this enabled all the time.

- Enable CPU Specific (MMX/MMX2) Optimizations
+  This enables use of the MMX registers and 128bit MMX2 registers
+  on CPUs that can support the new instructions (Pentium/AMD K6 or
+  newer). In order to support the Pentium III 128 bit XMM registers
+  you must enable both this and PII/PIII Extended Fast FPU save
+  support. It is safe to leave this enabled all the time.

(Also, should be noted that the agp device [device agp] for the
kernel config is not listed in LINT -- found it by browsing
the mailinglists)

I'm getting sidetracked here :) Any input on this would be greatly
appriciated. If possible, please CC a reply to my email address
(so I won't miss it in the flurry of messages that is the FreeBSD
mailinglist(s) :))


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001028030824.A36767>