Re: Spinlocks and CPU Architectures - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Spinlocks and CPU Architectures
Date
Msg-id 20051011190950.GG22806@svana.org
Whole thread Raw
In response to Re: Spinlocks and CPU Architectures  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Spinlocks and CPU Architectures
List pgsql-hackers
On Tue, Oct 11, 2005 at 02:28:02PM -0400, Tom Lane wrote:
> One thought that comes to mind is that these decisions are probably
> comparable to those made by gcc conditional on -march flags.  Do we
> get access to the -march setting by means of predefined symbols?
> If so we could compile different TAS code for opteron and em64t without
> introducing any packaging issues that didn't exist already.  It would
> essentially be up to the source-code builder which sub-arch to tune for.

The option is available see below. It appears __tune_xxx__ is set for
the -mcpu option and __xxx__ is set for the -march option. This is gcc
3.3.5, but it probably works for older versions...

-march controls which instructions to use, -mcpu is which scheduling to
assume. Which do we use? The former implies the latter but not the
other way round.

Have a nice day,

kleptog@vali:/tmp$ rm a.h
kleptog@vali:/tmp$ touch a.h
kleptog@vali:/tmp$ gcc -mcpu=i386 -E -dM a.h >/tmp/a
kleptog@vali:/tmp$ gcc -mcpu=pentium -E -dM a.h >/tmp/b
kleptog@vali:/tmp$ diff -u0 /tmp/a /tmp/b
--- /tmp/a      2005-10-11 21:02:38.000000000 +0200
+++ /tmp/b      2005-10-11 21:02:41.000000000 +0200
@@ -28,0 +29 @@
+#define __tune_pentium__ 1
@@ -44,0 +46 @@
+#define __tune_i586__ 1
@@ -61 +62,0 @@
-#define __tune_i386__ 1
kleptog@vali:/tmp$ gcc -march=i386 -E -dM a.h >/tmp/a
kleptog@vali:/tmp$ gcc -march=athlon -E -dM a.h >/tmp/b
kleptog@vali:/tmp$ diff -u0 /tmp/a /tmp/b
--- /tmp/a      2005-10-11 21:03:57.000000000 +0200
+++ /tmp/b      2005-10-11 21:05:47.000000000 +0200
@@ -4,0 +5 @@
+#define __3dNOW_A__ 1
@@ -16,0 +18 @@
+#define __athlon 1
@@ -41,0 +44 @@
+#define __MMX__ 1
@@ -46,0 +50 @@
+#define __athlon__ 1
@@ -59 +62,0 @@
-#define __tune_i386__ 1
@@ -63,0 +67,2 @@
+#define __tune_athlon__ 1
+#define __3dNOW__ 1
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

pgsql-hackers by date:

Previous
From: "Kevin Grittner"
Date:
Subject: database vacuum from cron hanging
Next
From: Peter Eisentraut
Date:
Subject: Re: Spinlocks and CPU Architectures