# [CALU] Predicated Executuion

• From: Martin Elshuber <e9825286@xxxxxxxxxxxxxxxxxxxx>
• To: calu-ss2010-tuwien@xxxxxxxxxxxxx
• Date: Sat, 10 Apr 2010 02:05:17 +0200

Ich bin mir nicht sicher, aber folgendes Besipiel kann ich nicht mit UUs alleine lösen (geht das überhaupt):

```
-------------------------------------
if (a==0)
S1
else
if (b==0) && (c==0)
S2
else
S3
endif
endif
-------------------------------------

Zur Erinnerung:
pred (a),px<cond>,py<cond> (P)
a..........Test Condition zb. (a>7)
P..........Predicate Bit
px<cond>...Verändere px, mit der Tabelle unten

a  P  px |  UU  iUU |  PU  iPU |  OR  iOR | AND iAND |
----------+----------+----------+----------+----------+
x  0  x  |  0    0  |  x    x  |  x    x  |  x    x  |
0  1  x  |  0    1  |  0    1  |  x    1  |  0    x  |
1  1  x  |  1    0  |  1    0  |  1    x  |  x    0  |

Lösung mit iOR:

pred (a==0), p0<UU>,p1<iUU>
pred (b==0), p1<UU>,p2<iUU> (p1)
pred (c==0), p1<UU>,p2<iOR> (p1)
S1 (p0)
S2 (p1)
S3 (p2)

| (init)   | step 1   | step 2   | step 3   |
a b c | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 |
-------+----------+----------+----------+----------+
0 0 0 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
0 0 1 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
0 1 0 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
0 1 1 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
1 0 0 | x  x  x  | 0  1  x  | 0  1  0  | 0  1  0  |
1 0 1 | x  x  x  | 0  1  x  | 0  1  0  | 0  0  1  |
1 1 0 | x  x  x  | 0  1  x  | 0  0  1  | 0  0  1  |
1 1 1 | x  x  x  | 0  1  x  | 0  0  1  | 0  0  1  |

Andere Lösung mit iPU:

pred (a==0), p0<UU>,p1<iUU>
pred (b==0), p1<UU>,p2<iUU> (p1)
pred (c==0), p1<UU>,p2<iPU> (p1)
S1 (p0)
S2 (p1)
S3 (p2)

| (init)   | step 1   | step 2   | step 3   |
a b c | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 |
-------+----------+----------+----------+----------+
0 0 0 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
0 0 1 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
0 1 0 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
0 1 1 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
1 0 0 | x  x  x  | 0  1  x  | 0  1  0  | 0  1  0  |
1 0 1 | x  x  x  | 0  1  x  | 0  1  0  | 0  0  1  |
1 1 0 | x  x  x  | 0  1  x  | 0  0  1  | 0  0  1  |
1 1 1 | x  x  x  | 0  1  x  | 0  0  1  | 0  0  1  |

Keine Lösung nur PUs:

pred (a==0), p0<PU>,p1<iPU>
pred (b==0), p1<PU>,p2<iPU> (p1)
pred (c==0), p1<PU>,p2<iPU> (p1)
S1 (p0)
S2 (p1)
S3 (p2)

| (init)   | step 1   | step 2   | step 3   |
a b c | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 |
-------+----------+----------+----------+----------+
0 0 0 | x  x  x  | 1  0  x  | 1  0  x  | 1  0  x  |
0 0 1 | x  x  x  | 1  0  x  | 1  0  x  | 1  0  x  |
0 1 0 | x  x  x  | 1  0  x  | 1  0  x  | 1  0  x  |
0 1 1 | x  x  x  | 1  0  x  | 1  0  x  | 1  0  x  |
1 0 0 | x  x  x  | 0  1  x  | 0  1  0  | 0  1  0  |
1 0 1 | x  x  x  | 0  1  x  | 0  1  0  | 0  0  1  |
1 1 0 | x  x  x  | 0  1  x  | 0  0  1  | 0  0  1  |
1 1 1 | x  x  x  | 0  1  x  | 0  0  1  | 0  0  1  |

wenn a=0 (obere 4 zeilen) wird p1 gleich 0 gesetzt.
```
da aber PUs ich schreibt wenn das predicate false ist wird p2 nie geschrieben.
```
Lösung nur PUs (eine extra Instruction):

pred (a==0), p0<PU>,p1<iPU>
pred (a==0), p0<PU>,p2<iPU>
pred (b==0), p1<PU>,p2<iPU> (p1)
pred (c==0), p1<PU>,p2<iPU> (p1)
S1 (p0)
S2 (p1)
S3 (p2)

| (init)   | step 1   | step 2   | step 3   | step 4   |
a b c | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 |
-------+----------+----------+----------+----------+----------+
0 0 0 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  | 1  0  0  |
0 0 1 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  | 1  0  0  |
0 1 0 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  | 1  0  0  |
0 1 1 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  | 1  0  0  |
1 0 0 | x  x  x  | 0  1  x  | 0  1  1  | 0  1  0  | 0  1  0  |
1 0 1 | x  x  x  | 0  1  x  | 0  1  1  | 0  1  0  | 0  0  1  |
1 1 0 | x  x  x  | 0  1  x  | 0  1  1  | 0  0  1  | 0  0  1  |
1 1 1 | x  x  x  | 0  1  x  | 0  1  1  | 0  0  1  | 0  0  1  |

Schrit 2 inititalisiert p2, daher passt alles.

Keine Lösung nur UUs:

pred (a==0), p0<UU>,p1<iUU>
pred (b==0), p1<UU>,p2<iUU> (p1)
pred (c==0), p1<UU>,p2<iUU> (p1)
S1 (p0)
S2 (p1)
S3 (p2)

| (init)   | step 1   | step 2   | step 3   |
a b c | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 | p0 p1 p2 |
-------+----------+----------+----------+----------+
0 0 0 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
0 0 1 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
0 1 0 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
0 1 1 | x  x  x  | 1  0  x  | 1  0  0  | 1  0  0  |
1 0 0 | x  x  x  | 0  1  x  | 0  1  0  | 0  1  0  |
1 0 1 | x  x  x  | 0  1  x  | 0  1  0  | 0  0  1  |
1 1 0 | x  x  x  | 0  1  x  | 0  0  1  | 0  0  0  |
1 1 1 | x  x  x  | 0  1  x  | 0  0  1  | 0  0  0  |

```
Im Schritt 3 wenn a=b=1 (die letzten beiden Zeilen) ist p1=0. UU schreibt in in diesem Fall unabhängig vom alten ergebnis des vergleichs eine 0
```
Fällt euch eine Lösung nur mi UUs ein?

```
Bez. der 24 Bit ISA wäre es wichtig nur eine Predicate-Condition zu haben, ansonsten gehen uns die Bits aus. Die einzige Variante die übrig bliebe wäre nur mit PUs zu arbeiten.
```Oder fällt irgend wem von euch eine Lösung mit UUs ein.

g Martin

```

### Other related posts:

• » [CALU] Predicated Executuion - Martin Elshuber