public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Optimise a build for floating point operation
@ 2003-02-05 10:13 Øystein O Johansen
  2003-02-05 13:13 ` John Love-Jensen
  0 siblings, 1 reply; 7+ messages in thread
From: Øystein O Johansen @ 2003-02-05 10:13 UTC (permalink / raw)
  To: gcc-help

Hi,

I got a program [*] code that makes mostly floating point operations
(written in C and C++). I know this program will run on a Windows 2000
Intel pentium 4 machine. The program is time critical, and I really want to
make it run as fast as possible. Which parameters and options should I send
to gcc when compiling and linking? I'm using mingw 2.0 with gcc 3.2.

gcc --version
gcc (GCC) 3.2 (mingw special 20020817-1)

I'm willing to update the compiler if that will increase the execution
performance of the binary.

-Øystein

[*] It's a neural net based backgammon evaluation program based on GNU
Backgammon

-------------------------------------------------------------------
The information contained in this message may be CONFIDENTIAL and is
intended for the addressee only. Any unauthorised use, dissemination of the
information or copying of this message is prohibited. If you are not the
addressee, please notify the sender immediately by return e-mail and delete
this message.
Thank you.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Optimise a build for floating point operation
  2003-02-05 10:13 Optimise a build for floating point operation Øystein O Johansen
@ 2003-02-05 13:13 ` John Love-Jensen
  0 siblings, 0 replies; 7+ messages in thread
From: John Love-Jensen @ 2003-02-05 13:13 UTC (permalink / raw)
  To: Øystein O Johansen, gcc-help

Hi Øystein,

You'll want to profile your executable, and then consider ways to optimize
the routines that show up as the biggest performance bottlenecks.

--Eljay

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Optimise a build for floating point operation
  2003-02-06  9:51 Øystein O Johansen
@ 2003-02-06 12:48 ` John Love-Jensen
  0 siblings, 0 replies; 7+ messages in thread
From: John Love-Jensen @ 2003-02-06 12:48 UTC (permalink / raw)
  To: Øystein O Johansen; +Cc: gcc-help

Hi Øystein,

>Does that means the -malign-double won't help me?

Yes, -malign-double won't help you if you are using floats and not using
doubles.

> I'm now using:
> -O3 -march=pentium-mmx -mcpu=pentium-mmx -msse -mfpmath=sse -mno-ieee-fp
> -ffast-math
> 
> Does this sound like a smart setting?

I'd drop the mmx parts.  And, if appropriate, put in the sse2 flag.

Otherwise, yes, sounds like smart settings for your project's purposes.

Sincerely,
--Eljay

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Optimise a build for floating point operation
@ 2003-02-06  9:51 Øystein O Johansen
  2003-02-06 12:48 ` John Love-Jensen
  0 siblings, 1 reply; 7+ messages in thread
From: Øystein O Johansen @ 2003-02-06  9:51 UTC (permalink / raw)
  To: John Love-Jensen <eljay; +Cc: gcc-help


Thanks,
The program does not use double, but float. Does that means the
-malign-double won't help me?

I'm now using:
-O3 -march=pentium-mmx -mcpu=pentium-mmx -msse -mfpmath=sse -mno-ieee-fp
-ffast-math

Does this sound like a smart setting?

-Øystein


-------------------------------------------------------------------
The information contained in this message may be CONFIDENTIAL and is
intended for the addressee only. Any unauthorised use, dissemination of the
information or copying of this message is prohibited. If you are not the
addressee, please notify the sender immediately by return e-mail and delete
this message.
Thank you.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Optimise a build for floating point operation
  2003-02-05 14:20 ` John Love-Jensen
@ 2003-02-06  7:29   ` Segher Boessenkool
  0 siblings, 0 replies; 7+ messages in thread
From: Segher Boessenkool @ 2003-02-06  7:29 UTC (permalink / raw)
  To: John Love-Jensen; +Cc: Øystein O Johansen, gcc-help

John Love-Jensen wrote:
> Hi Øystein,

> If IEEE 754 compliance doesn't matter to you, you could get a little more
> performance out of -mno-ieee-fp.

With similar warnings, -ffast-math can help too.


Segher


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Optimise a build for floating point operation
  2003-02-05 13:50 Øystein O Johansen
@ 2003-02-05 14:20 ` John Love-Jensen
  2003-02-06  7:29   ` Segher Boessenkool
  0 siblings, 1 reply; 7+ messages in thread
From: John Love-Jensen @ 2003-02-05 14:20 UTC (permalink / raw)
  To: Øystein O Johansen; +Cc: gcc-help

Hi Øystein,

>Should I add -mfpa ? (What does it do?)

-mfpa enables the Sun FPA instructions for floating point.  q.v.
<http://gcc.gnu.org/onlinedocs/gcc/Option-Index.html>.

>what about -mnumeric?

For the Intel 960, that indicates that floating point is supported in
hardware.  The inverse, -msoft-float, indicates that floating-point should
not be assumed (thus, adds overhead for Intel 960 systems that have floating
point support).

>Will that help the performance?

Only if you are running on Intel 960 CPU.

>What about -mfpmath, -mmmx and -msse? What's that?

These are for Intel 80x86 CPUs.

The -mmmx enables the MMX instructions on the appropriate MMX capable Intel
CPUs.  MMX has nothing to do with floating point, and since the MMX
instructions puts the CPU in a different state from FP (MMX mode, or FP
mode), it can impede performance of a heavily floating-point based
application.  Darn modal CPU.

The -mfpmath=sse is probably what you want (I'm not sure if that entails
-msse, or requires -msse).  I'd avoid MMX.

You may want to use -msse2.  See the above mentioned online documentation.

If IEEE 754 compliance doesn't matter to you, you could get a little more
performance out of -mno-ieee-fp.

You'll probably want -align-double, which makes your program's memory
footprint larger, but floating point can be a little faster.  I assume you
are using doubles.  (Or are you using long double?)

There are other optimizations for Athlon and 3Dnow instructions, if that's
the hardware you run on.

--Eljay

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Optimise a build for floating point operation
@ 2003-02-05 13:50 Øystein O Johansen
  2003-02-05 14:20 ` John Love-Jensen
  0 siblings, 1 reply; 7+ messages in thread
From: Øystein O Johansen @ 2003-02-05 13:50 UTC (permalink / raw)
  To: John Love-Jensen <eljay; +Cc: gcc-help


Hi, and thanks for your answer.

The code is pretty much profiled and __inline__ed and whatever optimised.
What I was looking for was hints for the compile options to use. Should I
add -mfpa ? (What does it do?) or what about -mnumeric? Will that help the
performance? What about -mfpmath, -mmmx and -msse? What's that?

I'm trying '-O3' versus '-O3 -march=pentium-mmx -mcpu=pentium-mmx -mmmx
-msse -mfpmath=sse'

Is there some other switches I can toggle to increaste the performance of
floating point operation?

Clueless,
-Øystein



-------------------------------------------------------------------
The information contained in this message may be CONFIDENTIAL and is
intended for the addressee only. Any unauthorised use, dissemination of the
information or copying of this message is prohibited. If you are not the
addressee, please notify the sender immediately by return e-mail and delete
this message.
Thank you.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-02-06 12:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-05 10:13 Optimise a build for floating point operation Øystein O Johansen
2003-02-05 13:13 ` John Love-Jensen
2003-02-05 13:50 Øystein O Johansen
2003-02-05 14:20 ` John Love-Jensen
2003-02-06  7:29   ` Segher Boessenkool
2003-02-06  9:51 Øystein O Johansen
2003-02-06 12:48 ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).