Subject: SGI O2 compile problem
To: None <port-sgimips@NetBSD.ORG>
From: Yutaka Narumai <ynarumai@marubun.co.jp>
List: port-sgimips
Date: 03/02/2002 20:29:33
Hello friend,
Now, we can boot up O2 with NetBSD, thank you.
But after we execute compiling on the O2 machine, executable=20
program crashes very easily.
When we compile a very small program(e.g. Hello world), it works OK but
we can not execute program in practical size.
Is that so unstable?
Any advises will be highly appreciated.
Sincerely,
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
# uname -a
NetBSD 1.5A NetBSD 1.5A (INDY) #142: Tue Jun 27 17:40:37 CEST 2000 sor=
en@me
ow:/usr/home/soren/netbsd/src/sys/arch/sgimips/compile/INDY sgimips
#
# pwd
/home/tmp
#
#
# ls
copybw.c helloworld.c
#
# which gcc
/usr/bin/gcc
#
# more helloworld.c
#include<stdio.h>
main()
{
printf("Hello World!\n");
}
#
# gcc -o helloworld.o helloworld.c
# ls -l helloworld.o
-rwxr-xr-x 1 root wheel 118298 Mar 2 2002 helloworld.o
# ./helloworld.o
Hello World!
#
# gcc -o copybw.o copybw.c
#=20
# ./copybw.o
=2E/copybw.o: chunk_size =3D 4194304, nchunks =3D 10, nprocesses =3D 1
Running power-on diagnostics...
reboot ...
////////////////////// copybw.c //////////////////////////
/*
* Author: Jan Edler
* copyright?: I recommend one. =20
*
* Try to measure and report memcpy bandwidth of parallel processes.
* Synchronization is coarse, to be as portable as possible,
* at the expense of some timing accuracy.
*/
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <float.h>
#include <sys/time.h>
#include <errno.h>
char usage[] =3D "Usage: %s [-v] [-c chunk_size] [-n nchunks] [-p
nprocesses]\n";
int chunk_size =3D 4*1024*1024, nchunks =3D 10, nprocesses =3D 1;
int verbose =3D 0;
#ifndef do_memcpy
#define do_memcpy(d,s,c) memcpy(d,s,c)
#endif
int
main (int argc, char **argv)
{
int c, n;
char *src, *dst;
int pipe_barrier[2];
int pipe_results[2];
char junk;
struct timeval tv_start, tv_end;
double *all_times, *next_time;
double min_start =3D DBL_MAX, max_start =3D DBL_MIN,
min_end =3D DBL_MAX, max_end =3D DBL_MIN;
while ((c =3D getopt (argc, argv, "vc:n:p:")) !=3D EOF)
switch (c) {
default: fprintf (stderr, usage, argv[0]); return 1;
case 'v': verbose =3D 1; break;
case 'c': chunk_size =3D atoi(optarg); break;
case 'n': nchunks =3D atoi(optarg); break;
case 'p': nprocesses =3D atoi(optarg); break;
}
if (optind < argc) {
fprintf (stderr, usage, argv[0]);
return 1;
}
printf ("%s: chunk_size =3D %d, nchunks =3D %d, nprocesses =3D %d\n",
argv[0], chunk_size, nchunks, nprocesses);
if (pipe (pipe_barrier) < 0) {
perror ("pipe pipe_barrier");
return 2;
}
if (pipe (pipe_results) < 0) {
perror ("pipe pipe_results");
return 2;
}
src =3D malloc (chunk_size);
if (src =3D=3D NULL) {
fprintf (stderr, "%s: malloc(%d) failed for src\n",
argv[0], chunk_size);
return 2;
}
dst =3D malloc (chunk_size);
if (dst =3D=3D NULL) {
fprintf (stderr, "%s: malloc(%d) failed for dst\n",
argv[0], chunk_size);
return 2;
}
all_times =3D malloc (nprocesses * 2 * sizeof(double));
if (all_times =3D=3D NULL) {
fprintf (stderr, "%s: malloc(%d) failed for all_times\n",
argv[0], nprocesses * 2 * sizeof(double));
return 2;
}
for (c =3D nprocesses; c > 1; c--) {
switch (fork()) {
case -1: perror ("fork"); return 2;
case 0: break; /* child: start waiting */
default: continue; /* parent: continue forking */
}
break; /* child */
}
memset (src, 0, chunk_size); /* initialize and break copy on write */
memset (dst, 0, chunk_size);
if (close (pipe_barrier[1]) < 0) {
perror ("close pipe_barrier[1]");
return 2;
}
/* this read will get EOF when all the processes have started */
if (read (pipe_barrier[0], &junk, 1) < 0) {
perror ("pipe read");
return 2;
}
if (gettimeofday (&tv_start, NULL) < 0) {
perror ("gettimeofday 0");
return 2;
}
/* this is the stuff being measured */
for (n =3D nchunks; n > 0; n--)
do_memcpy (dst, src, chunk_size);
if (gettimeofday (&tv_end, NULL) < 0) {
perror ("gettimeofday 1");
return 2;
}
all_times[0] =3D (double)tv_start.tv_sec + tv_start.tv_usec / 1000000.;
all_times[1] =3D (double)tv_end.tv_sec + tv_end.tv_usec / 1000000.;
if (verbose)
printf ("p%d: %d bytes copied in %f secs =3D %f MB/s\n",
c, chunk_size * nchunks, all_times[1] - all_times[0],
(double)(chunk_size * nchunks) /
(all_times[1] - all_times[0]) / (1024.*1024.));
if (c>1) { /* write time values back to parent */
errno =3D 0; /* should check return value instead XXX */
if (write (pipe_results[1], all_times, 2*sizeof(double)) !=3D
2*sizeof(double)) {
perror ("write pipe_results[1]");
return 2;
}
}
if (close (pipe_results[1]) < 0) {
perror ("close pipe_results[1]");
return 2;
}
if (c=3D=3D1) { /* collect and summarize the results */
next_time =3D &all_times[2];
/* should be more careful about errors & overrun XXX */
while (read (pipe_results[0], next_time,
2 * sizeof(double)) =3D=3D 2 * sizeof(double))
next_time +=3D 2;
if (next_time !=3D &all_times[2*nprocesses]) {
fprintf (stderr, "%s: next_time=3D%d is wrong\n",
argv[0], next_time - all_times);
return 2;
}
while (wait(NULL) >=3D 0)
continue; /* should check for errors XXX */
/*
* Use earliest start time and latest stop time.
* Also warn about non-overlap.
*/
for (n =3D 0; n < nprocesses; n++) {
if (min_start > all_times[n*2+0])
min_start =3D all_times[n*2+0];
if (max_start < all_times[n*2+0])
max_start =3D all_times[n*2+0];
if (min_end > all_times[n*2+1])
min_end =3D all_times[n*2+1];
if (max_end < all_times[n*2+1])
max_end =3D all_times[n*2+1];
}
printf ("%d*%d bytes copied in %f secs =3D %d*%f MB/s =3D %f MB/s",
nprocesses, chunk_size * nchunks, max_end - min_start,
nprocesses, ((double)chunk_size * nchunks) /
(max_end - min_start) / (1024.*1024.),
((double)nprocesses * chunk_size * nchunks) /
(max_end - min_start) / (1024.*1024.));
if (max_start >=3D min_end)
printf (" (some non-overlap occured)");
printf ("\n");
}
return 0;
}
#