next up previous
Next: Communication library functions Up: Operators Previous: Restricted type conversion

Location shifting

Shifting a location is used specially to support ghost regions, which require a new constructor for BlockRange with specification of ghost widths. A collective operation Adlib.writeHalo can update the ghost regions of a distribute array, copying values from the physical segments of neighboring processes. Shift operators >> and << applicable to locations return locations a specified number of places to the right or left of the current position (the results are only defined when used as an index to access distributed array). For example,

  Procs2 p(2, 4);

  on(p) {
    Range x = new BlockRange(100, p.dim(0), 1);  // ghost width 1
    Range y = new BlockRange(200, p.dim(1), 1);  // ghost width 1

    int [[#,#]] a = new int [[x,y]] ;

    // ... some code to initialize `a'

    Adlib.writeHalo(a);

    int [[#,#]] b = new int [[x,y]];

    over(Location i=x|:)
      over(Location j=y|:)
        b[i,j] = (a[i<<1,j] + a[i>>1,j] + a[i,j<<1] + a[i,j>>1]) / 4;

    over(Location i=x|:)
      over(Location j=y|:)
        a[i,j] = b[i,j];

  }

is a version of Jacobi iteration with only one iteration inside.



Guansong Zhang
Thu Nov 13 17:36:47 EST 1997