Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
* MFlops Comparison using g77 (bad news)
@ 1997-09-16  4:00 Luke Lonergan
  1997-09-16  4:00 ` Craig Burley
                   ` (4 more replies)
  0 siblings, 5 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-16  4:00 UTC (permalink / raw)




All,

I just installed RedHat 4.2, gcc-2.7.2.3 and g77-0.5.21 on a new Enorex 433
MHz Alpha
21164 machine. It uses the PC164 motherboard and has 256 MBytes of EDO RAM
installed.

I am running a simple Ocean model to benchmark machines. The computational
kernel is simple:

----------------------------------------------------------------------------
------------------------
	C    Operation count = 9 operations/grid point

      	do j = 2, ny-1
        	do i = 2, nx-1
          		psi_new(i,j) = a1*psi(i+1,j)+a2*psi(i-1,j)+
     &     	             	 a3*psi(i,j+1)+a4*psi(i,j-1)-
     &                 	 	 a5*f(i,j)
        	end do
      	end do
----------------------------------------------------------------------------
------------------------

This is the performance that I get:

	36 MFlops on the 21164 Alpha 433 MHz	(This is obviously unexpected)

	40 MFlops on the PPro 200MHz
	55 MFlops on the PentiumII 300 MHz
	70 MFlops on the SGI Origin 2000 (MIPS R10000 at 195 MHz)
	100 MFlops on the 21164 Alpha 450MHz on the Cray T3E
	1000 MFlops on the Cray T90

One of several things is wrong. It's not the memory system, as I observe
flat performance up to the 256 MBytes
of memory on the machine.

I think the compiler is the culprit. Any ideas?

Luke Lonergan
luke@navo.hpc.mil



^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: MFlops Comparison using g77 (bad news)
@ 1997-09-17  4:00 Robert Harley
  1997-09-22  4:00 ` Luke Lonergan
  0 siblings, 1 reply; 30+ messages in thread
From: Robert Harley @ 1997-09-17  4:00 UTC (permalink / raw)




Luke Lonergan (luke@navo.hpc.mil) writes:
>[...]
>I implemented the kernel in C this morning.  [...]
>
>----------------------------------------------------------------------------
>/*    Operation count = 9 operations/grid point */
>
>        for (j=1;j<*ny-1;j++) {
>
>          indj   = (*nx)*j;
>          indjp1 = (*nx)*(j+1);
>          indjm1 = (*nx)*(j-1);
>
>          for (i=1;i<*nx-1;i++) {
>            indx   = i+indj;
>            psi_new[indx] = (*a1)*psi[indx+1]+(*a2)*psi[indx-1]+
>                           (*a3)*psi[i+indjp1]+(*a4)*psi[i+indjm1]-
>                           (*a5)*f[indx];
>          }
>        }
>----------------------------------------------------------------------------
>
>[...]
>The answer is still dramatically (factor of 2?) lower than I would
>like, but interesting.  I thought the code generator was the culprit,
>but apparently the front end is involved in the Alpha's poor
>performance as well.

Your code loads *a1...*a6 and *nx repeatedly even though they
(presumably) don't change.  All these loads waste time and serialize
things that could otherwise be scheduled to make use of pipelining.
Use the forc^H^H^H^Hregisters, Luke!

Try something like the code below and let us know what happens.

Bye,
  Rob.
     .-.                     Robert.Harley@inria.fr                    .-.
    /   \           .-.                                 .-.           /   \
   /     \         /   \       .-.     _     .-.       /   \         /     \
  /       \       /     \     /   \   / \   /   \     /     \       /       \
 /         \     /       \   /     `-'   `-'     \   /       \     /         \
            \   /         `-'                     `-'         \   /
             `-'  Linux + 500MHz Alpha + 256MB SDRAM = heaven  `-'


/* > jacobi.c
 * Purpose: Ocean model kernel for Luke Lonergan (llonerga@worldnet.att.net).
 * Copyright: (c) Robert J. Harley, 17-Sep-1997
 * Contact: Robert.Harley@inria.fr
 * Legalese: You can do what you want with this code as long as this
 *           comment stays attached in a prominent position in
 *           human-readable form, any distribution of this or
 *           derived products is made without profit and includes
 *           full source and is subject to the same conditions.
 */

#ifndef __alpha
#error Use an Alpha!
#endif


/*== #defines ==============================================================*/

#ifdef DBL_PRECISION
#define FLOAT double
#else
#define FLOAT float
#endif


/*== Function declarations =================================================*/

extern void jacobi
  ( FLOAT *psi_new, FLOAT *psi, FLOAT *f
  , FLOAT *pa1, FLOAT *pa2, FLOAT *pa3, FLOAT *pa4, FLOAT *pa5
  , long *pnx, long *pny, long *pnx_max, long *pny_max
  );


/*== Function definitions ==================================================*/

/*-- jacobi ----------------------------------------------------------------*/

/* Rob's version. */
void jacobi
  ( FLOAT *psi_new, FLOAT *psi, FLOAT *f
  , FLOAT *pa1, FLOAT *pa2, FLOAT *pa3, FLOAT *pa4, FLOAT *pa5
  , long *pnx, long *pny, long *pnx_max, long *pny_max
  ) {

  long i, j, nx, ny, tmp;
  FLOAT a1, a2, a3, a4, a5, *ff, *out, *pu, *pv, *pw;

  /** Arguments are all pointers (for Fortran), dereference some of them. **/
  nx = *pnx; ny = *pny;
  a1 = *pa1; a2 = *pa2; a3 = *pa3; a4 = *pa4; a5 = *pa5;

  /** Main loop. **/
  for (j = 1; j < ny-1; ++j) {

    /* Inner loop unrolled four times. */
    tmp = j*nx+1; pv = psi+tmp; ff = f+tmp; out = psi_new+tmp;
    i = nx-2;

    /* Do chunks of four. */
    while (i >= 4) {
      FLOAT u0,u1,u2,u3, vm,v0,v1,v2,v3,v4, w0,w1,w2,w3, f0,f1,f2,f3;

      pu = pv-nx; pw = pv+nx;

                   u0 = pu[0]; u1 = pu[1]; u2 = pu[2]; u3 = pu[3];
      vm = pv[-1]; v0 = pv[0]; v1 = pv[1]; v2 = pv[2]; v3 = pv[3]; v4 = pv[4];
                   w0 = pw[0]; w1 = pw[1]; w2 = pw[2]; w3 = pw[3];

                   f0 = ff[0]; f1 = ff[1]; f2 = ff[2]; f3 = ff[3];
      
      out[0] = a1*v1 + a2*vm + a3*w0 + a4*u0 - a5*f0;
      out[1] = a1*v2 + a2*v0 + a3*w1 + a4*u1 - a5*f1;
      out[2] = a1*v3 + a2*v1 + a3*w2 + a4*u2 - a5*f2;
      out[3] = a1*v4 + a2*v2 + a3*w3 + a4*u3 - a5*f3;

      i -= 4; pv += 4; ff += 4; out += 4;
    } /* end while */

    /* Do last 0, 1, 2 or 3. */
    while (i) {
      *out = a1*pv[1] + a2*pv[-1] + a3*pv[nx] + a4*pv[-nx] - a5*ff[0];
      --i; ++pv; ++ff; ++out;
    } /* end while */

  } /* end for (j) */

} /* end jacobi */


/*== end of file jacobi.c ==================================================*/





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

end of thread, other threads:[~1997-09-22  4:00 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-09-16  4:00 MFlops Comparison using g77 (bad news) Luke Lonergan
1997-09-16  4:00 ` Craig Burley
1997-09-16  4:00 ` Toon Moene
1997-09-16  4:00   ` MFlops Comparison using g77 (bad news) - bench.tgz (1/1) Luke Lonergan
1997-09-16  4:00   ` MFlops Comparison using g77 (bad news) Luke Lonergan
1997-09-17  4:00     ` Linus Torvalds
1997-09-17  4:00       ` Luke Lonergan
1997-09-17  4:00         ` MFlops Comparison using g77 (bad news) - dpkernel.tgz (0/1) Luke Lonergan
1997-09-17  4:00           ` MFlops Comparison using g77 (bad news) - dpkernel.tgz (0/1) - dpkernel.tgz (1/1) Luke Lonergan
1997-09-17  4:00           ` MFlops Comparison using g77 (bad news) - dpkernel.tgz (0/1) - dpkernel.tgz (0/1) Luke Lonergan
1997-09-17  4:00         ` MFlops Comparison using g77 (bad news) - dpkernel.tgz (1/1) Luke Lonergan
1997-09-17  4:00       ` MFlops Comparison using g77 (bad news) Greg Lindahl
1997-09-17  4:00       ` Rowan D. Hughes
1997-09-17  4:00         ` Xiaoguang Zhang
1997-09-19  4:00     ` James Lewis Nance
1997-09-22  4:00       ` Luke Lonergan
1997-09-16  4:00   ` Greg Lindahl
1997-09-16  4:00   ` MFlops Comparison using g77 (bad news) - bench.tgz (0/1) Luke Lonergan
1997-09-18  4:00     ` H.W. Stockman
1997-09-18  4:00     ` Thomas Leitner
1997-09-18  4:00       ` Andrew G. Morgan
1997-09-16  4:00 ` MFlops Comparison using g77 (bad news) H.W. Stockman
1997-09-16  4:00   ` Greg Lindahl
1997-09-16  4:00 ` Ulrich Ruede
1997-09-18  4:00 ` Greg Lindahl
1997-09-19  4:00   ` Burkhard Neidecker-Lutz
1997-09-20  4:00     ` Toon Moene
1997-09-22  4:00   ` Luke Lonergan
  -- strict thread matches above, loose matches on Subject: below --
1997-09-17  4:00 Robert Harley
1997-09-22  4:00 ` Luke Lonergan

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