Here you can ask questions and find or give answers to organizational, academic and other questions about studying computer science.

925 questions

1k answers


441 users

0 votes

I have some questions regarding FULL and PARTIAL predication (Exercise Sheet 4 exercise 2).

I understand that full predication uses a boolean register to determine if an operation gets executed or not. Is this "check" mandatory for every line of code, i.e. does every operation need the [rp] addition or can I just add that for example to the IF-body? If it is mandatory, how do I actually write into the rp-register? Are only branches forbidden (bez, bnz) and jumps allowed or are both forbidden?

Furthermore, I don't quite understand why partial predication just offer a conditional move instruction. What if my program does not need load/store instructions? At least my solution for the code translation to Abacus does not have any.

In general, I would very much appreciate some examples for full and partial predication since on slide 66 the predication does not quite work exactly as in the exercise, does it?

Thanks in advance for all answers.

Best regards
in * TF "Emb. Sys. and Rob." by (1.2k points)

1 Answer

+1 vote
Best answer

Full predication means that all instructions are endowed with an additional predicate register. For instance, and addition instruction like add rd,rl,rr becomes [p]add rd,rl,rr and means that the predicate register p is checked before further executing the instruction: If the content of the predicate register p is true, the addition is executed as usual, otherwise, it is simply skipped.

The predicate registers are typically assigned by comparison operations and logical operations whose results are boolean values. Even these instructions may have predicate registers, so that there must also be at least some unpredicted instructions to assign constants "true" or "false" to a predicate register.

Full predication needs to add additional source operands to *essentially all* instructions and is therefore quite expensive: the programs become larger and the processors have to access all the time the predicate registers. 

To reduces these costs, one may alternatively use partial predication which means that *not all, but only a few* instructions are predicated. In essence, it is sufficient to implement an if-then-else expression that executes rd := (p?rl:rr) where the right hand side means "if p then rl else rr" or even less a conditional move instruction like [p] mov rd,r which means that rd:=r is executed if p holds, and otherwise, nothing is executed.

For an if-statement, you may this way, simply execute the then and else branch and assign finally only those values to the live variables that remain after the statement.

Conditional move instructions are not load/store instructions. The conditional move instruction "cmov rd, rl, rr " suggested in the excerise copies the value of register rr to rl if rd hold, and otherwise does nothing.

In the exercise, you should translation the given program to assembly code using either full or partial predication with the above instructions. For instance, consider the following statement

    if(x<y) {
        y = x+y;
    } else {
        y = x-y;

Using full predication, you may write the following program:

    sgt p1,rx,ry
    neg p0,p1
    [p1] add ry,rx,ry
    [p0] sub ry,rx,ry

Using partial predication, you may write the following program:

    sgt p1,rx,ry
    neg p0,p1
    add r1,rx,ry
    sub r0,rx,ry
    cmov p1,ry,r1
    cmov p0,ry,r0

    Hope this helps!

by (143k points)
selected by
It does indeed help! Thank you very much
Imprint | Privacy Policy