next up previous contents index
Next: Static Semantic Checking Up: Preliminaries Previous: On multiarray types   Contents   Index


HPspmd classes

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:

Now it is required that HPspmd code only appear in methods and constructors defined in HPspmd classesA.2. This restriction is quite specific, and in particular it forbids HPspmd code in initialization expressions for fields, or in static or instance intialization blocks, even if these are within HPspmd classes--our current feeling is that the implementation complexity needed to make the active process group available in these contexts isn't warranted by the modest advantages it provides.

To discourage invocation of HPspmd code from non-HPspmd code, the HPJava translator imposes the following limitations:

  1. If a class or interface inherits a method with the same signature from more than one of its superclasses and superinterfaces, either all declarations of the method must be in HPspmd classes and interfaces, or all declarations of the method must be in non-HPspmd classes and interfaces. So an inheritted method can always be unambiguously classified as an HPspmd method or a non-HPspmd method.
  2. An HPspmd class or interface may not override a non-HPspmd method.
Ordinary Java code (not processed by the HPJava translator) may access members of HPspmd classes, but this requires detailed knowledge of the transformations the HPJava translator applies to function signaturesA.3and distributed array variables, and in general this facility should be used very cautiously. The HPJava translator itself will prevent code in non-HPspmd classes from creating instances of, or invoking methods from, HPspmd classes. Of course there is no restriction in the other direction--an HPspmd class can freely use any non-HPspmd Java class, limited only by the normal accessibility rules.

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.


next up previous contents index
Next: Static Semantic Checking Up: Preliminaries Previous: On multiarray types   Contents   Index
Bryan Carpenter 2003-04-15