Re: [HACKERS] Sun performance - Major discovery!

From: Marko Karppinen <marko(at)karppinen(dot)fi>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Sun performance - Major discovery!
Date: 2003-10-11 17:46:40
Message-ID: DEDF8FE1-FC12-11D7-81B6-000A958D89B8@karppinen.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

On 8.10.2003, at 21:31, Bruce Momjian wrote:
> Well, this is really embarassing. I can't imagine why we would not set
> at least -O on all platforms. Looking at the template files, I see
> these have no optimization set:
>
> darwin

Regarding Darwin optimizations, Apple has introduced a "-fast" flag in
their GCC 3.3 version that they recommend when compiling code for their
new G5 systems. Because of this, I foresee a lot of people defining
CFLAGS="-fast" on their systems.

This is problematic for PostgreSQL, however, since the -fast flag is
the equivalent of:

-O3 -falign-loops-max-skip=15 -falign-jumps-max-skip=15
-falign-loops=16 -falign-jumps=16 -falign-functions=16 -malign-natural
-ffast-math -fstrict-aliasing -frelax-aliasing -fgcse-mem-alias
-funroll-loops -floop-transpose -floop-to-memset -finline-floor
-mcpu=G5 -mpowerpc64 -mpowerpc-gpopt -mtune=G5 -fsched-interblock
-fload-after-store --param max-gcse-passes=3 -fno-gcse-sm
-fgcse-loop-depth -funit-at-a-time -fcallgraph-inlining
-fdisable-typechecking-for-spec

At least the --fast-math part causes problems, seeing that PostgreSQL
actually checks for the __FAST_MATH__ macro to make sure that it isn't
turned on. There might be other problems with Apple's flags, but I
think that the __FAST_MATH__ check should be altered.

As you know, setting --fast-math in GCC is the equivalent of setting
-fno-math-errno, -funsafe-math-optimizations, -fno-trapping-math,
-ffinite-math-only and -fno-signaling-nans. What really should be done,
I think, is adding the opposites of these flags (-fmath-errno,
-fno-unsafe-math-optimizations, -ftrapping_math, -fno-finite-math-only
and -fsignaling-nans) to the command line if __FAST_MATH__ is detected.
This would allow people to use CFLAGS="-fast" on their G5s, beat some
Xeon speed records, and not worry about esoteric IEEE math standards.
What do you guys think?

GCC sets __FAST_MATH__ even if you counter a -ffast-math with the
negating flags above. This means that it is not currently possible to
use the -fast flag when compiling PostgreSQL at all. Instead, you have
to go through all the flags Apple is setting and only pass on those
that don't break pg.

mk

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2003-10-11 17:47:48 Re: fix for strict-alias warnings
Previous Message Tom Lane 2003-10-11 17:29:07 Re: fix for strict-alias warnings

Browse pgsql-performance by date

  From Date Subject
Next Message David Griffiths 2003-10-11 19:44:36 Another weird one with an UPDATE
Previous Message Nick Barr 2003-10-11 14:55:43 Re: go for a script! / ex: PostgreSQL vs. MySQL