Article View: comp.sys.super
Article #39Re: Inner product / AXPY performance
From: Kevin Dowd
Date: Mon, 03 Aug 1992 17:15
Date: Mon, 03 Aug 1992 17:15
63 lines
3277 bytes
3277 bytes
eijkhout@cupid.cs.utk.edu (Victor Eijkhout) writes:
: Yo hardcore number crunchers!
:
: I would like to get an idea of the difference in performance
: between inner products
:
: do i=1,n x = x + a(i)*b(i)
:
: and axpy operations
:
: do i=1,n x(i) = x(i) + a*b(i)
:
: which both have the same number of operations, but the inner product
: has an accumulation, which traditionally seems to be an
: unvectorizable idea.
:
: Please post if you know how your favourite vector processor / vector
: chip / Risc processor / whatever performs differently / the same
: on the two.
:
: My guess would be that the difference between these two operations
: can nowadays be conveniently neglected, but I might be wrong.
:
: Victor.
You're right, inner products aren't directly vectorizable, but there
are some good reasons why you would want to organize, say, a matrix
multiply around an inner product, rather than an 'axpy on a modern
RISC workstation.
The first reason is memory bandwidth. If you look at the two loops above,
you can see that the first one performs two memory references per
iteration-- two loads, and the second performs three-- two loads and
a store. Current RISC processors can do at most one memory operation
per clock cycle, so a savings in memory traffic gives you a chance to
run into some other barrier.
The second reason is that the floating point units on many newer RISC
processors feature a "multiply and accumulate" instruction. This
can do a floating point addition and multiply in the same time it
takes to do one of them alone. That is, you get two flops per
clock, rather than one, if you can find a use for this instruction.
(By the way, this is the reason that many vendors quote floating point
rates that are twice the clock rate-- they are saying that if you
can use a "multiply and accumulate" instruction every cycle, you
will get, say, 100 mflops on a 50 Mhz computer). An inner product
is custom made for a "multiply and accumulate" instruction, though in
this case you are still memory bandwidth limited.
On the other hand, the 'axpy version is better on some vector
supercomputers. Take the Cray Y-MP as an example. It can perform
*three* memory operations per clock (per processor)-- two loads and
a store. It also has two independent pipelined vector units.
Because the 'axpy is fully vectorizable, and because there is enough
memory bandwidth to go around, it will run better on a big vector
supercomputer than the inner product.
-Kevin
--
\ // // General purpose computer wizards.
\ // T E C H N O L O G I E S Kevin Dowd, dowd@wisper.com
\ //\ // ` (( // ) ((/ //'' Wethersfield, Connecticut
\// \// // )) // ((/ // USA (203) 257-7670
Technical Details
Message-ID:
<1992Aug3.171551.27311@wisper.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!rpi!psinntp!psinntp!wisper!dowdReferences:
<l7gi3fINNmsd@utkcs2.cs.utk.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!rpi!psinntp!psinntp!wisper!dowd From: dowd@wisper.com (Kevin Dowd) Newsgroups: comp.sys.super,comp.lang.fortran Subject: Re: Inner product / AXPY performance Message-ID: <1992Aug3.171551.27311@wisper.com> Date: 3 Aug 92 17:15:51 GMT Article-I.D.: wisper.1992Aug3.171551.27311 References: <l7gi3fINNmsd@utkcs2.cs.utk.edu> Organization: Wisper Technologies Lines: 63