[Coco] OT: memory test code?

Gene Heskett gene.heskett at verizon.net
Thu Sep 29 18:33:18 EDT 2005


On Thursday 29 September 2005 18:01, Kevin Diggs wrote:
>Hi,
>
> Anyone know of any memory test code that will run under NetBSD (i.e.
>source available) or MacOS 8.1?
>
> The source file xmaze.c has numerous calls to strcmp. The troubled
>computer is currently running an endless shell loop compiling the file
>to assembler output (-S) until a file shows up with a call to strcmp! It
>has been up for more than a day, albeit not doing a whole lot.
>
> If this system were experiencing memory problems would you expect to
>see occasional failures from the following program, which was written to
>play with the move16 instruction of the 040 (for the curious, movel
>takes about 1.9 or 2.0 seconds and move16 takes 1.2 or 1.3):
>
>#include <stdio.h>
>#include <stdlib.h>
>#include <string.h>
>#include <sys/resource.h>
>
>#define BLK_SIZE (16<<20)
>
>char *saveS(char *s)
>{
>static char *s0;
>
>	if(s!=NULL) s0=s;
>
>	return s0;
>}
>
>char *saveD(char *d)
>{
>static char *d0;
>
>	if(d!=NULL) d0=d;
>
>	return d0;
>}
>
>int tvDiff(const struct timeval *start, const struct timeval *end)
>{
>long sec,usec;
>int packed;
>
>	sec=end->tv_sec-start->tv_sec;
>	usec=end->tv_usec-start->tv_usec;
>
>	if(usec<0)
>	{
>		sec--;
>		usec+=1000000;
>	}
>
>	packed=usec/1000 | (sec<<10);
>
>	return packed;
>}
>
>int cpCheck(const char *s, const char *d, int count)
>{
>int diffs=0;
>const int *p,*q;
>
>	for(p=(const int *)s,q=(const int *)d; p<((const int *)s)+(count>>2);
>		p++,q++)
>		if(*p!=*q) diffs++;
>
>	return diffs;
>}
>
>int main(int argc, char *argv[])
>{
>char *s,*d;
>struct rusage ru_start,ru_movew,ru_movel,ru_move16,ru_memmove;
>int diffs,diffms,diff1,diff2,diff3,diff4;
>
>	s=saveS((char *)malloc(BLK_SIZE));
>	d=saveD((char *)malloc(BLK_SIZE));
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>
>	memset(d,0,BLK_SIZE);
>
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>	srand(getpid());
>
>	for(d=s; d<s+BLK_SIZE; d+=4)
>		*(int *)d=rand();
>
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>	s=saveS(NULL);
>
>	d=saveD(NULL);
>
>	getrusage(RUSAGE_SELF,&ru_start);
>
>	asm volatile("lsrl #1,%0;1:movew (%1)+,(%2)+;subql #1,%0;bne 1b":
>		:"d"(BLK_SIZE),"a"(s),"a"(d));
>
>	getrusage(RUSAGE_SELF,&ru_movew);
>
>	diffs=tvDiff(&ru_start.ru_utime,&ru_movew.ru_utime);
>	diffms=diffs&0x3ff;
>	diffs>>=10;
>
>	printf("movew   time for %d is %d.%03d\n",BLK_SIZE,diffs,diffms);
>
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>	s=saveS(NULL);
>
>	d=saveD(NULL);
>
>	diff1=cpCheck(s,d,BLK_SIZE);
>
>	if(diff1)
>		printf("\t%d errors for movew\n",diff1);
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>	memset(d,0,BLK_SIZE);
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>
>	getrusage(RUSAGE_SELF,&ru_start);
>
>	asm volatile("lsrl #2,%0;2:movel (%1)+,(%2)+;subql #1,%0;bne 2b":
>		:"d"(BLK_SIZE),"a"(s),"a"(d));
>
>	getrusage(RUSAGE_SELF,&ru_movel);
>
>	diffs=tvDiff(&ru_start.ru_utime,&ru_movel.ru_utime);
>	diffms=diffs&0x3ff;
>	diffs>>=10;
>
>	printf("movel   time for %d is %d.%03d\n",BLK_SIZE,diffs,diffms);
>
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>	s=saveS(NULL);
>
>	d=saveD(NULL);
>
>	diff2=cpCheck(s,d,BLK_SIZE);
>
>	if(diff2)
>		printf("\t%d errors for movel\n",diff1);
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>	memset(d,0,BLK_SIZE);
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>
>	getrusage(RUSAGE_SELF,&ru_start);
>
>	asm volatile("lsrl #4,%0;3:move16 (%1)+,(%2)+;subql #1,%0;bne 3b":
>		:"d"(BLK_SIZE),"a"(s),"a"(d));
>
>	getrusage(RUSAGE_SELF,&ru_move16);
>
>	diffs=tvDiff(&ru_start.ru_utime,&ru_move16.ru_utime);
>	diffms=diffs&0x3ff;
>	diffs>>=10;
>
>	printf("move16  time for %d is %d.%03d\n",BLK_SIZE,diffs,diffms);
>
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>	s=saveS(NULL);
>
>	d=saveD(NULL);
>
>	diff3=cpCheck(s,d,BLK_SIZE);
>
>	if(diff3)
>		printf("\t%d errors for move16\n",diff1);
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>	memset(d,0,BLK_SIZE);
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>
>	getrusage(RUSAGE_SELF,&ru_start);
>
>	memmove(s,d,BLK_SIZE);
>
>	getrusage(RUSAGE_SELF,&ru_memmove);
>
>	diffs=tvDiff(&ru_start.ru_utime,&ru_memmove.ru_utime);
>	diffms=diffs&0x3ff;
>	diffs>>=10;
>
>	printf("memmove time for %d is %d.%03d\n",BLK_SIZE,diffs,diffms);
>
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>	s=saveS(NULL);
>	d=saveS(NULL);
>
>	diff4=cpCheck(s,d,BLK_SIZE);
>
>	if(diff4)
>		printf("\t%d errors for memmove()\n",diff1);
>#ifdef CRASH_DEBUG
>	printf(__FILE__"-%d:\n",__LINE__);
>#endif
>
>	free(saveS(NULL));
>	free(saveD(NULL));
>#if 0
>	printf("times at start %d.%06d\n",ru_start.ru_utime.tv_sec,ru_start.
>		ru_utime.tv_usec);
>
>	printf("times after move.l
> %d.%06d\n",ru_movel.ru_utime.tv_sec,ru_movel. ru_utime.tv_usec);
>
>	printf("times after move16 %d.%06d\n",ru_move16.ru_utime.tv_sec,
>		ru_move16.ru_utime.tv_usec);
>#endif
>	return 0;
>}
>
>
>					kevin

See if you can find a little utility I've used a couple of times under
linux, called (IIRC) memburn.  It found some stuff that memtest86
didn't, like I was trying to run an XP-2800 athlon with a 400mhz FSB,
when in fact that cpu is only rated for a 333mhz FSB.

-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
99.35% setiathome rank, not too shabby for a WV hillbilly
Yahoo.com and AOL/TW attorneys please note, additions to the above
message by Gene Heskett are:
Copyright 2005 by Maurice Eugene Heskett, all rights reserved.




More information about the Coco mailing list