HPJava has all the Java statements for program execution control within a single process. It also introduces three new control constructs, on, at and over for execution control among processes.
A new concept, active process group, is introduced. It is the set of processes sharing the current thread of control.
In a traditional SPMD program, the concept of switching the active process group is reflected by if statement,
if(myid>=0 && myid<4) { ... }
means that inside the brace bracket, the processes numbered as 0 to 3 share the control thread.
In HPJava, this concept is expressed by a Group reference. When a HPJava program starts, the active process group is a system pre-defined value. During the execution, the active process group can be changed explicitly through an on construct in the language.
In a shared memory program, accessing the value of a variable is straight forward. In a message passing system, only the process which holds data can read and write the data. A traditional SPMD program achieves this by using if statements. For example,
if(myid==1) my_data=3;
will make sure that only my_data on process 1 is assigned to 3.
In the language we present here, the same thing is required, and not only for local variables but also for global variables, i.e. when assigning data, the data owner must be the active process group.
Besides on construct, there is a more convenient way to change the active process group according to the array element we want to access, at construct.
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 }
The assign statement guarded by an at construct is correct, the one without it may cause run time error if there is run time range checking.
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(i= x|0:3) b[i]=3;
on(q) for(int n=0;n<4;n++) at(i=x[n]) b[i]=3;
Inside each iteration, the active process group is changed to q/i.
In section 3, we will use more programs to show that by using the at and over construct it is quite convenient for a program to keep the active process group equal to the data owner group of the assigned data.
When accessing data on another process, HPJava needs explicit communication as in a ordinary SPMD program.