Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Re: performance
@ 1996-06-13 22:10 David Mosberger-Tang
  0 siblings, 0 replies; 6+ messages in thread
From: David Mosberger-Tang @ 1996-06-13 22:10 UTC (permalink / raw)


>>>>> On Fri, 14 Jun 1996 07:24:16 +0930 (CST), Berndt Josef Wulf <wulf@hotdog.ping.apana.org.au> said:

  Berndt> Which program is this and where can I find the source code
  Berndt> for it?

The source for test3 is appended below.  Note that gcc is not doing a
good job at optimizing the code due to conservative alias analysis
(that's my best guess, at least).  If you want to get good performance
on an Alpha, change the subroutines to do the following:

	(a) load all values from memory into temporary variables

	(b) do all the operations

	(c) store the results back into memory

This is a way of telling gcc that there really is no aliasing going
on.  I did this for routine svmva() and its execution time dropped
from 1.07 down to 0.56 seconds according to gprof.  Unfortunately, I
managed to destroy my optimized source, but it's really straight
forward (if error-prone) to apply the above changes.  It's funny, the
existing code looks very much like it has been optimized for an x86
(only one or two temporary values are used in the unrolled loops).

Another caveat: the file second.c uses times() which is known to be
broken on some (older?)  versions of the Linux/Alpha libc.  It would
be safer to use gettimeofday().

	--david

<--test3.c--><--test3.c--><--test3.c--><--test3.c-->
#include <stdio.h>
#include <stdlib.h>
#include "second.h"

void
report (int nx, int lx, float op, float tm)
{
  float mf = -1.;
  if (tm > 0.)
    mf = op / tm;
  printf ("%10d%10d%10.2f%10.2f\n", nx, lx, tm, mf);
}

extern void  svm   (float, float *, float *, int);
extern void  svmva (float, float *, float *, float *, int);
extern void  svmsa (float, float *, float, float *, int);
extern void  vvm   (float *, float *, float *, int);
extern void  vva   (float *, float *, float *, int);
extern float vsum  (float *, int);
extern float vdot  (float *, float *, int);

void
main (int argc, char *argv[])
{
#define LOOP 2000000
#define NM 7
#define NNX 500
  int OP, i, j, k, nx, nnx, lx, mmx;
  float a = .1, d, *x, *y, op, tm;
  double *px, *py, *pz;
  long str, LX, NX[NM] =
  {500, 1000, 5000, 10000, 50000, 100000, 500000};
  if (argc < 2)
    {
      printf ("Usage : %s loop-multiplier [stride]\n", argv[0]);
      exit (1);
    }
  sscanf (argv[1], "%ld", &LX);
  str = NNX;
  OP = 10;
  if (argc > 2)
    sscanf (argv[2], "%ld", &str);
  if (str <= 0)
    str = NX[NM];
  LX *= LOOP;
  printf ("      Size     Loops      Time    MFlops\n");
  for (j = 0; j < NM; j++)
    {
      nx = NX[j];
      lx = LX / nx;
      x = (float *) malloc (nx * sizeof (float));
      y = (float *) malloc (nx * sizeof (float));
      if (x == (float *) 0)
	{
	  puts ("Cannot allocate memory for x[]\n");
	  exit (-1);
	}
      if (y == (float *) 0)
	{
	  puts ("Cannot allocate memory for y[]\n");
	  exit (-1);
	}
      for (i = 0; i < nx; i++)
	{
	  x[i] = 1.;
	  y[i] = 0.;
	}
      op = (1.e-3 * (OP * nx)) * (1.e-3 * lx);
      d = 0.;
      tm = second ();
      nnx = (nx < str ? nx : str);
      for (k = 0; k < lx; k++)
	for (i = 0; i < nx; i += nnx)
	  {
	    mmx = nx - i;
	    mmx = (mmx < nnx ? mmx : nnx);
	    svm (a, &x[i], &y[i], mmx);
	    svmva (a, &x[i], &y[i], &y[i], mmx);
	    svmsa (a, &x[i], a, &y[i], mmx);
	    vvm (&x[i], &y[i], &y[i], mmx);
	    vva (&x[i], &y[i], &y[i], mmx);
	    d += vsum (&x[i], mmx);
	    d -= vdot (&x[i], &x[i], mmx);
	  }
      tm = second () - tm;
      report (nx, lx, op, tm);
      free (x);
      free (y);
    }
}
void
svm (float a, float *x, float *y, int n)
{
  int i, m;
  float t1, t2;
  m = n & ~7L;
  for (i = 0; i < m; i += 8)
    {
      t1 = a * x[i + 0];
      t2 = a * x[i + 1];
      y[i + 0] = t1;
      t1 = a * x[i + 2];
      y[i + 1] = t2;
      t2 = a * x[i + 3];
      y[i + 2] = t1;
      t1 = a * x[i + 4];
      y[i + 3] = t2;
      t2 = a * x[i + 5];
      y[i + 4] = t1;
      t1 = a * x[i + 6];
      y[i + 5] = t2;
      t2 = a * x[i + 7];
      y[i + 6] = t1;
      y[i + 7] = t2;
    }
  for (i = m; i < n; i++)
    y[i] = a * x[i];
  return;
}
void
svmva (float a, float *x, float *y, float *z, int n)
{
  int i, m;
  float t1, t2;
  m = n & ~7L;
  for (i = 0; i < m; i += 8)
    {
      t1 = a * x[i + 0];
      t2 = a * x[i + 1];
      t1 += y[i + 0];
      t2 += y[i + 1];
      z[i + 0] = t1;
      t1 = a * x[i + 2];
      z[i + 1] = t2;
      t1 += y[i + 2];
      t2 = a * x[i + 3];
      z[i + 2] = t1;
      t2 += y[i + 3];
      t1 = a * x[i + 4];
      z[i + 3] = t2;
      t1 += y[i + 4];
      t2 = a * x[i + 5];
      z[i + 4] = t1;
      t2 += y[i + 5];
      t1 = a * x[i + 6];
      z[i + 5] = t2;
      t2 = a * x[i + 7];
      t1 += y[i + 6];
      t2 += y[i + 7];
      z[i + 6] = t1;
      z[i + 7] = t2;
    }
  for (i = m; i < n; i++)
    z[i] = y[i] + a * x[i];
  return;
}
void
svmsa (float a, float *x, float b, float *y, int n)
{
  int i, m;
  float t1, t2;
  m = n & ~7L;
  for (i = 0; i < m; i += 8)
    {
      t1 = a * x[i + 0];
      t2 = a * x[i + 1];
      t1 += b;
      t2 += b;
      y[i + 0] = t1;
      t1 = a * x[i + 2];
      y[i + 1] = t2;
      t1 += b;
      t2 = a * x[i + 3];
      y[i + 2] = t1;
      t2 += b;
      t1 = a * x[i + 4];
      y[i + 3] = t2;
      t1 += b;
      t2 = a * x[i + 5];
      y[i + 4] = t1;
      t2 += b;
      t1 = a * x[i + 6];
      y[i + 5] = t2;
      t2 = a * x[i + 7];
      t1 += b;
      t2 += b;
      y[i + 6] = t1;
      y[i + 7] = t2;
    }
  for (i = m; i < n; i++)
    y[i] = a * x[i] + b;
  return;
}
void
vvm (float *x, float *y, float *z, int n)
{
  int i, m;
  float t1, t2;
  m = n & ~7L;
  for (i = 0; i < m; i += 8)
    {
      t1 = x[i + 0] * y[i + 0];
      t2 = x[i + 1] * y[i + 1];
      z[i + 0] = t1;
      t1 = x[i + 2] * y[i + 2];
      z[i + 1] = t2;
      t2 = x[i + 3] * y[i + 3];
      z[i + 2] = t1;
      t1 = x[i + 4] * y[i + 4];
      z[i + 3] = t2;
      t2 = x[i + 5] * y[i + 5];
      z[i + 4] = t1;
      t1 = x[i + 6] * y[i + 6];
      z[i + 5] = t2;
      t2 = x[i + 7] * y[i + 7];
      z[i + 6] = t1;
      z[i + 7] = t2;
    }
  for (i = m; i < n; i++)
    z[i] = x[i] * y[i];
  return;
}
void
vva (float *x, float *y, float *z, int n)
{
  int i, m;
  float t1, t2;
  m = n & ~7L;
  for (i = 0; i < m; i += 8)
    {
      t1 = x[i + 0] + y[i + 0];
      t2 = x[i + 1] + y[i + 1];
      z[i + 0] = t1;
      t1 = x[i + 2] + y[i + 2];
      z[i + 1] = t2;
      t2 = x[i + 3] + y[i + 3];
      z[i + 2] = t1;
      t1 = x[i + 4] + y[i + 4];
      z[i + 3] = t2;
      t2 = x[i + 5] + y[i + 5];
      z[i + 4] = t1;
      t1 = x[i + 6] + y[i + 6];
      z[i + 5] = t2;
      t2 = x[i + 7] + y[i + 7];
      z[i + 6] = t1;
      z[i + 7] = t2;
    }
  for (i = m; i < n; i++)
    z[i] = x[i] + y[i];
  return;
}
float
vsum (float *x, int n)
{
  int i, m;
  float vs, t1, t2, t3, t4;
  m = n & ~7L;
  t1 = t2 = 0.f;
  for (i = 0; i < m; i += 8)
    {
      t1 += x[i + 0];
      t2 += x[i + 1];
      t1 += x[i + 4];
      t2 += x[i + 5];
      t1 += x[i + 2];
      t2 += x[i + 3];
      t1 += x[i + 6];
      t2 += x[i + 7];
    }
  vs = t1 + t2;
  for (i = m; i < n; i++)
    vs += x[i];
  return vs;
}
float
vdot (float *x, float *y, int n)
{
  int i, m;
  float vs, t1, t2, s1, s2;
  m = n & ~7L;
  s1 = s2 = t1 = t2 = 0.f;
  for (i = 0; i < m; i += 8)
    {
      t1 = x[i + 0] * y[i + 0];
      s2 += t2;
      t2 = x[i + 1] * y[i + 1];
      s1 += t1;
      t1 = x[i + 2] * y[i + 2];
      s2 += t2;
      t2 = x[i + 3] * y[i + 3];
      s1 += t1;
      t1 = x[i + 4] * y[i + 4];
      s2 += t2;
      t2 = x[i + 5] * y[i + 5];
      s1 += t1;
      t1 = x[i + 6] * y[i + 6];
      s2 += t2;
      t2 = x[i + 7] * y[i + 7];
      s1 += t1;
    }
  vs = s1 + s2;
  for (i = m; i < n; i++)
    vs += x[i] * y[i];
  return vs;
}
<--second.c--><--second.c--><--second.c--><--second.c--><--second.c-->
#include <stdlib.h>
#include <unistd.h>
#include <sys/times.h>
#include "second.h"

double 
second ()
{
    struct tms buffer;

    times(&buffer);
    return buffer.tms_utime / (double) sysconf(_SC_CLK_TCK);
}

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: kernels 2.1.13* (fwd)
@ 1999-01-02 20:16 Dave Gilbert
  1999-01-02 20:15 ` Performance Herwin Jan Steehouwer
  0 siblings, 1 reply; 6+ messages in thread
From: Dave Gilbert @ 1999-01-02 20:16 UTC (permalink / raw)
  To: axp-list

On Sat, 2 Jan 1999 pancho@galaxy.lca.uevora.pt wrote:

> I am unable to get a clean compilation of kernels 2.1.130 and 2.1.131 in
> my axp PC164 LX running RH-5.1.
> 
> Got the following error messages during compilation of linux-2.1.131
> 
> make[1]: Entering directory `/home/pancho/linux/arch/alpha/kernel'
> gcc -D__KERNEL__ -I/home/pancho/linux/include -Wall -Wstrict-prototypes
> -O2 -fomit-frame-pointer -D__SMP__ -pipe -mno-fp-regs -ffixed-8 -mcpu=ev5
> -Wa,-mev6   -c -o irq.o irq.c
> irq.c: In function `__global_restore_flags':
> irq.c:528: internal error--unrecognizable insn:
> (jump_insn 81 80 82 (return) -1 (nil)
>     (nil))
> gcc: Internal compiler error: program cc1 got fatal signal 6

Thats a sign that your compiler is ill; get a recent version of the EGCS
compiler (I think there are RPMs somewhere on RedHats site); I normally
built recent EGCS versions from the source on
ftp://egcs.cygnus.com/pub/egcs

this message comes to you from an LX running 2.2.0-pre3 built with the
latest EGCS snapshot.

Dave

 --------------------------------------------------------------------   
/ Dr. David Alan Gilbert      | Running Linux on Alpha(LX) |  Happy  \ 
\   gro.gilbert @ treblig.org |   & ARM(EBSA285,old Arc)   |  In Hex /
 \____________________________|___ http://www.treblig.demon.co.uk __/


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: performance
@ 1996-06-14  9:45 Vareck Bostrom
  0 siblings, 0 replies; 6+ messages in thread
From: Vareck Bostrom @ 1996-06-14  9:45 UTC (permalink / raw)


Vareck Bostrom wrote:

> C:\users\bostrov\perf\WinRel>bench 10
> WARNING: this modified by Vareck Bostrom to build under MSVC2.0 under NT
> WARNING: the benchmark loop itself is unchanged
>       Size     Loops      Time    MFlops
>        500     40000      2.19     91.20
>       1000     20000      4.37     45.73
>       5000      4000      6.61     30.24
>      10000      2000      8.88     22.53
>      50000       400     12.88     15.53
>     100000       200     16.96     11.79
>     500000        40     21.17      9.45
> 
> - bostrov@teleport.com
> 
> I am an intel employee but am not speaking for intel in any way - personal test
> here guys (there, lawyer repellent applied).

Sorry to follow up on my own post, but after tinkering a bit with the compilation, 
performance attributes changed into somewhat more sane scores, in light of the spuratic 
scores that the alpha obtained (larger arrays scoring higher than smaller ones..., fairly 
even performance compared to the ppro which degraded rapidly with larger array sizes) 

Anyway, what I did was simply move the timer function into the main test file (test3.c), 
and leave the test itself unchanged. Also, this compile is with MSVC2.0. Here, performance 
drops drastically between size=10000 and size=50000 - perhaps running low on L2 cache? 

C:\users\bostrov\perf\WinRel>bench 10
WARNING: this modified by Vareck Bostrom to build under MSVC2.0 under NT
      Size     Loops      Time    MFlops
       500     40000      2.15     92.85
      1000     20000      2.17     92.04
      5000      4000      2.28     87.60
     10000      2000      2.26     88.38
     50000       400      4.15     48.24
    100000       200      4.09     48.95
    500000        40      4.51     44.39

C:\users\bostrov\perf\WinRel>

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: performance
@ 1996-06-14  8:44 Vareck Bostrom
  0 siblings, 0 replies; 6+ messages in thread
From: Vareck Bostrom @ 1996-06-14  8:44 UTC (permalink / raw)


Berndt Josef Wulf wrote:

> > Richard Henderson wrote:
> >    } 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

Hey guys, I thought you might be interested in some cross platform results. 

I had to change the timer routine somewhat to get it happy under NT, but otherwise 
it's the same code. Machine tested is a Dell Dimension XPS Pro200, 200 MHz Pentium 
Pro, 256kb L2 cache, 32 MB 2-way interleaved 60 ns FPM dram. I noticed that it 
seems to be operating on an array of floats - meaning if you have a 2 MB L3 cache 
alpha system this test almost never gets outside the cache- and the cache on the 
pentium pro is escaped pretty quickly, is only 256kb in size anyway, and has no L3 
cache to support the system outside that. 

System was NT 3.51 Workstation, Compiler was Intel Reference C Compiler 2.3.2 beta 
(and I got nearly identical numbers from MSVC 2.0, which is somewhat 
suspicious...)

I figure the pentium pro's L2 cache should be good to about the 50,000 size array 
(if they are indeed floats, haven't looked at that closely yet) so it's kind of 
interesting that performance drops off so rapidly compared to the small array 
sizes. Perhaps some strange unaligned access problem? Dunno. Anyway, take those 
numbers with a grain of salt, but thought you guys might be interested. 

Oh yes, compiler options were:
-O2 -Qip -Qmem -G6

C:\users\bostrov\perf\WinRel>bench 10
WARNING: this modified by Vareck Bostrom to build under MSVC2.0 under NT
WARNING: the benchmark loop itself is unchanged
      Size     Loops      Time    MFlops
       500     40000      2.19     91.20
      1000     20000      4.37     45.73
      5000      4000      6.61     30.24
     10000      2000      8.88     22.53
     50000       400     12.88     15.53
    100000       200     16.96     11.79
    500000        40     21.17      9.45

- bostrov@teleport.com

I am an intel employee but am not speaking for intel in any way - personal test 
here guys (there, lawyer repellent applied).

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: performance
@ 1996-06-13 22:50 Toon Moene
  0 siblings, 0 replies; 6+ messages in thread
From: Toon Moene @ 1996-06-13 22:50 UTC (permalink / raw)


David Mosberger-Tang <davidm@AZStarNet.com> wrote:

>  The source for test3 is appended below.  Note that gcc
>  is not doing a good job at optimizing the code due to
>  conservative alias analysis (that's my best guess, at
>  least).  If you want to get good performance on an Alpha,
>  change the subroutines to do the following:

Work on this is on its way.  I have been testing patches to the gcc  
backend by John Carr (jfc@mit.edu) that try to determine which  
items are and are not overlapping.  The results are promising.

Cheers,
Toon.

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: compile bug in gcc ? - was performance ...
@ 1996-06-12 19:45 Wim van Dorst
  1996-06-13 21:54 ` performance Berndt Josef Wulf
  0 siblings, 1 reply; 6+ messages in thread
From: Wim van Dorst @ 1996-06-12 19:45 UTC (permalink / raw)


Hello *,

Richard Henderson wrote:
   } 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

I am always keen to see how my PC, a 21066A/233 NoName,
performs in comparison with others. I took the programs
as posted by Arno Paehler, and compiled them with 'gcc -O3'
All three compiled problemless (warnings in test3, though),
and all three ran ok:

Test1:
      1000         1      0.13     61.54
Test2:
Transf Benchmark: loop length   :    10 * 10^3
Transf Benchmark: Time/MegaFlops:       2.85      63.16
Test3 1 25:
      Size     Loops      Time    MFlops
       500      4000      0.54     37.04
      1000      2000      0.56     35.71
      5000       400      2.80      7.14
     10000       200      2.95      6.78
     50000        40      3.17      6.31
    100000        20      3.18      6.29
    500000         4      3.26      6.13

I didn't exactly study on the precise meaning of these
results, but do I gather that my machine is about half or 
one third of a 21164/300? Good :-).

Met vriendelijke groeten, Wim van Dorst
--------------------------------------------------------------------
Blue Baron = Wim van Dorst, Voice (+31) 33 4676365, (+31) 35 5242319
(-:      baron@clifton.hobby.nl       WvD@Chem.AkzoNobel.nl      :-)
--------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-01-02 20:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-06-13 22:10 performance David Mosberger-Tang
  -- strict thread matches above, loose matches on Subject: below --
1999-01-02 20:16 kernels 2.1.13* (fwd) Dave Gilbert
1999-01-02 20:15 ` Performance Herwin Jan Steehouwer
1996-06-14  9:45 performance Vareck Bostrom
1996-06-14  8:44 performance Vareck Bostrom
1996-06-13 22:50 performance Toon Moene
1996-06-12 19:45 compile bug in gcc ? - was performance Wim van Dorst
1996-06-13 21:54 ` performance Berndt Josef Wulf

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