Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <richard@atheist.tamu.edu>
Subject: Re: compile bug in gcc ? - was performance ...
Date: Tue, 11 Jun 1996 16:26:30 -0500 (CDT)	[thread overview]
Message-ID: <68f9c74d065b71e9ede45776a7dd4038.axp-list@archive.invalid> (raw)
In-Reply-To: <199606111618.BAA24680@atlas.rc.m-kagaku.co.jp>

> Test 2 is the one that would not finish on a 21164-300 under linux.

This one, it turns out, is programmer error.  

> /* This is Test2 */
...
> void
> main (int argc, char *argv[])
> {
>   float f1, t1;
>   long i, n;
...
>   if (argc == 1)
>     n=10;
>   else
>     sscanf (argv[1], "%d", &n);

sscanf is writing an int into a long so the upper 32 bits are not
zeroed.  The number I happened to see in n was on the order of 10**12.

gcc -Wall can catch many of these problems, as will using the correct
system header files.

Some other pointers:

1) You should be using CLOCKS_PER_SEC in time.h.  Additionally,
user programs should not prototype library functions.  You will
be wrong on some system.  Besides, that is what system header
files are for.

So your cpu-time poll routines should be

  float second() { return (float)clock() / CLOCKS_PER_SEC; }

2) If you use malloc and free, include stdlib.h.  If you don't,
by ANSI C rules, malloc is implicitly declared to return an int
which gets truncated when you cast to a pointer.

3) This, unlike the last, is merely a helpful tip for the alpha
not an error on your part.

> extern void dist (float *, float *, float *, int);
...
>   for (i = 0; i < lx; i++)
>     for (j = 0; j < 3 * NM; j += 3)
>       dist (u, v + j, d, NM);

Alpha calling conventions let us do things more efficiently
when we know that the called function is in the same object file.
Making dist() static rather than extern has this effect.

This should be especially helpful when the functions are at
the center of multiply nested loops.

That said, here are the numbers for my eb164/300 with gcc -O2:

test1:
      1000        10      0.49    163.84

test2:
Transf Benchmark: loop length   :    10 * 10^3
Transf Benchmark: Time/MegaFlops:       1.43     126.25

test3:
      Size     Loops      Time    MFlops
       500     40000      2.50     80.00
      1000     20000      2.49     80.31
      5000      4000      2.61     76.70
     10000      2000      4.36     45.92
     50000       400      2.88     69.42
    100000       200      4.79     41.71
    500000        40      3.35     59.71

r~

       reply	other threads:[~1996-06-11 21:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <199606111618.BAA24680@atlas.rc.m-kagaku.co.jp>
1996-06-11 21:26 ` Richard Henderson [this message]
     [not found] <m0uTaxK-0001pVC@atheist.tamu.edu>
1996-06-12 19:45 ` compile bug in gcc ? - was performance Wim van Dorst
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox