next up previous
Next: Subgroup and Subrange Up: Basic concepts Previous: Process group

Distributed dimension and index with position

In a programming language, array elements are corresponding to an integer sequence, for example in Java, we have

  int[] a = new int[10];

then, when accessing the array, we use an index in the sequence,

  for (int i=0; i<a.length; i++)
    ...a[i]...

In fact, we have two concepts here, an index i and a range where the index can be chosen from, specified by length. They are both of type int.

When describing an array with position information, we need two new build-in classes in HPJava to represent those two concepts,

Range. A range maps an integer interval into a process dimension according to certain distribution format. Ranges describe the extent and mapping of array dimensions.

Location. A location, or slot, is an abstract element of a range. A range can be regarded as a set of locations, actually it is a one-to-one mapping between the global index and locations.

For example,

  Range x = new BlockRange(100, p.dim(0)) ;
  Range y = new CyclicRange(200, p.dim(1)) ;

will create two ranges on the different process dimensions of Group p, one is block distributed, the other is cyclic distributed. We will further explain the function dim and the meaning of block and cyclic range in section 2.1.4.

We can get 100 different items as Location references mapped by the range x from integers, for example, the first one is,

  Location i = x|0;

here ``|'' is an operator defined on Rang and int.

When mapping a location reference from a range by an integer, its order or rank in the range is used. We can also get this integer value from an inquiry function in Range class.

  int order = x.id(i);

will assign variable order to 0.


next up previous
Next: Subgroup and Subrange Up: Basic concepts Previous: Process group
Bryan Carpenter 2002-07-12