9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] p9/linux/fbsd compiler shootout
@ 2002-02-26 14:18 rob pike
  0 siblings, 0 replies; 14+ messages in thread
From: rob pike @ 2002-02-26 14:18 UTC (permalink / raw)
  To: 9fans

Again, and strongly, there was little effort made to make the Plan 9
C compilers generate good floating point code.  I predict much less
difference using normal, integer code - such as the kernel - which
did receive some optimization attention.

Also, the kernel spends most of its time in memmove and memset,
both of which are written in assembler and therefore are not affected
by the compiler.  I doubt the quality of complation of the kernel has a
minor effect on runtime of the compiler itself.

Russ Cox points out that:

	the linux guys
	decided that the default floating-point
	precision should be 80-bit in-register
	precision but with 64-bit in-memory
	precision.  i realize that this is sometimes
	desirable if you know what you're doing,
	but they made it the default.  so code 
	ends up behaving differently (usually
	incorrectly) based on what gcc registerizes
	and what overflows into memory.

	#include <stdio.h>
	#include <stdlib.h>
	#include <math.h>
	
	void
	main(void)
	{
		double x, y;
	
		x = sqrt(3.0);
		y = sqrt(3.0) - x;
	
		if(y)
			printf("buggered\n");
	}



-rob



^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [9fans] p9/linux/fbsd compiler shootout
@ 2002-02-26 15:02 andrey mirtchovski
  2002-02-26 16:02 ` Wilhelm B. Kloke
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: andrey mirtchovski @ 2002-02-26 15:02 UTC (permalink / raw)
  To: 9fans

> The compile time using for the BSD/2.95/no test looks *really* low;
> are we sure about that number?  It's a very strange outlier, isn't it?
> I'll mostly ignore that one, because it is *such* a surprise; GCC
> isn't normally thought to be that fast, but hey, maybe it really is. 
>

several more tests yield exactly the same results -- FBSD 4.5 w/
gcc2.95 takes about 18 seconds to compile.

> A total curiosity is that running the Linux binaries under emulation
> in BSD is *faster* than running the native BSD binaries.  It's hard to
> imagine that the BSD team specially optimized that case, does anyone
> have any knowledge or guesses?  
> 

gcc 3.0 on FBSD was locally compiled and installed (as was noted in
the explanations), had it been taken from a binary package it _must_
have been much faster (all we did was 'make; make install')...

something else i forgot to mention: gcc 3.0 on linux (rpm install)
complains of -m386 being deprecated (-m386 is part of the CFLAGS
switches povray uses)...  gcc3.0 on FBSD did not say anything about
-m386...  I find this very strange.



^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [9fans] p9/linux/fbsd compiler shootout
@ 2002-02-26 14:20 rob pike
  2002-02-26 16:07 ` Sean Quinlan
  0 siblings, 1 reply; 14+ messages in thread
From: rob pike @ 2002-02-26 14:20 UTC (permalink / raw)
  To: 9fans

> Rob, can you say more about what 8c's shortcomings are in
> floating point?

Ken just didn't spend much time on it.  A fair bit of effort was spent
on integer code for most of the architectures, including x86.  When
you have finite time (unlike the GCC people, who have infinite people
and forever to work on it, 8c was a one-man operation) you choose
where to spend it.

-rob



^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [9fans] p9/linux/fbsd compiler shootout
@ 2002-02-26 11:15 forsyth
  0 siblings, 0 replies; 14+ messages in thread
From: forsyth @ 2002-02-26 11:15 UTC (permalink / raw)
  To: 9fans

>>GCC had to develop a whole special extra codegen unit to manage to do
>>fp on a 386 anything approaching well, and without something like
>>that, it's pretty painful.

the code generators are all custom, although the RISC ones are similar
(and closely related), so that aspect of the peculiar floating-point
isn't troublesome (which isn't to say it tries anything too fancy).
the 680x0 and x86 compilers have a lot of custom code.

the plan 9 c compilers aren't like pcc, which did a simple essentially
one-pass translation (to assembler) with no optimisation.
the compiler does function-level register allocation, addressing mode selection
and broad instruction selection, with local code improvements.
unusually, detailed (machine-level) instruction selection is done by
the linker (which is in a good position to do ARM/Thumb linkage, literal pools,
span-dependent instructions, instruction scheduling, etc.).  only the linker knows
the binary formats of instructions of a given processor or processor variant.
some instructions issued by the compiler don't correspond to real instruction variants.
the assembler is just a front-end to the linker.  the compiler doesn't use the assembler.


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [9fans] p9/linux/fbsd compiler shootout
@ 2002-02-26  3:10 rob pike
  2002-02-26 10:26 ` Thomas Bushnell, BSG
  0 siblings, 1 reply; 14+ messages in thread
From: rob pike @ 2002-02-26  3:10 UTC (permalink / raw)
  To: 9fans

Great, thanks.  I'd like to see a similar shootout using a non-floating-point
application.

-rob



^ permalink raw reply	[flat|nested] 14+ messages in thread
* [9fans] p9/linux/fbsd compiler shootout
@ 2002-02-26  3:05 andrey mirtchovski
  2002-02-26 10:27 ` Thomas Bushnell, BSG
  2002-02-26 10:27 ` Thomas Bushnell, BSG
  0 siblings, 2 replies; 14+ messages in thread
From: andrey mirtchovski @ 2002-02-26  3:05 UTC (permalink / raw)
  To: 9fans

Hello,

We spent the day here doing a simple compiler/os/p9-vs-the-world
shootout..  Here's what we found...


Machine:
        A single cpu 800mhz Athlon T-Bird system (k7).  Each operating
system was installed on a separate IBM Deskstar 30GB IDE drive.  The
video card used was NVidia TNT2, but that's not important since only
plan9 ran any graphical interface (note: when attempting to test on P9
without rio the machine hung during ape/psh compilation).

OS: 
       Linux/RedHat 7.2, kernel 2.4.7 (ext3) standard install
       FreeBSD 4.5 fresh install (no softupdates turned on)
       Plan9 installed on-line (with kernel modification to
       accomodate NVidia graphics hardware)

Software: 
        The test was done using POV-Ray graphics/imaging sotware
(www.povray.org)..  We downloaded the latest 3.1 unix sources.  The
makefile for p9 was modified to compile under ape/psh.  We removed
most of the CFLAGS switches, set the compiler to pcc.  The compile
time reported under all OS's and compilers does *not* include time to
compile libpng and zlib support.  We used only POV-Ray - relevant
files.

        Time given is the time it took to render a single frame of a
predefined scene (explanation below).

        We chose to render using radiosity rather than ray-tracing,
since radiosity is more computationaly intensive.  The test is
extremely floating-point heavy (or at least it should be -- after all
it's graphics we're dealing with :).  Each compilation resulted in a
ppm image of size 1440015 bytes + 1910 bytes in an ASCII statistics
file.  POV-Ray keeps rough stats on its own, so the time reported is
the actual time in seconds that POV-Ray thinks it was rendering
(including initial parsing of the scene description file).  All output
was redirected to a file in order to avoid any console IO (this was
not done for the compilation, though.

        The scene description could be found in:
		.../scenes/radios/rad2.pov
	in the POV-Ray distribution.


        Images generated were of size 800x600, in PPM format.  Here is
the string used to render them:
                (plan9 version given, others identical except for
                redirection syntax)
                povray +L/path/to/povray/libs rad2.ini +Irad2.pov +Oscene.ppm +FP +W800 +H600 -GA +GS >[2]out.txt

        For each platform/compiler pair we compiled two binaries -- one using
the standard optimizations found in POV-Ray's makefile, the other
without any optimization switches (e.g.  gcc -c file.c).  Povray uses
the following optimizations:
        -O6
        --finline-functions
        --ffast-math 
        -m386 (deprecated in 3.0)
 
	Each compiler was given three runs, each run is reported. 


Some additional notes: 
        FreeBSD 4.5 does not come with gcc 3.0, neither could it be
found as a binary package.  We had to compile it from the ports
collection, but since it was a simple make; make install deal we got
no optimization for it.  It shows (compare the 3.0 results with the 
same fbsd using gcc 2.95 and a linux binary compiled with 3.0
under emulation)...


--- 

Results (time in seconds):

(please excuse bad formatting -- we elaborated on the idea of putting
everything in an excel spreadsheet, but couldn't find any)

OS/compiler/
optimization		run #1	run #2	run #3	Compile time (mm:ss.ms)
------------------------------------------------
P9/8c/yes(?)		293		293		292		0:19.24

Lnx/3.0.2/yes		150		149		149		0:56.541
BSD/3.0.2/yes		170		170		170		0:55.04
BSD/3.0.2/yes		151		151		151		none (running linux binaries under emulation)

Lnx/3.0.2/no		196		196		196		0:30.052
BSD/3.0.2/no		221		221		220		0:26.49
BSD/3.0.2/no		203		203		203		none (running linux binaries under emulation)

Lnx/2.96/yes		147		147		148		0:56.848
BSD/2.95/yes		177		178		178		0:42.03

Lnx/2.96/no		203		204		203		0:55.620
BSD/2.95/no		208		208		208		0:18.76


-----

regards :)

ps: reading the above forces you to agree not to use the information
here in flammable, non-p9-related and in any way unscientific
discussions :)

pps: funny fact #430995: selecting gcc for installation on rh7.2
results in installing 220mb worth of dependencies.  one of the
more-importand ones is x-chat (or at least x-chat related)!




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

end of thread, other threads:[~2002-03-04 10:04 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-26 14:18 [9fans] p9/linux/fbsd compiler shootout rob pike
  -- strict thread matches above, loose matches on Subject: below --
2002-02-26 15:02 andrey mirtchovski
2002-02-26 16:02 ` Wilhelm B. Kloke
2002-02-26 18:00   ` splite
2002-02-26 16:04 ` Matt H
2002-03-04 10:04 ` Gaute B Strokkenes
2002-02-26 14:20 rob pike
2002-02-26 16:07 ` Sean Quinlan
2002-02-26 11:15 forsyth
2002-02-26  3:10 rob pike
2002-02-26 10:26 ` Thomas Bushnell, BSG
2002-02-26  3:05 andrey mirtchovski
2002-02-26 10:27 ` Thomas Bushnell, BSG
2002-02-26 10:27 ` Thomas Bushnell, BSG

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 NNTP newsgroup(s).