From: gthaker@atl.ge.com (Gautam H. Thaker) Subject: a pgm to test cache/memory speeds and how it shows my hardware problems Date: 30 Jul 1993 18:10:30
I have been unsuccessful in getting my DTK machine to cache properly about 8 Mb.
Thru a posting I heard from Joerg Lenneis in Austria who had a newer DTK motherboard
and felt his system worked fine. I got my vendor to upgrade my motherboard, but
my tests still ran slow when using more than 8 Mb of mem. So I sent him my test
pgms and he too discovered that his machine ran slow when accessing addresses > 8 Mb.
He suggests the following test program to learn if there is any significant variation
in memory speeds in your machine. THis pgm is shown below with the results I get
when using 8 or 16 Mb of memory.
Others may want to try this pgm. A variation in your run would likely mean you too
have cache/memory system problems.
I would like to hear from others if they try this. Later I hope to write a pgm
to test mem from a device driver. This way at least the code would run in
low RAM...
Gautam H. Thaker (gthaker@atl.ge.com) 609-866-6412 (fax x6397. Dialcom 8-777)
Martin Adv. Tech. Lab., MS 145-2; Route 38; Moorestown, NJ 08057. 767-4396 (H)
#if 0
DO
gcc -O -o memtest memtest.c
followed by running following script
========== start of script ===================
#!/bin/sh
memtest 32 8 60000 >> result
memtest 32 16 60000 >> result
memtest 32 24 60000 >> result
memtest 32 32 60000 >> result
memtest 32 40 60000 >> result
memtest 32 48 60000 >> result
memtest 32 56 60000 >> result
memtest 32 64 60000 >> result
memtest 32 72 60000 >> result
memtest 32 80 60000 >> result
memtest 32 88 60000 >> result
memtest 32 96 60000 >> result
awk '{print $2}' result|sort -n |uniq -c
============================= end of script ====================
When running my DTK 486/33 MHz with 64k cache and 16 Mb of mem. but limited
in kernel to just use lower 8 Mb.
Num Ticks
Hits
196 33
421 34
3 35
4 36
When running my DTK 486/33 MHz with 64k cache and 16 Mb of mem. and using all memory.
Num Ticks
Hits
45 36
50 37
1 39
17 54
69 55
2 59
395 73
34 74
1 76
4 77
5 78
1 79
#endif
#include <stdio.h>
#include <sys/times.h>
#include <unistd.h>
#define SCALE 0.23283064365386962890625e-9
#define MULT 1812433253U
#define Randint(low, high) ( (long) (low) + ((seed = (seed * MULT + 1)) % ((high) - (low))))
time_t t;
struct tms tmsstruct;
unsigned long seed = 11;
long *buf;
main (int argc, char **argv)
{
long i,j, k, sum, size, per_block;
long blocksize, blocks, iterations;
if (argc != 4) {
fprintf(stderr, "%s <blocksize in kb> <blocks> <iterations>\n", argv[0]);
exit(1);
}
blocksize = atol(argv[1]) * 1024;
blocks = atol(argv[2]);
iterations = atol(argv[3]);
size = blocksize * blocks / sizeof (long);
per_block = blocksize / sizeof(long);
buf = (long *) calloc (size * sizeof(long), 1);
sum = 0;
for (i = 0; i < size ; i += per_block) {
t = times(&tmsstruct);
for (j = 0; j < iterations; j++) {
k = Randint(i, i + per_block);
sum += buf[k];
k = Randint(i, i + per_block);
buf[k] = Randint(0, 3) - 1;
}
printf("%d %d\n", blocks, times(&tmsstruct) - t);
}
/* printf("%ld\n", sum); */
}