next up previous
Next: Operators Up: Program execution control Previous: Active process group

Accessing global variable

Suppose we still have b defined in previous section,

  on (q) {
    Location i=x|1;
    at(i)
      b[i]=3; //correct

    b[i]=3;   //error
  }

In general, at construct has the form,

  at(Location i= ...) {
    array[i]=...
  }

This is similar to a traditional SPMD program like,

  if( own(array[global_local(i)]) ) {
    array[global_local(i)]=...
  }

In HPJava, a more powerful construct over can be used to combine the switching of the active process group with a loop,

  on(q)
    over(Location i= x|0:3)
      b[i]=3;

is semantically equivalent togif

  on(q) 
    for(int n=0;n<4;n++)
      at(Location i=x|n)
        b[i]=3;

In general, over construct has the form,

math98



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