We will define a translation scheme from HPJava class definitions to standard Java-language class definitions. The existing HPJava translator literally goes through these stages, generating Java source as its output. In the future a more advanced HPJava compiler might directly generate Java byte code. Nevertheless, the early phases of compilation will presumably apply transformations similar to the ones described in this appendix.
In general only a subset of the classes in an HPJava program will actually use the special syntax of distributed arrays and distributed control constructs. Many of the classes used will be written in standard Java, or may be part of standard Java libraries. Other classes may use sequential multiarrays, but not distributed arrays or parallel constructs.
Methods that do use parallel HPJava syntax have some special properties. They require a well-defined active process group (APG) at their point of invocation. So in general it is problematic (although not impossible) to invoke parallel HPJava code from a piece of ordinary Java. These problems reflect real limitations of the underlying SPMD programming model--it is difficult to directly invoke distributed parallel procedures from sequential code.
The HPJava translator tries to make a clear distinction between code that uses HPJava parallel extensions and code that does not. It introduces a special interface, hpjava.lang.HPspmd, which must be implemented by any class that uses the parallel syntax.
We will refer to a class that (directly or indirectly) implements the HPspmd interface as an HPspmd class. Any other class is a non-HPspmd class. Likewise, an interface that extends the HPspmd interface is an HPspmd interface, and any other interface is a non-HPspmd interface. We define HPspmd code to be any statement or expression that includes the following:
To discourage invocation of HPspmd code from non-HPspmd code, the HPJava translator imposes the following limitations:
It should be very clear that the distinction between HPspmd and non-HPspmd classes is orthogonal to the discussion in section A.1.1 about the types of distributed arrays themselves. Here we are essentially concerned with what kind of code is allowed to use distributed arrays. HPspmd classes are unequivocally Java classes, whereas distributed array types are not classes of any kind.