* FAST interesting benchmarks
@ 1996-09-03 23:08 Robert Allen Barker
0 siblings, 0 replies; only message in thread
From: Robert Allen Barker @ 1996-09-03 23:08 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] only message in thread
only message in thread, other threads:[~1996-09-03 23:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-09-03 23:08 FAST interesting benchmarks Robert Allen Barker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox