Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Re: interesting benchmarks
       [not found] <qtkWcFAFGBLyEw+Q@fgel.demon.co.uk>
@ 1996-09-03 22:55 ` Robert Allen Barker
  1996-09-04  8:24 ` interesting benchmarks, which gcc ? Nigel Sale
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Allen Barker @ 1996-09-03 22:55 UTC (permalink / raw)


Nigel,

Optimizing the code for Alpha I get the following:

                      pentium-166   21164-500  Alpha MFLOPS
                      -----------   ---------  ------------
initial version          22.3        12.15        66
RISC version             28.0         1.70       470
RISC with multiply       28.0	      1.11       720

There are two primary reasons for the apparent 'slowness' of the Alpha
chip. 1) Alpha pays a heavy penalty for converting from int to double 
because, although it can do the conversion quickly, the floating point
register must be stored in memory and then retrieved into an integer 
register. 2) the code has not been tailored to a RISC environment taking
advantage of the pipelining.

I tried rewriting the floating point version removing the conversion, 
putting everything into registers, and unrolling the loop a bit to four
calculations per loop instead of one. I also made four seperate results
c0 .. c3 to prevent the pipes from stalling while waiting for previous
results. (these changes are quite common to RISC and 'super computer'
loops) The difference between Alpha and intel becomes clear with the
Alpha achieving 470 of its theoretical 500 MFLOPS for this code. In the
last test I replaced the calculation with '*' instead of '-' which
allows the Alpha to dual issue the floating point operations because
they are now a mix of '*' and '-'. Alas, none of these optimizations can
help the poor old pentium.

This benchmark is an excellent example of the difference between a RISC
processor and an intel type machine. Perhaps the best way to compare two
different architectures is to optimize the code for each individually.  

-------------------------------------------------------------------------

#include <stdio.h>

#define MAXI 100
#define MAXJ 1000
#define MAXK 500
#define MAXKF 100
/*------------------------------------------------------------------------*/
main()
{
	benchf();
	benchf2();
	/*benchi();*/
}
/*------------------------------------------------------------------------*/

benchi()
{
  int i, j, k;
  int a, b, c;

  for (i=0;i<MAXI;i++) {
    a = i;
    for (j=MAXJ;j>-MAXJ;j--) {
      b = a*j;
      for (k=MAXK;k>-MAXK;k--) {
        c = b + k;
      }
    }
  }
  printf("%d %d %d\n",a ,b, c);
}
/*------------------------------------------------------------------------*/
benchf()
{
  int i, j, k;
  double a, b, c;

  for (i=0;i<MAXI;i++) {
    a = (double)i;
    for (j=MAXJ;j>-MAXJ;j--) {
      b = a*(double)j;
	for (k=MAXKF;k>-MAXKF;k--) {
        c = b + (double)k;
      }
    }
  }
  printf("%f %f %f\n",a ,b, c);
}
/*------------------------------------------------------------------------*/
benchf2()
{
  int i, j,k;
  double a, b, c0,c1,c2,c3;
  double kf0,kf1,kf2,kf3,one,four;
    
    one=1.00;four=4.0;

    for (i=0;i<MAXI;i++) {
    a = (double)i;
    for (j=MAXJ;j>-MAXJ;j--) {
      b = a*(double)j;
      kf0=MAXKF;
      kf1=kf0-one;
      kf2=kf1-one;
      kf3=kf2-one;
      for (k=MAXKF;k>-MAXKF;k-=4) {
        c0 = b + kf0;
	kf0=kf0-four;
        c1 = b + kf1;
	kf1=kf1-four;
        c2 = b + kf2;
	kf2=kf2-four;
        c3 = b + kf3;
	kf3=kf3-four;
       }
    }
  }
  printf("%f %f %f\n",a ,b, c0+c1+c2+c3);
  /* I must print all 4 cxs or else the optimizer will remove some of the 
   inner loop*/
}
/*------------------------------------------------------------------------*/

--
To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null

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

* interesting benchmarks, which gcc ?
       [not found] <qtkWcFAFGBLyEw+Q@fgel.demon.co.uk>
  1996-09-03 22:55 ` interesting benchmarks Robert Allen Barker
@ 1996-09-04  8:24 ` Nigel Sale
  1 sibling, 0 replies; 3+ messages in thread
From: Nigel Sale @ 1996-09-04  8:24 UTC (permalink / raw)


In message <qtkWcFAFGBLyEw+Q@fgel.demon.co.uk>, nms@fgel.demon.co.uk
writes
>
>The execution time (to the nearest second) for the integer program on
>the UDB is 35 secs. On a Pentium 166 Mhz system (running Linux of
>course) the execution time is 101 secs. Great i thought.
>
>For the floating point program the UDB time is 30 secs. On the Pentium
>system the time is 20 secs.
>
>Where am i going wrong ?
>
>I'm running RedHat 3.0.3/AXP straight out of the box, no tweeks ( so gcc
>2.7.0 ). I've tried complier options such as no-soft-float and fp-regs
>but it makes no difference.
>
>Thanks in advance.

Actually, i think its gcc 2.7.1, but im wondering if i should bother
converting to ELF and gcc 2.7.2. Will i see any performance benefit ?
What are the differences between the two, specifically with alpha in
mind.

Thanks

-- 
Nigel Sale

--
To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null

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

* Re: interesting benchmarks, which gcc ?
       [not found] <eNt7EHAiyTLyEwaR@fgel.demon.co.uk>
@ 1996-09-04 14:58 ` Richard Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 1996-09-04 14:58 UTC (permalink / raw)


> Actually, i think its gcc 2.7.1, but im wondering if i should bother
> converting to ELF and gcc 2.7.2. Will i see any performance benefit ?
> What are the differences between the two, specifically with alpha in
> mind.

Bug fixes, mostly.

2.8 will have quite a few performance improvements, including ev5
scheduling and ev56 byte/word load/store.

r~

--
To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null

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

end of thread, other threads:[~1996-09-04 14:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <qtkWcFAFGBLyEw+Q@fgel.demon.co.uk>
1996-09-03 22:55 ` interesting benchmarks Robert Allen Barker
1996-09-04  8:24 ` interesting benchmarks, which gcc ? Nigel Sale
     [not found] <eNt7EHAiyTLyEwaR@fgel.demon.co.uk>
1996-09-04 14:58 ` Richard Henderson

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