next up previous contents index
Next: Parameter Promotion Up: Sequential and Parallel Variables Previous: Operations on Whole Indexed

Promotion

   

In certain cases sequential and parallel expressions can interact through promotion, in which the sequential expression is logically treated as a conforming parallel expression. In the following example the sequential variable 1.0 is logically promoted to be a parallel array of the same size as A.

    A := 1.0;                 -- promote 1.0 to a parallel array
Similarly, the return value of a procedure can be promoted by assigning it to a parallel variable:

    var A : [R] float;
        s : float;

    procedure abs(x: float) : float;
    begin
        if x<0 then
            return -x;
        else
            return x;
    end;

    . . .

    A := abs(s);              -- promote the value returned by abs()

Only scalar expressions can be promoted, and only when they appear as an r-value. Intuitively, modifying a promoted scalar would allow the promoted scalar to have different values at different indices, and the semantics of the scalar expression would be lost. Thus, the following example shows a case of illegal promotion:

    s := A;                   -- illegal promotion of s





Kay Nettle
Fri Feb 21 21:14:29 CST 1997