next up previous
Next: Inquiry fields and functions Up: Global variables Previous: Array section and type


Data descriptor

When we introduced global data, we introduced a concept, data descriptor. We will explain more about the idea in this section.

Actually, the concept of data descriptor is not something entirely new. It exists in Java language itself.

In Java, array type is not of any class type, but a special reference type. In fact, it is exactly a handle to a data descriptor. We can see this point through the following example.

In C language, a main function may has the following prototype,

  int main(int argc, char* argv[]);

From the function input, one can retrieve the information like how many command line arguments are passed, and where they are located.

But in Java, a main function is written as,

  int main(String argv[]) {
    ...
  };

Why does not Java language need to pass the number of arguments?

The answer is that you can always get this value from the array reference, argv.length. This means argv not only store where the array data is, but also record the length of the array. It is a simplest data descriptor.

On a single processor, an array variable can be labeled by a simple value like memory addresses and an int value as length.

On a multi-processor, to label a global variable, a more complicated structure is needed. We call it data descriptor. It portrays where the data is created, and how are they distributed. A logical structure of a descriptor is shown in figure 5.

Figure 5: Descriptor
\begin{figure}\begin{center}
\leavevmode
\psfig{figure=descriptor.eps} \end{center}\end{figure}

The descriptor locates on each process which defines the global variable, whenever necessary, a process can look up those information to decide where the data is.

In HPJava, when global data are defined, such as

  int # s = new int #;
  float [[ ]] a = new float [[ ]];
  float [[#]] b = new float [[x]];
  float [[#,#]] c = new float [[x, y]];

a descriptor shown in the figure is allocated with them.

Though they have different syntax looking and different names, such as global scalar reference an global array reference, in an implementation point of view, s, a b and c are all descriptor handles. They are not the descriptor themselves.

Therefor, syntactically , we use the descriptor handle to represent the whole data it describes; And we use different operators, such as # (when it describes scalar) or [] (when it describes array) to access the data value.

When a new array section is created, a new descriptor has to be created to depict a subset of the same array with some dimension restricted by locations or subranges. In this case, a double bracket is used.


next up previous
Next: Inquiry fields and functions Up: Global variables Previous: Array section and type
Bryan Carpenter 2002-07-12