This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Performance measurements


Hi,
i tried to compare different compilers on my numerical code.
Therefore i extracted a FPU intensive function and surrounded
it with a loop while measuring the execution time.

I will provide the source and the Makefile at the end of this mail.

I work on a Linux 2.0.34 SMP Kernel (libc5). My hardware is a
dual Pentium Pro 200MHz system with 128MB RAM.

pgcc is the portland group compiler and 
tcc the free Tendra compiler system
(from http://alph.dera.gov.uk/TenDRA/)

Here are my results:
%> make
pgcc:
90.11 MFLOPS
gcc-2.7.2.1:
95.46 MFLOPS
gcc-without double align:
23.52 MFLOPS
egcs-2.91.42:
69.96 MFLOPS
tcc:
92.33 MFLOPS

- The difference -malign-double makes on gcc-2.7.2.1 is very 
  impressive. On egcs it doesn't change the result.

- egcs seems to produce worse code than gcc-2.7.2.1
- During my experience, pgcc produces very good code and is very
  reliable. The code usually runs about 25% faster than egcs-code.
- For tcc i have to say, that the result is very dependent on the 
  order, you declare the variables:
  If you put the declarations int i,j; and double *wksph=wksp+n/2;
  in front of the one for c[], the result drops down to 24.70 MFLOPS.
  For all other compilers, this doesn't make much difference.

Could anybody comment on that?

If anyone is interested in the asm code that pgcc produces, i 
can send it offline (388 lines of asm statements are too 
long for the list)


For the axp list: It would be very kind, if anybody could provide
some values for a Linux Alpha (e.g. 533MHz) for comparison.

Thanks in advance,
Martin


Here is the testfile m.c:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>

#define N 1024

void trafo(double *a,const int n,double *wksp,double *const ops)
{
 double c[]={ 3.52262918857095333469e-02,
             -8.54412738820266443041e-02,
             -1.35011020010254584323e-01,
              4.59877502118491543470e-01,
              8.06891509311092547385e-01,
              3.32670552950082631938e-01 };
 int i,j;
 double *wksph=wksp+n/2;

 if(n<6)
    return;

 for(i=j=0;i<n/2-2;i++,j+=2)
    {wksph[i]= c[0]*a[j]+c[1]*a[j+1]
     +c[2]*a[j+2]+c[3]*a[j+3]
         +c[4]*a[j+4]+c[5]*a[j+5];
     wksp[i] = c[5]*a[j]-c[4]*a[j+1]
         +c[3]*a[j+2]-c[2]*a[j+3]
         +c[1]*a[j+4]-c[0]*a[j+5];
    }
 wksph[i]= c[0]*a[j]+c[1]*a[j+1]
     +c[2]*a[j+2]+c[3]*a[j+3]
     +c[4]*a[0]+c[5]*a[1];
 wksp[i] = c[5]*a[j]-c[4]*a[j+1]
     +c[3]*a[j+2]-c[2]*a[j+3]
     +c[1]*a[0]-c[0]*a[1];
 i++;j+=2;
 wksph[i]= c[0]*a[j]+c[1]*a[j+1]
     +c[2]*a[0]+c[3]*a[1]
     +c[4]*a[2]+c[5]*a[3];
 wksp[i] = c[5]*a[j]-c[4]*a[j+1]
     +c[3]*a[0]-c[2]*a[1]
     +c[1]*a[2]-c[0]*a[3];

 memcpy(a,wksp,sizeof(double)*n);
 (*ops)+=((double)11)*n;
 return;
}

int main(int argc,const char *argv[])
{
 double *x,h,ops=0;
 int i;
 clock_t start;

 if(!(x=malloc(2*N*sizeof(double))))
    {
     fputs("out of memory\n",stderr);
     return EXIT_FAILURE;
    }

 for(i=0;i<N;i++)
    {
     h=(double)i;
     x[i]=sin(h*PI/(double)N);
    }

 start=clock();
 for(i=0;i<10000;i++)
     trafo(x,N,x+N,&ops);
 h=(double)(clock()-start)/(double)CLOCKS_PER_SEC;
 printf("%.2f MFLOPS\n",1.0e-6*ops/h);

 free(x);
 return 0;
}

And here is the Makefile:

EXECUTABLES = m.pgcc m.egcs-2.91.42 m.gcc-2.7.2.1 m.not_aligned m.tcc
GCC_OPTS = -O3 -malign-double -fomit-frame-pointer -Wall -malign-loops=2 -malign-jumps=2 -malign-functions=2
all: $(EXECUTABLES) test
clean:
	rm -f  $(EXECUTABLES)
test:
	@echo "pgcc:"
	@m.pgcc
	@echo "gcc-2.7.2.1:"
	@m.gcc-2.7.2.1
	@echo "gcc-without double align:"
	@m.not_aligned
	@echo "egcs-2.91.42:"
	@m.egcs-2.91.42
	@echo "tcc:"
	@m.tcc
m.pgcc: m.c
	pgcc -O2 -tp p6 -Mnoframe -o $@ $< -lm
m.gcc-2.7.2.1: m.c
	/usr/bin/gcc $(GCC_OPTS) -o $@ $< -lm
m.not_aligned: m.c
	/usr/bin/gcc -O3 -fomit-frame-pointer -Wall -malign-loops=2 -malign-jumps=2 -malign-functions=2 -o $@ $< -lm
m.egcs-2.91.42: m.c
	/sw/egcs/bin/gcc $(GCC_OPTS) -o $@ $< -lm
m.tcc: m.c
	tcc -Ysystem -O2 -o $@ $< -lm


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]