[net.micro.mac] Floating Point bench-marks

waddingt@umn-cs.UUCP (Jake Waddington ) (02/19/86)

I, with the help some freinds, perform some simple bench marks 
on three development systems. The purpose of these timings
was to help determine the suitability of the Mac for scientific,
number crunching, programs. Also, to help detremine the best
development system for these programs. Three seperate programs
where run for the test. The structure of the programs was
determined with very little insight in to the workings of the compilers
All three programs used the same basic structure but with different
functions. The code for the first program in C follows:

main()
{
	double a,s;
	double pi;
	double N[100][2];
	int i, j;
	long t,t0;
	FILE *fp;*fopen();
	
	printf("Using Arrays\n");
	fp= fopen("Bench_Marks","w");
	
	t = tickcount();	/* time outer loop in 60ths of seconds */
	
	pi= 3.1415926535897932324;
	s=0;
	for(i=1;i<=10;++i){
		for(j=0;j<100;++j){
			a= j+1;
			N[j][1]= pi/a;
			N[j][2]= sin(N[j][1])/cos(N[j][1]);
		}
		for(j=0;j<100;++j){
			a= j+1;
			a= a*(N[j][2]*cos(N[j][1])/sin(N[j][1])+ N[j][1]-atan(N[j][2]));
			s= s+a;
		}
	}
	t = tickcount() - t;
	printf("\nTime %5.2f sec.\n",(float)t/60.0);
	printf("s= %e\n",s);
	fprintf(fp,"Time %5.2f sec.\n",(float)t/60.0);
	fprintf(fp,"s= %e\n",s);
	fflush(fp);
	fclose(fp);
	/* Delay for User	*/
	t0= tickcount();
	printf("Done ?\n");
	scanf("%*c");
}

The  the 2nd & 3th program were the same but the 2nd divided by 10 then 

mulitplied by 10, while the 3rd squared a value then took the square 
root of it. The structure is:

	double a,s;
	
	t = tickcount();	/* time outer loop in 60ths of seconds */
	
	for(i=1;i<=1000;++i){
		a= i;
		for(j=1;j<=10;++j)
			a= sqrt(a);
		for(j=1;j<=10;++j)
			a= a*a;
		s= s+a;
	}
	s/= 5050.0;
	t = tickcount() - t;
	a= 1.0 -s/100.0;
	printf("\nTime %5.2f sec.\n",(float)t/60.0);
	printf("s= %20.14f   %5.3f%%\n",s,a);
}

Three three development systems differ in that two are "C", Aztec &
MegaMax, and one is Pascal, TML. MegaMax and TML both use the Apple, Sane,
floating point routines while Aztec uses their own. The times for 
three programs are:

(1) "for loops" using floating point arrays & trig functions
Compiler     Relative   Sec
TML             1       91
Aztec C         2.0     181
MegaMax C       1.3     115

(2)  "for loops" with /10 & *10
Compiler     Relative   Sec
TML             1       23
Aztec C         1.7     40
MegaMax C       1.8     42

(3)  "for loops" with sqr & sqrt
Compiler     Relative   Sec
TML             1       31
Aztec C         8.1     250
MegaMax C       1.9     58

Three features are notable from this data. First, TML Pascal is the
easy "winner". I have been told that it also is fast in QuickDraw
calls. Second, except for simple function MeagMax beats Aztec "C".
This is attributable to the fast machine code of the Sane package
verses the complied "C" code of Aztec floating piont functions. The last
feature is the very long time given by Aztec "C" in the thrid program. 

This can only be a result of problem with their square root routine. 
This will require further checking.

From these test I conclude that the Apple Sane math package is desirable
in a development package. It also implies that TML Pascal would make a 

very good system. A vax 780 took 3 to 20 secounds to run the 3rd
program. The wide spead in times due to the load. So the Mac does perform
well for number crunching programs when run time is not extermly long or
when one is forced to use a moderatly loaded system. For long programs
main frames are still best. Development time should also be taken into
account when compairing the Mac to a main frame. I beleive I can write
and debug a program on the Mac far quicker than on a multi-user system.

All three systems let the user write standard programs with the language's
standard I/O calls. The Sane package has only the usual Pascal math 
functions, exp, ln, sqrt, sin, cos, arctan. TML and MegaMax have only
these functions.

Bench marks are not the only way to judge a development systems. Easy
of use, completeness, and how bug free the package is. In short I
find TML Pascal to be very good in all these points while MegaMax
has many floating point bugs! Aztec C is a very good, very complete
system. I will post more on this later. For now I have to get back to 
my studies.


	Paul Fink
	University of Minnesota Cosmic Ray Lab
	
	ihnp4!umn-cs!waddingt

nathan@orstcs.UUCP (nathan) (02/24/86)

Re: error in posting

This may not be relevant to the benchmark, but the value of
"pi" used in the posted code was wrong.  The correct value
(to the same number of places) is
	pi = 3.1415926535897932385
				^^

stew@harvard.UUCP (Stew Rubenstein) (02/25/86)

In article <887@umn-cs.UUCP> waddingt@umn-cs.UUCP (Paul Fink ) writes:
>
>I, with the help some freinds, perform some simple bench marks 
>on three development systems.

I played with floating point on MegaMax a while ago...  The problem I have
with them is that they decided that compatibility with the world of 8-byte
doubles is important.  This results in a conversion from 8 to 10 byte format
and back for every operation, three traps where one should do.  Perhaps I am
naive, but I would implement the default floating point in C (double) using
the default floating point format (10 byte IEEE).  Compilers should at least
allow the use of the 10 byte format, perhaps via an "extended" type (I think
Consulair does this).

Any program which relies on "double" being 10 bytes or exactly two "float"s
is BROKEN.

Anyway, to the point -- coding my own (very simple) fp routines using

typedef struct { char b[10]; } extended;

sped up my crude benchmark by a factor of two.  It is not clear that this
is worth losing infix equations and normal assignments and comparisons.

Stew