int dimof(shape s, int axis)

Return the size of the "axis" dimension of the shape "s"

shape [10][20][30]S; shape []T; dimof(S,0) /* evaluates to 10 */ dimof(S,2) /* evaluates to 30 */ dimof(T,0) /* undefined behavior until shape T is defined further */ dimof(S,5) /* undefined behavior, axis > rankof(S) */

dpce_layout_t layoutof(shape s, int axis )

Return a layout descriptor, see dpce.h header, for the "axis" dimension of the shape "s".

shape [1024 block(256)]S; dpce_layout_t dS; dS = layoutof(S,0); /* yields layout descriptor for shape S, axis 0 dS.size = 256; dS.spec = DPCE_BLOCK */

shape newshape( int rank, int *dimensions, dpce_layout_t *specs )

Return a shape that is of rank "rank", where each dimension is of size *(dimension+0)...*(dimension+rank-1), with the layout described in *(specs+0)...*(specs+rank-1)

shape []T; shape U; dpce_layout_t specT[] = { {10,DPCE_BLOCK} }; int thousand = 1000; dpce_layout_t specU[] = { {50,DPCE_BLOCK}, {50,DPCE_BLOCK} }; int dims[2] = { 200, 200 }; ... T = newshape(1, &thousand, specT); /* T is now defined as rank 1 of size 1000, distributed in blocks of size 10 */ U = newshape(2, dims, specU }; /* U is now defined as rank 2 of size 200 by 200, distributed in blocks of size 50 by 50 */

int:void nodeof(shape s);

Returns a parallel int of shape s whose value at each position is the unique node designation on which each position of a give shape is mapped by the shape's layout.

shape [2]physical; /* assume dpce.h defines that there are 2 processors and the nodes are defined as 0 and 1 */ shape [10]S, [10 block(3)]T; nodeof(S); /* denotes parallel int with values: { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 }, assuming the compiler put 5 elements on each processor */ nodeof(T); /* denotes parallel int with values: { 0, 0, 0, 1, 1, 1, 0, 0, 0, 1 } */

int:physical nodepositionof(shape s)

Returns a parallel int of shape physical whose value at each position is the total number of positions of shape s mapped to the node that contains that element of shape physical.

shape [2]physical; /* assume dpce.h defines that there are 2 processors and the nodes are defined as 0 and 1 */ shape [10]S, [10 block(3)]T; nodepositionsof(S); /* denotes parallel int {5,5} */ nodepositionsof(T); /* denotes parallel int {6,4} */

void:void *palloc(shape *s, int bsize)

Allocates space for a parallel object of the shape pointed to by s and having element size of bsize bytes.

shape [20][20]S; int:S *x; ... x = palloc(&S, sizeof(int)); /* allocates space for 20x20 parallel int */

int:void pcoord(shape s, int axis)

Returns a parallel int of shape s whose value at each position is initialized to the coordinate at the position in the given axis. x = pcoord(S,0) where shape [10]S yields the values 0,1,2,3,4,5,6,7,8,9

shape [10]S, [2][2]T; int:S x; int:T y; x = pcoord(S,0); /* [0]x [1]x [2]x [3]x [4]x [5]x [6]x [7]x [8]x [9]x values: 0 1 2 3 4 5 6 7 8 9 */ y = pcoord(T,1); /* [0][0]y [0][1]y [1][0]y [1][1]y 0 1 0 1 */

void pfree(void:void *pptr)

Free up space previously gotten from palloc.

shape [20][20]S; int:S *x; ... x = palloc( &S, sizeof(int) ); ... pfree(x);

int positionsof(shape s)

Returns the computed number of positions in the shape s

shape [10][30]S; positionsof(S); /* value is 300 */

int:void prand(shape s)

Returns a parallel int of the same shape as s. It is a parallel version of the rand function.

void psrand( unsigned seed );

The psrand function provides the same functionality with respect to the prand function as the srand function does with respect to the rand function.

int rankof(shape s);

Returns the rank of shape s.

shape [10][50]S; int rank; rank = rankof(S); /* rank = 2 */

Options:

- Top of DPCE tutorial.
- Start of this section.
- Previous topic (parallel operations).
- Next topic (advanced features).

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

Send comments or suggestions to dpce2 at crescentbaysoftware.com.