A shape is a template for parallel data and is analgous to HPF's template directive. A shape typically reflects the natural organization of the data. In order to define parallel variables, you must first define a shape. A shape is specified by the following:

Also associated with a shape is a Context which is a representation of the active and inactive elements of a parallel variable as controlled by conditional expressions, where and everywhere statements.

There are 3 types of shapes: fully specified; Partially specified; and fully unspecified. A fully specified shape is one in which the rank and dimensions are known when the shape is declared. When only the rank is defined the shape is said to be "Partially specified" and, when there is no rank information, the shape is said to be "fully unspecified".

The use of fully unspecified shapes can lead to run-time performance degredation since more code checking needs to be done at run-time rather than at compile time.

Declaration of a shape:

 shape [10][100]S;   /* fully specified, 2 dimensional, 10 by 100 */
 shape [][]T;        /* Partially specified, 2 dimensional of unknown size */
 shape X;            /* fully unspecified, rank and dimensions unknown */

In the above examples, no information is given as to the distribution or layout of the shapes. When this information is not present, it is up to the DPC compiler to determine what layout is most efficient. The distribution can be suggested by using the keywords block or scale.

The block specifier suggests that data is to be distributed in blocks of the indicated size. The scale specifier suggests that data be partitioned into maximal blocks with block dimensions proportional to the scale expressions in the corresponding dimensions.

 shape [1000 block(100)]A;   
         /* The fully specified shape A, has a rank of 1 and 1000 positions, 
            and objects of shape A are to be distributed in blocks of 
            100 elements per partition. */

 shape [100 scale(1)][100 scale(2)]B;  
         /* The fully specified shape B, has a rank of 2 with 100 positions
            in each dimension. The distribution is suggested to be in blocks
            of k by 2k elements; k will be be approxiametly 
            sqrt((100*100)/2n) where n is the number of partitions. */

The programmer should keep in mind that in declaring shapes of rank "n", that assignments involving such shapes are, in effect, performing "n" nests of loops. The number of nests of loops may effect the optimization capability of the compiler. In general, optimizing compilers can efficiently handle loops of nest 3, the required number for such operations as matrix multiply; however, nests of loops larger then 3 may impede complete optimization. The moral for the programmer is that they should be judicious in their use of multi-dimensional shapes greater than rank of 3.

You can return to the top of the DPCE tutorial, or move back to the previous topic (simple example), or on to the next topic (parallel variables).

©1995 Pacific-Sierra Research Corporation. All rights reserved.

Send comments or suggestions to dpce2 at