next up previous contents
Next: remap Up: Introduction to Adlib Previous: The active process

Array sections

Adlib supports array sections analogous to Fortran array sections. A special array constructor takes an existing array and a vector of ranges as its arguments.

Suppose we have the Adlib declarations

  Procs2 p(2, 2) ;

  Range x(10, p.dim(0), BLK) ;
  Range y(10, p.dim(1), BLK) ;
  
  Array2<int> a(p, x, y) ;
which are comparable to the HPF declarations
  !HPF$ PROCESSORS P (2, 2)
  !HPF$ TEMPLATE T (10, 10)
  !HPF$ DISTRIBUTE T(BLOCK, BLOCK) ONTO P

  INTEGER A(10, 10)
  !HPF$ ALIGN A (:, :) WITH T
In Adlib a section of a can be introduced as follows
  Range u(8, 1, x) ;
  Range v(8, 1, y) ;

  Array2<int> b(a, sect(u, v)) ;
u and v are derived ranges similar to the ones introduced in section 2.5. The auxilliary function sect is syntactic sugar; it takes a list of ranges as arguments, and returns a vector containing those ranges. The array b represents a section of a containing only the non-edge points. It provides an alias for this section of a's data. This alias can be passed to Adlib-defined procedures (including other section constructors) and user-defined procedures in just the same way as a full data array.

The section b is comparable with the Fortran section

  A (2 : 9, 2 : 9)
Fortran, unlike Adlib, does not allow this section to be named, except by passing it to a procedure and referencing it as a dummy argument.

Through a defined type conversion, a local subscript can be passed to a section-constructor, in place of a range. With the earlier declarations we could also define

  Subscript i(y(5)) ;
  Array1<int> c(a, sect(x, i)) ;
which makes c analogous to the Fortran section
  A (:, 6)

Note:

Incidentally, it is not only array sections that can be distributed over restricted process groups. With the above declarations, the Adlib code
  Array1<int> d(p / i, x) ;
is comparable to the HPF 1.0 code
  INTEGER D (10)
  !HPF$ ALIGN D (:) WITH T (:, 6)

The Array base class provides the inquiry function

  ProcessGroup Array :: prc() ;
which returns the process group over which an array is distributed.



next up previous contents
Next: remap Up: Introduction to Adlib Previous: The active process



Bryan Carpenter
Fri Feb 23 15:40:28 EST 1996