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 ` H.W. Stockman
                   ` (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-16  4:00 MFlops Comparison using g77 (bad news) Luke Lonergan
                   ` (2 preceding siblings ...)
  1997-09-16  4:00 ` Toon Moene
@ 1997-09-16  4:00 ` Craig Burley
  1997-09-18  4:00 ` Greg Lindahl
  4 siblings, 0 replies; 30+ messages in thread
From: Craig Burley @ 1997-09-16  4:00 UTC (permalink / raw)



"Luke Lonergan" <llonerga@worldnet.att.net> writes:

> 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?

That's my guess.  Try another Fortran compiler, one highly optimized
for the Alpha, and I'll bet you see *much* better numbers.  g77 has
a ways to go to generate great code for Alphas; at least it seems
to work adequately for now, but clearly there's plenty of room for
improvement.
-- 

"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson    burley@gnu.ai.mit.edu



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-16  4:00 MFlops Comparison using g77 (bad news) Luke Lonergan
  1997-09-16  4:00 ` H.W. Stockman
@ 1997-09-16  4:00 ` Ulrich Ruede
  1997-09-16  4:00 ` Toon Moene
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 30+ messages in thread
From: Ulrich Ruede @ 1997-09-16  4:00 UTC (permalink / raw)



In article <5vl4lv$8ko@bgtnsc03.worldnet.att.net>,
	"Luke Lonergan" <llonerga@worldnet.att.net> writes:

	[ ... ]
> 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:
> 
	[ ... ]
> 
> 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?

This must be the compiler's fault. You may experiment with the compiler
flags, but most likely g77 just is not capable of exploiting the Alpha
architecture reasonably well yet.

For a similar kernel (red-black ordering to improve vectorization),
see a preliminary comparison of various machines at
http://scicomp.math.uni-augsburg.de/ruede/cache/rb/docu.html
Here the Alpha (with 500 Mhz) shows a peak rate of 400+x MFlops, and in a
modified code I have seen rates of 700+ Mflops. However this was done by
using the original Digital FORTRAN compiler.

Unfortunately I do not know many compiler alternatives under Linux for the
Alpha. The only one I know of is http://www.microway.com/ndpfort.html
Are there others out there?

Uli
__________________________________________________________________________
Ulrich Ruede, Institut fuer Mathematik, Universitaet Augsburg
D-86135 Augsburg, Germany, e-mail: ruede@math.uni-augsburg.de
Tel: +49 821 598 2190, Fax: +49 821 598 2339
URL: http://scicomp.math.uni-augsburg.de/ruede/me.html



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-16  4:00 MFlops Comparison using g77 (bad news) Luke Lonergan
@ 1997-09-16  4:00 ` H.W. Stockman
  1997-09-16  4:00   ` Greg Lindahl
  1997-09-16  4:00 ` Ulrich Ruede
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 30+ messages in thread
From: H.W. Stockman @ 1997-09-16  4:00 UTC (permalink / raw)
  To: Luke Lonergan


Luke Lonergan wrote:
[...]
> ------------------------
>         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
[...]
> I think the compiler is the culprit. Any ideas?

The compiler is probably the culprit.  We don't know
how big your arrays are, so there is a chance you are thrashing
the cache with all that column-flipping, but I doubt it.  

About a year back we did some
comparisons among various architechtures and compilers, and
found: (1) g77 generally produced code a factor of 2 to 3 slower
than the commercial compilers (like Lahey on the PPro, DEC
FORTRAN on the alpha); for our memory-intensive tests, a 500
MHz DECalpha system was about 3 times faster than a 200 MHz
PPro.  Unfortunately, the tests were slightly skewed by the fact
that the alpha had 8 MB L3 on a total array set of about 12 MB,
but subsequent tests suggested at least a factor of 2.

On gcc code, one fellow did some "quick" gcc hand optimizations --
mainly stuffing important variables into registers -- and 
improved the alpha performance by nearly a factor of two.

You might request someone try to compile your code with
egcs-inspired g77.  I saw a note here recently (possibly
from Craig Burley?) that such a combination was possible.



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-16  4:00 ` H.W. Stockman
@ 1997-09-16  4:00   ` Greg Lindahl
  0 siblings, 0 replies; 30+ messages in thread
From: Greg Lindahl @ 1997-09-16  4:00 UTC (permalink / raw)



"H.W. Stockman" <hwstock@swcp.com> writes:

> About a year back we did some
> comparisons among various architechtures and compilers, and
> found: (1) g77 generally produced code a factor of 2 to 3 slower
> than the commercial compilers (like Lahey on the PPro,

However, on the PPro, once you've fixed the fact that the stack isn't
properly double-word aligned, g77 is doing very well on SPECfp95 these
days. Perhaps there's a similar smoking gun on the alpha?

-- g



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-16  4:00 MFlops Comparison using g77 (bad news) Luke Lonergan
  1997-09-16  4:00 ` H.W. Stockman
  1997-09-16  4:00 ` Ulrich Ruede
@ 1997-09-16  4:00 ` Toon Moene
  1997-09-16  4:00   ` MFlops Comparison using g77 (bad news) - bench.tgz (1/1) Luke Lonergan
                     ` (3 more replies)
  1997-09-16  4:00 ` MFlops Comparison using g77 (bad news) Craig Burley
  1997-09-18  4:00 ` Greg Lindahl
  4 siblings, 4 replies; 30+ messages in thread
From: Toon Moene @ 1997-09-16  4:00 UTC (permalink / raw)



"Luke Lonergan" <llonerga@worldnet.att.net> wrote:

> 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
> 
----------------------------------------------------------------------------
> ------------------------

[ ... Horrendous performance figures ... ]

> 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?

This sort of code tends to benefit rather handsomely from the optimisation 
known as "strength reduction", basically changing all array index arithmetic 
by simple stride 4 (or 8 in case of DOUBLE PRECISION) steps through the 
arrays.

However, in g77 "strength reduction" is almost completely ineffective on the 
Alpha, because the optimisation pass doesn't know how to deal with subword 
integers (the default INTEGER in g77 is 32 bits wide, which is half of a 
64-bit register).

I'm working on a solution to this problem, but so far I've produced nothing 
more than a patch purely as a Gedankenexperiment (on a Motorola 68040 based 
NEXTSTATION ;-)

-- 
Toon Moene (mailto:toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: mailto:fortran@gnu.ai.mit.edu; NWP: http://www.knmi.nl/hirlam



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

* Re: MFlops Comparison using g77 (bad news)
  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-16  4:00   ` Greg Lindahl
  1997-09-16  4:00   ` MFlops Comparison using g77 (bad news) - bench.tgz (0/1) Luke Lonergan
  3 siblings, 0 replies; 30+ messages in thread
From: Greg Lindahl @ 1997-09-16  4:00 UTC (permalink / raw)



Toon Moene <toon@moene.indiv.nluug.nl> writes:

> However, in g77 "strength reduction" is almost completely ineffective on the 
> Alpha, because the optimisation pass doesn't know how to deal with subword 
> integers (the default INTEGER in g77 is 32 bits wide, which is half of a 
> 64-bit register).

If this theory is correct, then f2c should produce much better code for
this particular example -- once translated to C, the index values are
cast to 64-bit quantities, and gcc should be able to strength-reduce those.

-- g



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

* Re: MFlops Comparison using g77 (bad news) - bench.tgz (1/1)
  1997-09-16  4:00 ` Toon Moene
@ 1997-09-16  4:00   ` Luke Lonergan
  1997-09-16  4:00   ` MFlops Comparison using g77 (bad news) Luke Lonergan
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-16  4:00 UTC (permalink / raw)



begin 644 bench.tgz
<encoded_portion_removed>
end



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

* Re: MFlops Comparison using g77 (bad news) - bench.tgz (0/1)
  1997-09-16  4:00 ` Toon Moene
                     ` (2 preceding siblings ...)
  1997-09-16  4:00   ` Greg Lindahl
@ 1997-09-16  4:00   ` Luke Lonergan
  1997-09-18  4:00     ` H.W. Stockman
  1997-09-18  4:00     ` Thomas Leitner
  3 siblings, 2 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-16  4:00 UTC (permalink / raw)



On 16 Sep 1997 19:04:44 GMT, Toon Moene <toon@moene.indiv.nluug.nl>
wrote:


>However, in g77 "strength reduction" is almost completely ineffective on the 
>Alpha, because the optimisation pass doesn't know how to deal with subword 
>integers (the default INTEGER in g77 is 32 bits wide, which is half of a 
>64-bit register).

I implemented the kernel in C this morning. Unfortunately my news
server was screwed up at work so I couldn't post the results until
now:

----------------------------------------------------------------------------
/*    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];
          }
        }
----------------------------------------------------------------------------

I expected the result to be similar to the Fortran version, but lo and
behold:

        48 MFlops, 433 MHz Alpha using gcc and the C kernel
        36 MFlops, 433 MHz Alpha using g77

        36 MFlops on the PPro 200 using gcc and the C kernel
        40 MFlops on the PPro 200 using g77

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.

BTW, the compiler options I used were:
	-ffast-math -O2 (-m486 on the PPro)

I tried using the -fstrength-reduce on the C kernel and the Fortran
and got no change on the Fortran (36 MFlops) and a bump to the
C (49 MFlops versus 48).

I am posting the source tree here for anyone else who would like to
take a whack at it.

Luke




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

* Re: MFlops Comparison using g77 (bad news)
  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   ` Luke Lonergan
  1997-09-17  4:00     ` Linus Torvalds
  1997-09-19  4:00     ` James Lewis Nance
  1997-09-16  4:00   ` Greg Lindahl
  1997-09-16  4:00   ` MFlops Comparison using g77 (bad news) - bench.tgz (0/1) Luke Lonergan
  3 siblings, 2 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-16  4:00 UTC (permalink / raw)



On 16 Sep 1997 19:04:44 GMT, Toon Moene <toon@moene.indiv.nluug.nl>
wrote:

>However, in g77 "strength reduction" is almost completely ineffective on the 
>Alpha, because the optimisation pass doesn't know how to deal with subword 
>integers (the default INTEGER in g77 is 32 bits wide, which is half of a 
>64-bit register).

I implemented the kernel in C this morning. Unfortunately my news
server was screwed up at work so I couldn't post the results until
now:

----------------------------------------------------------------------------
/*    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];
          }
        }
----------------------------------------------------------------------------

I expected the result to be similar to the Fortran version, but lo and
behold:

        48 MFlops, 433 MHz Alpha using gcc and the C kernel
        36 MFlops, 433 MHz Alpha using g77

        36 MFlops on the PPro 200 using gcc and the C kernel
        40 MFlops on the PPro 200 using g77

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.

BTW, the compiler options I used were:
	-ffast-math -O2 (-m486 on the PPro)

I tried using the -fstrength-reduce on the C kernel and the Fortran
and got no change on the Fortran (36 MFlops) and a bump to the
C (49 MFlops versus 48).

I am posting the source tree here for anyone else who would like to
take a whack at it.

Luke



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

* Re: MFlops Comparison using g77 (bad news)
  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       ` Greg Lindahl
                         ` (2 more replies)
  1997-09-19  4:00     ` James Lewis Nance
  1 sibling, 3 replies; 30+ messages in thread
From: Linus Torvalds @ 1997-09-17  4:00 UTC (permalink / raw)



In article <341f1031.69553746@netnews.worldnet.att.net>,
Luke Lonergan <luke@navo.hpc.mil> wrote:
>
>I implemented the kernel in C this morning. Unfortunately my news
>server was screwed up at work so I couldn't post the results until
>now:
>
>----------------------------------------------------------------------------
>/*    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];
>          }
>        }
>----------------------------------------------------------------------------

You left out the definitions for the variables, but let me guess: they
are all "int" rather than "long"?

Change them all to "long" and see whether that makes a difference. At
least in theory gcc should have a much easier time with long, simply
because then gcc is using only 64-bit quantities. 

With your current code, you're mixing 32-bit and 64-bit arithmetic,
which limits the code generation a lot (because order matters when you
mix different sizes).

On a PPro you'll never see this, because everything is 32 bits, obviously, 

		Linus



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

* Re: MFlops Comparison using g77 (bad news) - dpkernel.tgz (0/1)
  1997-09-17  4:00       ` Luke Lonergan
  1997-09-17  4:00         ` MFlops Comparison using g77 (bad news) - dpkernel.tgz (1/1) Luke Lonergan
@ 1997-09-17  4:00         ` 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
  1 sibling, 2 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-17  4:00 UTC (permalink / raw)



All

Here is the double precision ocean model benchmark kernel.

I would really like to see some better results on the Alpha (see the
previous news thread with the same name), perhaps obtained using the
NDP or NAG Fortran compilers.

Luke



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

* Re: MFlops Comparison using g77 (bad news) - dpkernel.tgz (1/1)
  1997-09-17  4:00       ` Luke Lonergan
@ 1997-09-17  4:00         ` Luke Lonergan
  1997-09-17  4:00         ` MFlops Comparison using g77 (bad news) - dpkernel.tgz (0/1) Luke Lonergan
  1 sibling, 0 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-17  4:00 UTC (permalink / raw)



begin 644 dpkernel.tgz
<encoded_portion_removed>
end



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

* Re: MFlops Comparison using g77 (bad news) - dpkernel.tgz (0/1) - dpkernel.tgz (1/1)
  1997-09-17  4:00         ` MFlops Comparison using g77 (bad news) - dpkernel.tgz (0/1) Luke Lonergan
@ 1997-09-17  4:00           ` Luke Lonergan
  1997-09-17  4:00           ` MFlops Comparison using g77 (bad news) - dpkernel.tgz (0/1) - dpkernel.tgz (0/1) Luke Lonergan
  1 sibling, 0 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-17  4:00 UTC (permalink / raw)



begin 644 dpkernel.tgz
<encoded_portion_removed>
end



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-17  4:00     ` Linus Torvalds
  1997-09-17  4:00       ` Greg Lindahl
@ 1997-09-17  4:00       ` 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) - dpkernel.tgz (0/1) Luke Lonergan
  1997-09-17  4:00       ` MFlops Comparison using g77 (bad news) Rowan D. Hughes
  2 siblings, 2 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-17  4:00 UTC (permalink / raw)



On 17 Sep 1997 00:22:42 GMT, torvalds@transmeta.com (Linus Torvalds)
wrote:

>You left out the definitions for the variables, but let me guess: they
>are all "int" rather than "long"?
Correct. However, I implemented the indices as "long" type later to no
effect. I was thinking of just declaring temporary pointers to the
float arrays and incrementing them in the loop, but haven't done it
yet because I think it won't change much.

>Change them all to "long" and see whether that makes a difference. At
>least in theory gcc should have a much easier time with long, simply
>because then gcc is using only 64-bit quantities. 

Actually I checked the types of the indices and other variables from
within gdb and found that they were all 32 bit. Registers that are
allocated by the compiler are probably 64 bit, though.

After some work, I changed _everything_ in the Fortran and C to be 64
bit, including the integers. Here is the result:
	
	34 MFlops	Alpha 433 MHz gcc with C kernel, all 64 bit
	34 MFlops	Alpha 433 MHz gcc with C kernel, 64 bit floats
	28  MFlops	Alpha 433 MHz g77, all 64 bit

These aren't bad 64 bit numbers, but they aren't up to expectations.

I will post the 64 bit source tree following this message.

I would really like to see results on another compiler like NDP or NAG
for the Alpha...
 
Luke



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

* Re: MFlops Comparison using g77 (bad news) - dpkernel.tgz (0/1) - dpkernel.tgz (0/1)
  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           ` Luke Lonergan
  1 sibling, 0 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-17  4:00 UTC (permalink / raw)



For some reason, the attachment didn't upload, I'll try again....



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-17  4:00     ` Linus Torvalds
@ 1997-09-17  4:00       ` Greg Lindahl
  1997-09-17  4:00       ` Luke Lonergan
  1997-09-17  4:00       ` MFlops Comparison using g77 (bad news) Rowan D. Hughes
  2 siblings, 0 replies; 30+ messages in thread
From: Greg Lindahl @ 1997-09-17  4:00 UTC (permalink / raw)



torvalds@transmeta.com (Linus Torvalds) writes:

> Change them all to "long" and see whether that makes a difference. At
> least in theory gcc should have a much easier time with long, simply
> because then gcc is using only 64-bit quantities. 
> 
> With your current code, you're mixing 32-bit and 64-bit arithmetic,
> which limits the code generation a lot (because order matters when you
> mix different sizes).

Actually, we've already seen that the g77 generated code is more
restrictive than the f2c/gcc generated code. Yes, it's a difficult
problem, but it's extremely important to get this right. Presumably
Dec's compiler does, although it may not handle wrap-around
properly... you would only notice that for huge arrays.

> On a PPro you'll never see this, because everything is 32 bits, obviously, 

You might be able to similarly confuse gcc by using lots of shorts.

I once worked on a million line F66 program which broke the VMS optimizer
by using lots of INTEGER*2 variables. If you have different cases for
different sizes of things, you leave yourself open to having
a tiny bug in a rarely-used case...

-- g




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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-17  4:00     ` Linus Torvalds
  1997-09-17  4:00       ` Greg Lindahl
  1997-09-17  4:00       ` Luke Lonergan
@ 1997-09-17  4:00       ` Rowan D. Hughes
  1997-09-17  4:00         ` Xiaoguang Zhang
  2 siblings, 1 reply; 30+ messages in thread
From: Rowan D. Hughes @ 1997-09-17  4:00 UTC (permalink / raw)



On 17 Sep 1997 00:22:42 GMT, Linus Torvalds <torvalds@transmeta.com> wrote:
>In article <341f1031.69553746@netnews.worldnet.att.net>,
>Luke Lonergan <luke@navo.hpc.mil> wrote:
>>
>>I implemented the kernel in C this morning. Unfortunately my news
>>server was screwed up at work so I couldn't post the results until
>>now:
>>
>>----------------------------------------------------------------------------
...[snip
>>
>>        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];
>>          }
>>        }
>>----------------------------------------------------------------------------
>
>You left out the definitions for the variables, but let me guess: they
>are all "int" rather than "long"?

I presume he's updating a stream function or vorticity-driving fn, and
so will be REAL*4 or *8. Definitely *8 on the C90. Enough digression.

One simple thing--it has caught me before--he should check that the g77
code is giving the correct answers. If all machines are IEEE compliant
(the C90 won't be) all answers should be *very* close to each other.
They should be *identical* with -O0. g77 has some problems with
-f-move-all-movables; it can sometimes fail to see a dependancy within
a loop. Also, loop-unrolling can make a huge (x7) difference on alphas and
I vaguely remember gcc/g77 having some trouble with this a while ago.
Thusly, I concur with the others that g77 is the most likely culprit.
Using f2c + gcc + yaf will probably yield the same problems found with g77.
Time to spend  money on Nastran, NAG, Microway, or wait for the
re-worked g77. Good f77/90 is not Free (tm).

=================================================================
Rowan Hughes, Maths Dept, James Cook University. x-csrdh@lion.jcu.edu.au



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-17  4:00       ` MFlops Comparison using g77 (bad news) Rowan D. Hughes
@ 1997-09-17  4:00         ` Xiaoguang Zhang
  0 siblings, 0 replies; 30+ messages in thread
From: Xiaoguang Zhang @ 1997-09-17  4:00 UTC (permalink / raw)



If anyone think that any commercial fortran compiler is necessarily better,
here is a data point for our fortran code on a 500MHz Alpha running Redhat
Linux:
DEC fortran:               512 MFLOPs
NDP fortran (Microway):     20 MFLOPs    (no typo here, two-zero)!
Someone here played a little with f2c/gcc and my impression was that it
gave about 50 MFLOPs.

Not all compilers are equal.

Xiaoguang Zhang



^ 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

* Re: MFlops Comparison using g77 (bad news) - bench.tgz (0/1)
  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
  1 sibling, 1 reply; 30+ messages in thread
From: Thomas Leitner @ 1997-09-18  4:00 UTC (permalink / raw)



In article <341f0c1d.68509433@netnews.worldnet.att.net> you wrote:
> On 16 Sep 1997 19:04:44 GMT, Toon Moene <toon@moene.indiv.nluug.nl>
> wrote:

>         48 MFlops, 433 MHz Alpha using gcc and the C kernel
>         36 MFlops, 433 MHz Alpha using g77

>         36 MFlops on the PPro 200 using gcc and the C kernel
>         40 MFlops on the PPro 200 using g77

This is what I get on an AlphaStation 500/500 running Digital Unix 4.0b
using DEC CC and DEC F77 and the code you've posted as bench.tgz 
with the following options:

           FOPTIONS = -O5
           COPTIONS = -DUSCORE -O3 -fast

           MFlops/Second =    93.03, C-Kernel
           MFlops/Second =   123.79, F-Kernel

Looks as if DEC compilers are really much better than GNU stuff ??

Tom
-- 
--------------------------------------------------------------------------
T o m   L e i t n e r                       Dept. of Communications
                                            Graz University of Technology, 
e-mail    : tom@finwds01.tu-graz.ac.at      Inffeldgasse 12
Phone     : +43-316-873-7455                A-8010 Graz / Austria / Europe
Fax       : +43-316-463-697
Home page : http://wiis.tu-graz.ac.at/people/tom.html
PGP public key on : ftp://wiis.tu-graz.ac.at/pgp-keys/tom.asc or send 
mail with subject "get Thomas Leitner" to pgp-public-keys@keys.pgp.net
--------------------------------------------------------------------------
    Before we have the paperless office, we have the paperless toilet!



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-16  4:00 MFlops Comparison using g77 (bad news) Luke Lonergan
                   ` (3 preceding siblings ...)
  1997-09-16  4:00 ` MFlops Comparison using g77 (bad news) Craig Burley
@ 1997-09-18  4:00 ` Greg Lindahl
  1997-09-19  4:00   ` Burkhard Neidecker-Lutz
  1997-09-22  4:00   ` Luke Lonergan
  4 siblings, 2 replies; 30+ messages in thread
From: Greg Lindahl @ 1997-09-18  4:00 UTC (permalink / raw)



"Luke Lonergan" <llonerga@worldnet.att.net> writes:

> 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

BTW, when I:

1) make the index vars in jacobi.f INTEGER*8 and
2) make the arrays start at 0 instead of 1,

I get 59 MFlops on a 21164 500mhz (PC164).

So it would seem that this one g77/gcc bug (sub-word array indexing)
is much of the problem. (BTW, the T3E node is probably benefitting
from its lack of L3 cache and excellent main memory system...)

-- g



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

* Re: MFlops Comparison using g77 (bad news) - bench.tgz (0/1)
  1997-09-18  4:00     ` Thomas Leitner
@ 1997-09-18  4:00       ` Andrew G. Morgan
  0 siblings, 0 replies; 30+ messages in thread
From: Andrew G. Morgan @ 1997-09-18  4:00 UTC (permalink / raw)



(This is the first time I've tried to post with Netscape 4.02b7. If it all
comes
out in "html", my apologies and I'll start using emacs..)

Another Data point:  Microway have beta released a 64bit version of their
Linux/Alpha compiler (version  4.6.1) and here is the fortran number for
Luke's
benchmark:

         mf64 -O5 -fastlib -onv:

        Time to calculate solution:   0.30 seconds.
        Flops/Second =    80.66

[Note, that the timer Luke's code uses is a "real" timer and does not take
into
account the fact that other jobs may be running on the machine.]

Cheers

Andrew

Thomas Leitner wrote:

> In article <341f0c1d.68509433@netnews.worldnet.att.net> you wrote:
> > On 16 Sep 1997 19:04:44 GMT, Toon Moene <toon@moene.indiv.nluug.nl>
> > wrote:
>
> >         48 MFlops, 433 MHz Alpha using gcc and the C kernel
> >         36 MFlops, 433 MHz Alpha using g77
>
> >         36 MFlops on the PPro 200 using gcc and the C kernel
> >         40 MFlops on the PPro 200 using g77
>
> This is what I get on an AlphaStation 500/500 running Digital Unix 4.0b
> using DEC CC and DEC F77 and the code you've posted as bench.tgz
> with the following options:
>
>            FOPTIONS = -O5
>            COPTIONS = -DUSCORE -O3 -fast
>
>            MFlops/Second =    93.03, C-Kernel
>            MFlops/Second =   123.79, F-Kernel
>
> Looks as if DEC compilers are really much better than GNU stuff ??
>
> Tom
> --
> --------------------------------------------------------------------------
> T o m   L e i t n e r                       Dept. of Communications
>                                             Graz University of Technology,
> e-mail    : tom@finwds01.tu-graz.ac.at      Inffeldgasse 12
> Phone     : +43-316-873-7455                A-8010 Graz / Austria / Europe
> Fax       : +43-316-463-697
> Home page : http://wiis.tu-graz.ac.at/people/tom.html
> PGP public key on : ftp://wiis.tu-graz.ac.at/pgp-keys/tom.asc or send
> mail with subject "get Thomas Leitner" to pgp-public-keys@keys.pgp.net
> --------------------------------------------------------------------------
>     Before we have the paperless office, we have the paperless toilet!






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

* Re: MFlops Comparison using g77 (bad news) - bench.tgz (0/1)
  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
  1 sibling, 0 replies; 30+ messages in thread
From: H.W. Stockman @ 1997-09-18  4:00 UTC (permalink / raw)



Luke Lonergan wrote:

> /*    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];
>           }
>         }
[...]
> I am posting the source tree here for anyone else who would like to
> take a whack at it.

Have you tried forcing some of the intensely-used
pointers into registers?



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-16  4:00   ` MFlops Comparison using g77 (bad news) Luke Lonergan
  1997-09-17  4:00     ` Linus Torvalds
@ 1997-09-19  4:00     ` James Lewis Nance
  1997-09-22  4:00       ` Luke Lonergan
  1 sibling, 1 reply; 30+ messages in thread
From: James Lewis Nance @ 1997-09-19  4:00 UTC (permalink / raw)



In article <341f1031.69553746@netnews.worldnet.att.net>, Luke Lonergan wrote:
>
>I implemented the kernel in C this morning. Unfortunately my news
>server was screwed up at work so I couldn't post the results until
>now:

I compiled and ran the source you posted on a Digital Unix machine
using the Digital Unix compilers.  I don't really know how to interpret
them, so I will just post them and let you tell me what they imply.
The machine they were run on is an Alphastation 500/500.

digital Unix compilers, C kernel:

halfpint> ./stml_serial2.x
 Forcing function file doesn't exist, assuming first
 run.
Creating forcing file... Done.
Initializing solution... Done.
 Time spent in problem setup:   0.07 seconds.
           1   235340.2    
           2   235237.1    
           3   235168.1    
           4   235112.2    
           5   235064.4    
 Time to calculate solution:   0.49 seconds.
MFlops/Second =   125.03

Digital Unix compilers, Fortran kernel:

halfpint> .//stml_serial2.x
 Forcing function file doesn't exist, assuming first
 run.
Creating forcing file... Done.
Initializing solution... Done.
 Time spent in problem setup:   0.04 seconds.
           1   235340.2
           2   235237.1
 Time to calculate solution:   0.14 seconds.
MFlops/Second =   168.96

GNU C compiler, C kernel:

halfpint> ./stml_serial2.x
 Forcing function file doesn't exist, assuming first
 run.
Creating forcing file... Done.
Initializing solution... Done.
 Time spent in problem setup:   0.08 seconds.
           1   235340.2
           2   235237.1
           3   235168.1
           4   235112.2
           5   235064.4
 Time to calculate solution:   0.55 seconds.
MFlops/Second =   111.24


Hope this is of some use,

Jim



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

* Re: MFlops Comparison using g77 (bad news)
  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
  1 sibling, 1 reply; 30+ messages in thread
From: Burkhard Neidecker-Lutz @ 1997-09-19  4:00 UTC (permalink / raw)



In article <5vrlmo$9e7@news1.zippo.com> lindahl@pbm.com (Greg Lindahl) writes:
>"Luke Lonergan" <llonerga@worldnet.att.net> writes:
>> 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
>
>So it would seem that this one g77/gcc bug (sub-word array indexing)
>is much of the problem. 

Just for the heck of it I ran it through a "real" compiler:

	Digital Unix V4.0B
	DIGITAL Fortran 77 V5.0-138-3678F
	
Compilation Flags:

	FOPTIONS = -O5 -arch ev5 -fast 

The timing on a 300 Mhz (!) 21164 then is:

	106 MFlops

So I take it that this is really a case of bad g77 behaviour. The memory
behaviour of the code is ok, L1 miss rate is 0.106 , board level miss
rate for a 1 Mbyte board cache is 0.35 (so the board cache isn't very
effective, but there is reasonable locality in the small scale).

		Burkhard Neidecker-Lutz

EUROMEDIA - Distributed Multimedia Archives for Cooperative TV Production
CEC Karlsruhe , European Applied Research Center, Digital Equip. Corp.
email: neideck@kar.dec.com



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-19  4:00   ` Burkhard Neidecker-Lutz
@ 1997-09-20  4:00     ` Toon Moene
  0 siblings, 0 replies; 30+ messages in thread
From: Toon Moene @ 1997-09-20  4:00 UTC (permalink / raw)



neideck@kar.dec.com (Burkhard Neidecker-Lutz) wrote:

> Just for the heck of it I ran it through a "real" compiler:

> 	106 MFlops

> So I take it that this is really a case of bad g77 behaviour. The memory
> behaviour of the code is ok, L1 miss rate is 0.106 , board level miss
> rate for a 1 Mbyte board cache is 0.35 (so the board cache isn't very
> effective, but there is reasonable locality in the small scale).

Yep, we even know where at least most of the problem is situated.  
Unfortunately, as things are now, I am not the one solving this - I just send 
out a HEEEELLLLLPPPP message to the egcs mailing list.

[ The problem first to be solved is that g77/gcc doesn't recognise
  most induction variables on Alpha, due to the fact that all integer
  arithmetic, by default, is 32 bits, i.e. half-word ]

-- 
Toon Moene (mailto:toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: mailto:fortran@gnu.ai.mit.edu; NWP: http://www.knmi.nl/hirlam



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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-19  4:00     ` James Lewis Nance
@ 1997-09-22  4:00       ` Luke Lonergan
  0 siblings, 0 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-22  4:00 UTC (permalink / raw)



On 19 Sep 1997 14:23:35 GMT, jlnance@volt.ece.ncsu.edu (James Lewis
Nance) wrote:
>GNU C compiler, C kernel:
>           5   235064.4
> Time to calculate solution:   0.55 seconds.
>MFlops/Second =   111.24

The DEC Fortran number (>160 MFlops) was outstanding! The GNU C
compiler result presented here is also dramatically better than what I
get under Linux (RedHat 4.2 for Alpha). Can you tell me what version
of GNU C you are using and what options you gave to the compiler?

BTW, here is a better version of the C code:

void jacobi_(float *psi_new,float *psi,float *f,
	     float *a1, float *a2, float *a3, float *a4, float *a5,
	     int *nx,int *ny,int *nx_max,int *ny_max) {

  int i,j;
  int indij,indip1j,indim1j,indijp1,indijm1;

  float *p_ij_psi_new,*p_ij_psi,*p_ij_f;

  float *p_ip1j_psi,*p_im1j_psi;
  float *p_ijp1_psi,*p_ijm1_psi;

  /* Critical performance benefit here! The value of nx is used in the
     memory offset calculations and needs to be local to avoid
frequent
     reloading and stalls. */
  int nx_r=(*nx);

  /* Copy the floating point values of constants into local memory for
     the same reason as above. */
  float aa1=(*a1),aa2=(*a2),aa3=(*a3),aa4=(*a4),aa5=(*a5);

  i = 1; j = 1;
  indij   = i+(nx_r)*(j);
  indim1j = indij-1;
  indip1j = indij+1;
  indijm1 = indij-(nx_r);
  indijp1 = indij+(nx_r);

  /* Create the starting locations of the pointers */
  p_ij_psi_new   = psi_new + indij;

  p_ij_f   = f + indij;

  p_ij_psi   = psi + indij;
  p_im1j_psi = psi + indim1j;
  p_ip1j_psi = psi + indip1j;
  p_ijm1_psi = psi + indijm1;
  p_ijp1_psi = psi + indijp1;

  for (j=1;j<(*ny)-1;j++) {
    for (i=1;i<(nx_r)-1;i++) {
      *p_ij_psi_new++ = aa1*(*p_ip1j_psi++)+aa2*(*p_im1j_psi++)+
                        aa3*(*p_ijp1_psi++)+aa4*(*p_ijm1_psi++)+
		        aa5*(*p_ij_f++);
    }
    /* Fixup for the two skipped I locations */
    p_ij_psi_new+=2;
    p_ip1j_psi+=2;
    p_im1j_psi+=2;
    p_ijp1_psi+=2;
    p_ijm1_psi+=2;
    p_ij_f+=2;
  }
}




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

* Re: MFlops Comparison using g77 (bad news)
  1997-09-18  4:00 ` Greg Lindahl
  1997-09-19  4:00   ` Burkhard Neidecker-Lutz
@ 1997-09-22  4:00   ` Luke Lonergan
  1 sibling, 0 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-22  4:00 UTC (permalink / raw)



On 18 Sep 1997 16:43:04 GMT, lindahl@pbm.com (Greg Lindahl) wrote:

>1) make the index vars in jacobi.f INTEGER*8 and
>2) make the arrays start at 0 instead of 1,
>
>I get 59 MFlops on a 21164 500mhz (PC164).

Greg,

Odd suggestion, but it seems to work. However, the INTEGER*8 of i and
j seem to do nothing. Also, on my machine (a 433 MHz PC164 with fully
populated SIMM slots) I get 46 MFlops which is less than a clock ratio
from yours. Here is the code fragment that changes:

      real psi(0:nx_max-1,0:ny_max-1)
      real psi_new(0:nx_max-1,0:ny_max-1)
      real f(0:nx_max-1,0:ny_max-1)
      real a1,a2,a3,a4,a5

      integer i,j

C    Operation count = 9 operations/grid point

      do j = 1, ny-2
        do i = 1, nx-2
          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


One other thing: take the print statement out of the loop in main3.f:
2c2
<       implicit none
---
> CLAL      implicit none
22a23
>       dimension gnorm_a(100)
95c96,97
<         print *, it, gnorm
---
> CLAL        print *, it, gnorm
>       gnorm_a(it) = gnorm
110a113,116
>
>       do ii=1,itcnt
>         write(*,*)gnorm_a(ii)
>       end do                                                                 

And you will see a performance impact around 10%.



^ 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, 0 replies; 30+ messages in thread
From: Luke Lonergan @ 1997-09-22  4:00 UTC (permalink / raw)



On 17 Sep 1997 10:21:19 GMT, harley@pauillac.inria.fr (Robert Harley)
wrote:

>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!

I agree. Several days ago (on an airplane, one of the reasons I love
Linux is that it runs on laptops) I did the following to the code and
got terrific benefits, one of which was much better use of cache:

void jacobi_(float *psi_new,float *psi,float *f,
	     float *a1, float *a2, float *a3, float *a4, float *a5,
	     int *nx,int *ny,int *nx_max,int *ny_max) {

  int i,j;
  int indij,indip1j,indim1j,indijp1,indijm1;

  float *p_ij_psi_new,*p_ij_psi,*p_ij_f;

  float *p_ip1j_psi,*p_im1j_psi;
  float *p_ijp1_psi,*p_ijm1_psi;

  /* Critical performance benefit here! The value of nx is used in the
     memory offset calculations and needs to be local to avoid
frequent
     reloading and stalls. */
  int nx_r=(*nx);

  /* Copy the floating point values of constants into local memory for
     the same reason as above. */
  float aa1=(*a1),aa2=(*a2),aa3=(*a3),aa4=(*a4),aa5=(*a5);

  i = 1; j = 1;
  indij   = i+(nx_r)*(j);
  indim1j = indij-1;
  indip1j = indij+1;
  indijm1 = indij-(nx_r);
  indijp1 = indij+(nx_r);

  /* Create the starting locations of the pointers */
  p_ij_psi_new   = psi_new + indij;

  p_ij_f   = f + indij;

  p_ij_psi   = psi + indij;
  p_im1j_psi = psi + indim1j;
  p_ip1j_psi = psi + indip1j;
  p_ijm1_psi = psi + indijm1;
  p_ijp1_psi = psi + indijp1;

  for (j=1;j<(*ny)-1;j++) {
    for (i=1;i<(nx_r)-1;i++) {
      *p_ij_psi_new++ = aa1*(*p_ip1j_psi++)+aa2*(*p_im1j_psi++)+
                        aa3*(*p_ijp1_psi++)+aa4*(*p_ijm1_psi++)+
		        aa5*(*p_ij_f++);
    }
    /* Fixup for the two skipped I locations */
    p_ij_psi_new+=2;
    p_ip1j_psi+=2;
    p_im1j_psi+=2;
    p_ijp1_psi+=2;
    p_ijm1_psi+=2;
    p_ij_f+=2;
  }
}




^ 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 ` H.W. Stockman
1997-09-16  4:00   ` Greg Lindahl
1997-09-16  4:00 ` Ulrich Ruede
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       ` Greg Lindahl
1997-09-17  4:00       ` 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) - 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) 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) Craig Burley
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