Sun S3L 3.0 Programming and Reference Guide

Declaring Parallel Arrays

The Sun S3L toolkit functions described in this section share a common purpose--they all enable you to define parallel arrays that can then be operated on by other Sun S3L routines. Each of these routines returns an S3L array handle, which the application uses to reference the parallel array in subsequent S3L calls.

Each array declaring routine is described separately below.

Sun S3L also provides a routine for declaring a sparse matrix. This routine, called, S3L_declare_sparse is described in "S3L_declare_sparse ".

S3L_declare

Description

S3L_declare creates an S3L array handle that describes an S3L parallel array . It supports calling arguments that enable the user to specify

Based on the argument-supplied specifications, a process grid size is internaly determined to distribute the array as evenly as possible.


Note -

An array subgrid is the set of array elements that is allocated to a particular process.


The axis_is_local argument specifies which array axes (if any) will be local to the process. It consists of an integer vector whose length is at least equal to the rank (number of dimensions) of the array. Each element of the vector indicates whether the corresponding axis is local or not: 1 = local, 0 = not local.

When axis_is_local is ignored, all array axes except the last will be local. The last axis will be block distributed.

For greater control over array distribution, use S3L_declare_detailed().

Upon successful completion, S3L_declare returns an S3L array handle, which subsequent S3L calls can use as an argument to gain access to that array.

Syntax

The C and Fortran syntax for S3L_declare are shown below.

C/C++ Syntax


Example 7-5

#include <s3l/s3l-c.h>
#include <s3l/s3l_errno-c.h>
int
S3L_declare(A, rank, extents, type, axis_is_local, atype)
    S3L_array_t        *A
    int                rank
    int                *extents
    S3L_data_type      type
    S3L_boolean_t      *axis_is_local
    S3L_alloc_type     atype

F77/F90 Syntax


Example 7-6

include `s3l/s3l-f.h'
include `s3l/s3l_errno-f.h'
subroutine
S3L_declare(A, rank, extents, type, axis_is_local, atype, ier)
    integer*8           A
    integer*4          rank
    integer*4          extents(*)
    integer*4          type
    integer*4          axis_is_local(*)
    integer*4          atype
    integer*4          ier

Input

Output

S3L_declare uses the following arguments for output:

Error Handling

On successful completion, S3L_declare returns S3L_SUCCESS.

S3L_declare applies verious checks to the arrays it accepts as arguments. If an array argument fails any of these checks, the function returns an error code indicating the kind of error that was detected and terminates. See Appendix A, S3L Array Checking Errors of this manual for a list of these error codes.

In addition, the following conditions will cause S3L_declare to terminate and return the associated error value:

Notes

When S3L_USE_MMAP or S3L_USE_SHMGET is used on a 32-bit platform, the part of an S3L array owned by a single SMP cannot exceed 2 gigabytes.

When S3L_USE_MALLOC or S3L_USE_MEMALIGN64 is used, the part of the array owned by any single process can not exceed 2 gigabytes.

If these size restrictions are violated, an S3L_ERR_MEMALLOC will be returned. On 64-bit platforms, the upper bound is equal to the system's maximum available memory.

Examples

../examples/s3l/transpose/ex_trans1.c
../examples/s3l/grade-f/ex_grade.f

Related Functions

S3L_declare_detailed(3)
S3L_free(3)

S3L_declare_detailed

Description

This subroutine offers the same functionality as S3L_declare, but supports the additional input argument, addr_a, which gives the user additional control over array distribution.

Syntax

The C and Fortran syntax for S3L_declare_detailed are shown below.

C/C++ Syntax


Example 7-7

#include <s3l/s3l-c.h>
#include <s3l/s3l_errno-c.h>
int
S3L_declare_detailed(A, addr_a, rank, extents, type, blocksizes, proc_src,
axis_is_local, pgrid, atype)
    S3L_array_t        *A
    void               *addr_a
    int                rank
    int                *extents
    S3L_data_type      type
    int                *blocksizes
    int                *proc_src
    S3L_boolean_t      *axis_is_local
    S3L_pgrid_t        pgrid
    S3L_alloc_type     atype

F77/F90 Syntax


Example 7-8

include `s3l/s3l-f.h'
include `s3l/s3l_errno-f.h'
subroutine
S3L_declare_detailed(A, addr_a, rank, extents, type, blocksizes, proc_src,
axis_is_local, pgrid, atype, ier)
    integer*8          A
    <type>             array(1)
    pointer            (addrr_a,array)
    integer*4          rank
    integer*4          extents(*)
    integer*8          type
    integer*4          *blocksizes
    integer*4          *proc_src
    integer*4          axis_is_local(*)
    integer*8          pgrid
    integer*4          atype
    integer*4          ier

where <type> is one of: integer*4, integer*8, real*4, real*8, complex*8, or complex*16.

Input

S3L_declare_detailed accepts the following arguments as input:

Output

Error Handling

On successful completion, S3L_declare_detailed returns S3L_SUCCESS.

S3L_declare_detailed applies various checks to the arrays it accepts as arguments. If an array argument fails any of these checks, the function returns an error code indicating the kind of error that was detected and terminates. See Appendix A, S3L Array Checking Errors of this manual for a list of these error codes.

In addition, the following conditions will cause S3L_declare_detailed to terminate and return the associated error value:

Notes

When S3L_USE_MMAP or S3L_USE_SHMGET is used on a 32-bit platform, the part of an S3L array owned by a single SMP cannot exceed 2 gigabytes.

When S3L_USE_MALLOC or S3L_USE_MEMALIGN64 is used, the part of the array owned by any single process cannot exceed 2 gigabytes.

If these size restrictions are violated, an S3L_ERR_MEMALLOC will be returned. On 64-bit platforms, the upper bound is equal to the system's maximum available memory.

Examples

../examples/s3l/utils/copy_array.c
../examples/s3l/utils-f/copy_array.f
../examples/s3l/utils/get_attribute.c
../examples/s3l/utils-f/get_attribute.f
../examples/s3l/utils/scalapack_conv.c
../examples/s3l/utils-f/scalapack_conv.f

Related Functions

S3L_declare(3)
S3L_free(3)
S3L_get_process_grid(3)
S3L_set_process_grid(3)

S3L_DefineArray

Description

S3L_DefineArray associates an internal S3L array handle to a user-distributed parallel array. The array must be distributed in such a manner that it can be expressed as a block cyclic distribution. The array handle returned by S3L_DefineArray can then be used in subsequent calls by Sun MPI programs to S3L functions.

S3L_DefineArray does not allocate the memory required to store the local (process specific) part on the array. The user must allocate sufficient memory on each process to hold the local part of the parallel array before calling this function.

Syntax

The C and Fortran syntax for S3L_DefineArray are shown below.

C/C++ Syntax


Example 7-9

#include <s3l/s3l-c.h>
#include <s3l/s3l_errno-c.h>
S3L_array_t
S3L_DefineArray(address, rank, type, extents, blocks,
sprocs, p_ext)
    void               address
    int                rank
    int                type
    int                *extents
    int                *blocks
    int                *sprocs
    int                *p_ext

F77/F90 Syntax


Example 7-10

include `s3l/s3l-f.h'
include `s3l/s3l_errno-f.h'
integer*8 function
S3L_DefineArray(address,
rank, type, extents, blocks, sprocs, p_ext)
    <type>             array(1)
    integer*4          rank
    pointer            (addrr_a,array)
    integer*4          rank
    integer*4          type
    integer*4          extents(*)
    integer*4          blocks(*)
    integer*4          sprocs(*)
    integer*4          p_ext(*)

Input

S3L_DefineArray accepts the following arguments as input:

Note that process ordering within the process grid is always column major (F77 major) and that the product of the extents of the process grid must equal the total number of processes participating in the computation (that is, must equal the size of MPI_COMM_WORLD).

Error Handling

On success, S3L_DefineArray returns an S3L array handle that can be used for subsequent calls to other Sun S3L functions.

On error, it returns 0.

Examples

../examples/s3l/api
../examples/s3l/api-f

Related Functions

S3L_UnDefineArray(3)