libm for 68881 and Sun fpa is incredibly slow

prl at eiger.uucp prl at eiger.uucp
Wed Mar 1 19:10:49 AEST 1989


If you use libm (especially trancendental functions sin(), cos(), ln(),
exp() etc..) you can get nearly a 10* speedup by using the clumsy code
inlining facility provided by Sun's C complier.

For example (on Sun 3/60, SunOS 4.0.1)

The following code:

	#include <math.h>

	main()
	{
		register int i;
		register double x, y;
		for(i = 0, x = 0; i < 100000; i++, x += 2*M_PI/100000.0)
			y = cos(x);
	}

Compiled with:
	cc -O -f68881 -o cos cos.c -lm

Runs in:
	real    0m30.16s
	user    0m24.56s
	sys     0m0.58s

Compiled with (but how incredibly *UGLY*):
	cc -O -f68881 -o cos cos.c /usr/lib/f68881/libm.il

Runs in:
	real    0m4.33s
	user    0m3.65s
	sys     0m0.20s

REASON:
	Although Sun went to the trouble of making the assembly inline
	file /usr/lib/f68881/libm.il, and a 68881 version of the
	maths library, they *DID NOT* make assembly versions of
	the maths functions to put into the maths library!
	(and similarly for the FPA)

	THIS IS STUPID!

NOTA BENE, Sun:
	We discovered this while benchmarking Sony workstations. Trivial
	loops with sin(), cos() etc. calls run 10* faster on the Sony
	(20MHz, 68020 version) than on the Sun 3/60, without the need for
	the inlining muck.

	If Sony can do it right first time, why can't Sun get it right
	on their Nth release after introducing the 68881?

Peter Lamb				uucp:  seismo!mcvax!ethz!prl
Tel: (01) 256 5241 (Switzerland)	eunet: prl at iis.ethz.ch
     +411 256 5241 (International)

Integrated Systems Laboratory
ETH-Zentrum
8092 Zurich



More information about the Comp.sys.sun mailing list