Re: Short Vectors Versus Long Vectors

Liste des GroupesRevenir à c arch 
Sujet : Re: Short Vectors Versus Long Vectors
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.arch
Date : 23. Apr 2024, 13:40:07
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2024Apr23.144007@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5
User-Agent : xrn 10.11
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
On Tue, 23 Apr 2024 06:22:38 GMT, Anton Ertl wrote:
If your OoO capabilities are limited (and I think
they are on the Cray machines), you cannot start the second iteration of
the doall loop before the processing step of the first iteration has
finished with the register.
>
How would out-of-order execution help, anyway, given all the operations on
the vector elements are supposed to be identical?

OoO does in hardware what software pipelining does in software: If I
have a loop

for (i=0; i<n; i++)
  b[i] = a[i]+c[i];

the straightforward way to code this is:

L0:
load tmp1 = a[i]
load tmp2 = b[i]
add tmp3 = tmp1,tmp2
store c[i] = tmp3
add i = i+1
branch L0 if i<n

On an in-order CPU you then do things like loop unrolling, modulo
scheduling and modulo variable renaming to get a steady state like:

L0:
store c[i], tmp1
add tmp3 = tmp3,tmp4
load tmp9 = a[i+4]
load tmp10 = b[i+4]
store c[i+1], tmp3
add tmp5 = tmp5,tmp6
load tmp1 = a[i+5]
load tmp2 = b[i+5]
store c[i+2], tmp5
add tmp7 = tmp7,tmp8
load tmp3 = a[i+6]
load tmp4 = b[i+6]
store c[i+3], tmp7
add tmp9 = tmp9,tmp10
load tmp1 = a[i+7]
load tmp2 = b[i+7]
store c[i+4], tmp9
add tmp1 = tmp1,tmp2
load tmp3 = a[i+8]
load tmp4 = b[i+8]
add i=i+5
branch L0 if i<n-4

And that's just to cover a load latency of 4 cycles, assuming that the
machine can perform 2 loads and one store per cycle.  And you have to
generate the ramp-up and ramp-down code, and for more complicated
loops it becomes more complicated.

By contrast, on an OoO machine the straightforward code just works
efficiently, and the hardware does the reordering and register
renaming (and the Golden Cove with its 0-cycle constant additions
eliminates even a part of the reason for loop unrolling).  It creates
the ramp-up automatically, and, if the loop exit is predicted
correctly, even the ramp-down, and it overlaps the ramp-up (and
possibly the ramp-down) with adjacent code.

Back to the Crays: While the SIMD/vector semantics means that a
straightforward loop will process 64 elements rather than one before
the first load of the second iteration has to wait for the add of
the first iteration to finish, you still have to do some software
pipelining to get an overlap between that add and that load; the
longer the latency, the more software pipelining and (for register
renaming) the more registers you need.

In OoO the corresponding condition is when the OoO engine has consumed
all instances of one resource and has to wait for instructions to
finish to free these resources; ideally the hardware prefetcher avoids
that scenario, but in memory-bandwidth-limited situations it will
occur.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
  Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Date Sujet#  Auteur
23 Apr 24 * Short Vectors Versus Long Vectors109Lawrence D'Oliveiro
23 Apr 24 +* Re: Short Vectors Versus Long Vectors97MitchAlsup1
23 Apr 24 i+* Re: Short Vectors Versus Long Vectors21Lawrence D'Oliveiro
23 Apr 24 ii+* Re: Short Vectors Versus Long Vectors15Anton Ertl
23 Apr 24 iii+* Re: Short Vectors Versus Long Vectors3Lawrence D'Oliveiro
23 Apr 24 iiii+- Re: Short Vectors Versus Long Vectors1Anton Ertl
23 Apr 24 iiii`- Re: Short Vectors Versus Long Vectors1MitchAlsup1
23 Apr 24 iii+- Re: Short Vectors Versus Long Vectors1MitchAlsup1
23 Apr 24 iii`* Re: Short Vectors Versus Long Vectors10BGB
24 Apr 24 iii `* Re: Short Vectors Versus Long Vectors9MitchAlsup1
24 Apr 24 iii  `* Re: Short Vectors Versus Long Vectors8BGB
24 Apr 24 iii   +* Re: Short Vectors Versus Long Vectors6Lawrence D'Oliveiro
24 Apr 24 iii   i`* Re: Short Vectors Versus Long Vectors5MitchAlsup1
24 Apr 24 iii   i +* Re: Short Vectors Versus Long Vectors2BGB
24 Apr 24 iii   i i`- Re: Short Vectors Versus Long Vectors1Lawrence D'Oliveiro
24 Apr 24 iii   i `* Re: Short Vectors Versus Long Vectors2Terje Mathisen
25 Apr 24 iii   i  `- Re: Short Vectors Versus Long Vectors1MitchAlsup1
24 Apr 24 iii   `- Re: Short Vectors Versus Long Vectors1MitchAlsup1
23 Apr 24 ii`* Re: Short Vectors Versus Long Vectors5MitchAlsup1
23 Apr 24 ii `* Re: Short Vectors Versus Long Vectors4Lawrence D'Oliveiro
24 Apr 24 ii  `* Re: Short Vectors Versus Long Vectors3MitchAlsup1
24 Apr 24 ii   `* Re: Short Vectors Versus Long Vectors2Lawrence D'Oliveiro
24 Apr 24 ii    `- Re: Short Vectors Versus Long Vectors1MitchAlsup1
24 Apr 24 i`* Re: Short Vectors Versus Long Vectors75John Savard
24 Apr 24 i +* Re: Short Vectors Versus Long Vectors26MitchAlsup1
24 Apr 24 i i+* Re: Short Vectors Versus Long Vectors23John Savard
24 Apr 24 i ii+* Re: Short Vectors Versus Long Vectors2Lawrence D'Oliveiro
24 Apr 24 i iii`- Re: Short Vectors Versus Long Vectors1BGB
24 Apr 24 i ii+* Re: Short Vectors Versus Long Vectors19Anton Ertl
25 Apr 24 i iii`* Re: Short Vectors Versus Long Vectors18Lawrence D'Oliveiro
25 Apr 24 i iii +* Re: Short Vectors Versus Long Vectors2Michael S
27 Apr 24 i iii i`- Re: Short Vectors Versus Long Vectors1Lawrence D'Oliveiro
25 Apr 24 i iii `* Re: Short Vectors Versus Long Vectors15John Levine
25 Apr 24 i iii  `* Re: Short Vectors Versus Long Vectors14MitchAlsup1
25 Apr 24 i iii   +* Re: Short Vectors Versus Long Vectors9Michael S
25 Apr 24 i iii   i`* Re: Short Vectors Versus Long Vectors8MitchAlsup1
25 Apr 24 i iii   i `* Re: Short Vectors Versus Long Vectors7Michael S
25 Apr 24 i iii   i  `* Re: Short Vectors Versus Long Vectors6BGB
27 Apr 24 i iii   i   `* Re: Short Vectors Versus Long Vectors5Thomas Koenig
27 Apr 24 i iii   i    +* Re: Short Vectors Versus Long Vectors3John Levine
28 Apr 24 i iii   i    i`* Re: Short Vectors Versus Long Vectors2Lawrence D'Oliveiro
28 Apr 24 i iii   i    i `- Re: Short Vectors Versus Long Vectors1John Levine
28 Apr 24 i iii   i    `- Re: Short Vectors Versus Long Vectors1Tim Rentsch
26 Apr 24 i iii   `* Re: Short Vectors Versus Long Vectors4Lawrence D'Oliveiro
26 Apr 24 i iii    `* Re: Short Vectors Versus Long Vectors3MitchAlsup1
26 Apr 24 i iii     `* Re: Short Vectors Versus Long Vectors2Lawrence D'Oliveiro
26 Apr 24 i iii      `- Re: Short Vectors Versus Long Vectors1MitchAlsup1
24 Apr 24 i ii`- Re: Short Vectors Versus Long Vectors1David Schultz
27 Apr 24 i i`* Re: Short Vectors Versus Long Vectors2aph
27 Apr 24 i i `- Re: Short Vectors Versus Long Vectors1MitchAlsup1
24 Apr 24 i +* Re: Short Vectors Versus Long Vectors2Lawrence D'Oliveiro
24 Apr 24 i i`- Re: Short Vectors Versus Long Vectors1Anton Ertl
24 Apr 24 i +- Re: Short Vectors Versus Long Vectors1Thomas Koenig
24 Apr 24 i `* Re: Short Vectors Versus Long Vectors45Anton Ertl
24 Apr 24 i  +* Re: Short Vectors Versus Long Vectors43Lawrence D'Oliveiro
24 Apr 24 i  i`* Re: Short Vectors Versus Long Vectors42Anton Ertl
25 Apr 24 i  i `* Re: Short Vectors Versus Long Vectors41Lawrence D'Oliveiro
25 Apr 24 i  i  `* Re: Short Vectors Versus Long Vectors40John Savard
25 Apr 24 i  i   `* Re: Short Vectors Versus Long Vectors39Lawrence D'Oliveiro
25 Apr 24 i  i    +* Re: Short Vectors Versus Long Vectors3Michael S
26 Apr 24 i  i    i`* Re: Short Vectors Versus Long Vectors2Lawrence D'Oliveiro
26 Apr 24 i  i    i `- Re: Short Vectors Versus Long Vectors1Michael S
25 Apr 24 i  i    +* Re: Short Vectors Versus Long Vectors7John Levine
25 Apr 24 i  i    i`* Re: Short Vectors Versus Long Vectors6Thomas Koenig
29 Apr 24 i  i    i `* Re: Short Vectors Versus Long Vectors5George Neuner
29 Apr 24 i  i    i  +* Re: Short Vectors Versus Long Vectors3Terje Mathisen
29 Apr 24 i  i    i  i+- Re: Short Vectors Versus Long Vectors1BGB
30 Apr 24 i  i    i  i`- Re: Short Vectors Versus Long Vectors1George Neuner
29 Apr 24 i  i    i  `- Re: lotsa power, Short Vectors Versus Long Vectors1John Levine
25 Apr 24 i  i    `* Re: Short Vectors Versus Long Vectors28John Savard
25 Apr 24 i  i     `* Re: Short Vectors Versus Long Vectors27Thomas Koenig
25 Apr 24 i  i      +* Re: lots of juice, Short Vectors Versus Long Vectors3John Levine
27 Apr 24 i  i      i`* Re: lots of juice, Short Vectors Versus Long Vectors2Thomas Koenig
28 Apr 24 i  i      i `- Re: lots of juice, Short Vectors Versus Long Vectors1Lawrence D'Oliveiro
28 Apr 24 i  i      `* Re: Short Vectors Versus Long Vectors23Tim Rentsch
30 Apr 24 i  i       `* Re: Short Vectors Versus Long Vectors22Thomas Koenig
30 Apr 24 i  i        +* Re: old power, Short Vectors Versus Long Vectors19John Levine
30 Apr 24 i  i        i`* Re: old power, Short Vectors Versus Long Vectors18Lawrence D'Oliveiro
1 May 24 i  i        i `* Re: old power, Short Vectors Versus Long Vectors17John Levine
1 May 24 i  i        i  +- Re: old power, Short Vectors Versus Long Vectors1MitchAlsup1
2 May 24 i  i        i  `* Re: old power, Short Vectors Versus Long Vectors15BGB
2 May 24 i  i        i   `* Re: old power, Short Vectors Versus Long Vectors14MitchAlsup1
3 May 24 i  i        i    +- Re: old power, Short Vectors Versus Long Vectors1BGB
3 May 24 i  i        i    `* Re: old power, Short Vectors Versus Long Vectors12Lawrence D'Oliveiro
3 May 24 i  i        i     `* Re: old power, Short Vectors Versus Long Vectors11BGB
4 May 24 i  i        i      `* Re: old power, Short Vectors Versus Long Vectors10MitchAlsup1
5 May 24 i  i        i       +* Re: old power, Short Vectors Versus Long Vectors4Thomas Koenig
5 May 24 i  i        i       i+- Re: old power, Short Vectors Versus Long Vectors1BGB
5 May 24 i  i        i       i`* Re: old power, Short Vectors Versus Long Vectors2MitchAlsup1
5 May 24 i  i        i       i `- Re: old power, Short Vectors Versus Long Vectors1BGB
5 May 24 i  i        i       +* Re: old power, Short Vectors Versus Long Vectors2BGB
5 May 24 i  i        i       i`- Re: old power, Short Vectors Versus Long Vectors1MitchAlsup1
6 May 24 i  i        i       `* Re: not even sort of old power, Short Vectors Versus Long Vectors3John Levine
6 May 24 i  i        i        +- Re: not even sort of old power, Short Vectors Versus Long Vectors1MitchAlsup1
6 May 24 i  i        i        `- Re: not even sort of old power, Short Vectors Versus Long Vectors1Thomas Koenig
1 May 24 i  i        `* Re: Short Vectors Versus Long Vectors2Tim Rentsch
1 May 24 i  i         `- Re: Short Vectors Versus Long Vectors1Thomas Koenig
24 Apr 24 i  `- Re: Short Vectors Versus Long Vectors1MitchAlsup1
30 Apr 24 `* Re: Short Vectors Versus Long Vectors11MitchAlsup1
30 Apr 24  +- Re: Short Vectors Versus Long Vectors1MitchAlsup1
1 May 24  `* Re: Short Vectors Versus Long Vectors9Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal