Subject: Re: Compiler timings on varous MVII NetBSDs etc.
To: David Brownlee <abs@netbsd.org>
From: Lord Isildur <mrfusion@umbar.vaxpower.org>
List: port-vax
Date: 01/26/2001 05:46:08
sure. the source is at the bottom here. it's pretty decent at beating
a machine's memory to benchmark memory speed. run it with a large
size to effectively fault every cached access and test the speed of
core.. and dont laugh at my code too much :-)

the argument tells it how many words of memory to devote to the sieve,
and it puts a bunch of not veryuseful dots on stderr, and optionally prints
the primes on stdout (a few extra numbers sneak in, i never bothered to 
fix  it ;) , to shut off the printing, compile with -DSILENT

happy hacking,
isildur

On Fri, 26 Jan 2001, David Brownlee wrote:

> 	Could you send the program to the list (or make it available),
> 	so people with identical hardware and different OS versions can
> 	get exact numbers?
> 
> 		David/absolute		-- www.netbsd.org: No hype required --
> 

---
/* massiv.c, a simple sieve program. more useful in
 * benchmarking some basic memory capabilities than
 * for actually getting lists of primes.. 
 * isildur@umbar, 22 nov 1998 03:08:27 */

#include <stdio.h>
#include <sys/types.h>

int main(argc, argv)
int argc;
char** argv;
{
unsigned int* field,foo,bar,blarf,*mark,*space,m,x,*b,c,snum,bnum;
/* bar will mark the current factor. blarf is the marker for
 * the current bit. mark will mark the current word.
 * m speeds up finding blarf's bit, while blarf is used for masking
 * the actual bit. 
 */
if(argc<2){puts("Are you asking me how many bananas per square furlong there\nare in Costa Rica?\n");exit(0);}

bnum=atoi(argv[1]);
		/* bnum marks how many words will be devoted to the sieve */

bar=bnum*32;
bar++;
			/* we want snum to be sqrt(32*bnum). */
snum=1;c=1;
while(bar>snum){bar>>=1;snum<<=1;c<<=1;c++;}
snum=c;

bar=2;
foo=snum;
field=(unsigned int*)sbrk(bnum*4);
space=(field+bnum+1)-(snum/32);
	/* we want space to be the word directly past the place which holds
	 * 32*bnum -snum. */

b=field;
x=4;
c=0;

sto:
mark=field;
m=bar%32;
mark+=(bar/32);


sta:
/* first we must find out where blarf is and how much we must increment mark
 * by, and of course how far into the new place blarf should go. 
 */

*(mark+=((bar+m)/32))|=(blarf=1<<(m=((bar+m)%32)));
if(mark<space)goto sta;

/* note that this allows a few nonprimes to sneak in because of the improper
 * bounds here. not very important since this is more of a benchmark than
 * a prime generator. 
 */
write(2,".",1);
			/* find the next highest prime */
x<<=1;bar++;if(x==0){x=1;b++;}
while(((*b)&x)){x<<=1;bar++;if(x==0){x=1;b++;}
if(bar<snum)goto sto;
/**/
*field|=3;foo=0;mark=field;
pou:
blarf=1;m=0;
pia:
#ifndef SILENT
if(((*mark)&blarf)==0)printf("%d\n",foo);
#endif
blarf<<=1;m++;foo++;
if(m<32)goto pia;
mark++;
if(mark<space)goto pou;
/**/
write(2,"*\n",2);

return 0;
}