Sun S3L provides an extensive subset of auxiliary routines, referred to as the toolkit functions, which enable you to do the following.
Set up the proper environment to support calls to Sun S3L subroutines:
S3L_init - See "S3L_init "
Exit the Sun S3L environment once use of the library is over:
S3l_exit - See "Leaving a Sun S3L Environment"
Set up parallel arrays and allocate memory for them:
S3L_declare - See "S3L_declare "
S3L_declare_detailed - See "S3L_declare_detailed "
S3L_DefineArray - See "S3L_DefineArray "
Defining and freeing parallel process grids:
S3L_set_process_grid - See "S3L_set_process_grid "
S3L_free_process_grid - See "S3L_free_process_grid "
Undefine a parallel array:
S3L_free - See "S3L_free "
S3L_UnDefineArray - See "S3L_UnDefineArray "
Perform operations on elements of parallel arrays:
S3L_array_op1 - See "S3L_array_op1 "
S3L_array_op2 - See "S3L_array_op2 "
S3L_array_scalar_op2 - See "S3L_array_scalar_op2 "
S3L_cshift - See "S3L_cshift "
S3L_forall - See "S3L_forall "
S3L_reduce - See "S3L_reduce "
S3L_reduce_axis - See "S3L_reduce_axis "
S3L_set_array_element - See "S3L_set_array_element, S3L_get_array_element, S3L_set_array_element_on_proc, and S3L_get_array_element_on_proc"
S3L_set_array_element_on_proc - "S3L_set_array_element, S3L_get_array_element, S3L_set_array_element_on_proc, and S3L_get_array_element_on_proc"
S3L_get_array_element - See "S3L_set_array_element, S3L_get_array_element, S3L_set_array_element_on_proc, and S3L_get_array_element_on_proc"
S3L_get_array_element_on_proc - See "S3L_set_array_element, S3L_get_array_element, S3L_set_array_element_on_proc, and S3L_get_array_element_on_proc"
S3L_zero_elements - See "S3L_zero_elements "
Extract various kinds of information about parallel arrays and subgrids:
S3L_describe - See "S3L_describe "
S3L_get_attribute - See "S3L_get_attribute "
Read a file into a parallel array, write all or part of a parallel array to a file, and print all or part of a parallel array to standard out:
S3L_read_array - See "S3L_read_array and S3L_read_sub_array"
S3L_read_sub_array - See "S3L_read_array and S3L_read_sub_array"
S3L_print_array - See "S3L_print_array and S3L_print_sub_array"
S3L_print_sub_array - See "S3L_print_array and S3L_print_sub_array"
S3L_write_array - See "S3L_write_array and S3L_write_sub_array"
S3L_write_sub_array - See "S3L_write_array and S3L_write_sub_array"
Copy the contents of one parallel array into another:
S3L_copy_array - See "S3L_copy_array "
Convert ScaLAPACK descriptors to S3L arrays and vice versa:
S3L_from_ScaLAPACK_desc - See "S3L_from_ScaLAPACK_desc "
S3L_to_ScaLAPACK_desc - See "S3L_to_ScaLAPACK_desc "
Miscellaneous general control functions:
S3L_thread_comm_setup - See " S3L_thread_comm_setup"
S3L_set_safety - See "S3L_set_safety "
S3L_get_safety - See "S3L_get_safety "
Before an application can start using Sun S3L functions, every process involved in the application must call S3L_init to initialize the S3L environment. S3L_init initializes the BLACS environment as well.
S3L_init also initializes the Sun MPI layer if the user has not done so. If S3L_init calls MPI_Init internally, subsequent use of S3L_exit will also result in an internal call to MPI_Finalize.
S3L_init tests the MPI library to verify that it is Sun MPI. If not, it returns an error message and terminates.
If the MPI layer is Sun MPI, S3L_init proceeds to initialize the S3L environment, the BLACS environment, and if not already initialized, the Sun MPI environment. It also enables the Prism library to access Sun S3L operations.
The C and Fortran syntax for S3L_init are illustrated below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_init() |
include `s3l/s3l-f.h' include s3l/s3l_errno-f.h' subroutine S3L_init(ier) integer*4 ier |
S3L_init takes no input arguments.
When called from a Fortran program, S3L_init returns error status in ier.
On successful completion, S3L_init returns S3L_SUCCESS.
S3L_init tests to see if the MPI library is Sun MPI. If not, it returns the following error message and terminates.
S3L error: invalid MPI. Please use Sun HPC MPI.
../examples/s3l/utils/copy_array.c ../examples/s3l/utils/copy_array.f
S3L_exit(3)
When an application is finished using Sun S3L functions, it must call S3L_exit to perform various cleanup tasks associated with the current S3L environment.
S3L_exit checks to see if the S3L environment is in the initialized state--S3L_init has been called more recently than S3L_exit. If not, S3L_exit returns the error message S3L_ERR_NOT_INIT and exits.
The C and Fortran syntax for S3L_exit are illustrated below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_exit() |
include `s3l/s3l-f.h' include s3l/s3l_errno-f.h' subroutine S3L_exit(ier) integer*4 ier |
S3L_exit takes no input arguments.
When called from a Fortran program, S3L_exit returns error status in ier.
On successful completion, S3L_exit returns S3L_SUCCESS.
The following condition will cause S3L_exit to terminate and return the associated error value:
S3L_ERR_NOT_INIT - S3L has not been initialized.
../examples/s3l/dense_matrix_ops/inner_prod.c ../examples/s3l/dense_matrix_ops-f/inner_prod.f ../examples/s3l/utils/copy_array.f
S3L_init(3)
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.
Declare a parallel array - See "S3L_declare ".
Declare a parallel array with detailed control over attributes - See "S3L_declare_detailed "
Define a parallel array - "S3L_DefineArray ".
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 creates an S3L array handle that describes an S3L parallel array . It supports calling arguments that enable the user to specify
the array's rank (number of dimensions)
the extent of each axis
the array's data type
which axes, if any, will be distributed locally
how memory will be allocated for the array
Based on the argument-supplied specifications, a process grid size is internaly determined to distribute the array as evenly as possible.
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.
The C and Fortran syntax for S3L_declare are shown below.
#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 |
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 |
extents - An integer vector whose length is equal to the number of dimensions in the array. Each element in extents specifies the extent of the corresponding array axis. Note that axis indexing is zero-based for the C interface and one-based for the Fortran interface, as follows:
When called from a C or C++ application, the first element of extents corresponds to axis 0, the second element to axis 1, and so forth.
When called from an F77 or F90 application, the first element corresponds to axis 1, the second to axis 2, and so forth.
type - Specifies the array's data type; this must be a type supported by Sun S3L. See Chapter 4, Sun S3L Data Types for a complete list of supported data types.
axis_is_local - An integer vector whose length equals the array's rank. Each element of axis_is_local controls the distribution of the corresponding array axis as follows:
If axis_is_local[i]= 0, axis[i] of the array will be block-distributed along axis [i] of the process grid.
If axis_is_local[i]= 1, axis[i] will not be distributed.
If axis_is_local is NULL (C/C++) or if its first integer value is negative (F77/F90), this argument will be ignored.
atype - Use one of the following predefined values to specify how the array will be allocated:
S3L_USE_MALLOC - Uses malloc() to allocate the array subgrids.
S3L_USE_MEMALIGN64 - Uses memalign() to allocate the array subgrids and to align them on 64-bit boundaries.
S3L_USE_MMAP- Uses mmap() to allocate the array subgrids. Array subgrids on the same node will be in shared memory.
S3L_USE_SHMGET - Uses shmget() to allocate the array subgrids. Array subgrids on the same node will be in intimate shared memory.
S3L_declare uses the following arguments for output:
A - S3L_declare returns the array handle in A.
ier (Fortran only) - When called from a Fortran program, S3L_declare_detailed returns error status in ier.
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:
S3L_ERR_ARG_RANK - The rank specified is invalid.
S3L_ERR_ARG_EXTENTS - One or more of the array extents is less than 1.
S3L_ERR_ARG_BLKSIZE - One or more blocksizes is less than 1.
S3L_ERR_ARG_DISTTYPE - axis_is_local has one or more invalid values. See the description of axis_is_local in the Input section for details.
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/s3l/transpose/ex_trans1.c ../examples/s3l/grade-f/ex_grade.f
S3L_declare_detailed(3) S3L_free(3)
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.
The C and Fortran syntax for S3L_declare_detailed are shown below.
#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 |
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.
S3L_declare_detailed accepts the following arguments as input:
addr_a - If the atype argument is set to S3L_DONOT_ALLOCATE, addr_a is taken as the starting address of the local (per process) portion of the parallel array A. If atype is not equal to S3L_DONOT_ALLOCATE, addr_a will be ignored.
rank - Specifies the number of dimensions the array will have. The range of legal values for rank is 1 <= rank <= 31.
extents - An integer vector whose length is equal to the number of dimensions in the array. Each element in extents specifies the extent of the corresponding array axis. Note that axis indexing is zero-based for the C interface and one-based for the Fortran interface, as follows:
When called from a C or C++ application, the first element of extents corresponds to axis 0, the second element to axis 1, and so forth.
When called from an F77 or F90 application, the first vector element corresponds to axis 1, the second to axis 2, and so forth.
type - Specifies the array's data type; this must be a type supported by Sun S3L. See Chapter 4, Sun S3L Data Types for a complete list of supported data types.
blocksizes - Specifies the blocksize to be used in a block cyclic distribution along each axis. If blocksizes is NULL (C/C++) or if its first element is equal to -1 (F77/F90), default blocksizes will be chosen by the system.
proc_src - Vector of length at least equal to the rank. The indices of the processes contain the start of the array--that is, the first element along the particular axis. If this argument is a NULL pointer (C/C++) or if its first element is less than zero (F77/F90), default values will be used. Along each axis, the process whose process grid coordinate along that axis is equal to 0 contains the first array element. If present, the pgrid argument (process grid) should also be present. Otherwise an error code will be returned.
axis_is_local - An integer vector whose length equals the number of dimensions in the array. Each element of axis_is_local controls the distribution of the corresponding array axis as follows:
If axis_is_local[i]= 0, axis[i] of the array will be block-distributed along axis [i] of the process grid.
If axis_is_local[i]= 1, axis[i] will not be distributed.
The axis_is_local argument is used only if a pgrid is not specified. If it is NULL (C/C++) or if its first integer value is negative (F77/F90), axis_is_local will be ignored.
A process grid is the array of processes onto which the data is distribued.
pgrid - An S3L process grid handle that was obtained by calling either S3L_set_process_grid or S3L_get_attribute. If this argument is NULL (C/C++) or is equal to zero (F77/F90), S3L will choose an appropriate pgrid for the array.
atype - Use one of the following predefined values to specify how the array will be allocated:
S3L_USE_MALLOC - Uses malloc() to allocate the array subgrids.
S3L_USE_MEMALIGN64 - Uses memalign() to allocate the array subgrids and to align them on 64-bit boundaries.
S3L_USE_MMAP- Uses mmap() to allocate the array subgrids. Array subgrids on the same SMP will be in shared memory.
S3L_USE_SHMGET - Uses shmget() to allocate the array subgrids. Array subgrids on the same SMP will be in shared memory.
A - S3L_declare_detailed returns the array handle in A.
ier (Fortran only) - When called from a Fortran program, S3L_declare_detailed returns error status in ier.
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:
S3L_ERR_ARG_RANK - The rank specified is invalid in one of the following ways:
If called from a C/C++ program, it is negative or greater than 31
If called from an F77/F90 program, it is zero or greater than 32.
S3L_ERR_ARG_EXTENTS - One or more of the array extents is less than 1.
S3L_ERR_ARG_BLKSIZE - One or more blocksizes is less than 1.
S3L_ERR_ARG_DISTTYPE - axis_is_local has one or more invalid values. See the description of axis_is_local in the Input section for details.
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/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
S3L_declare(3) S3L_free(3) S3L_get_process_grid(3) S3L_set_process_grid(3)
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.
The C and Fortran syntax for S3L_DefineArray are shown below.
#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 |
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(*) |
S3L_DefineArray accepts the following arguments as input:
address - The starting address of the local (within the process) portion of a parallel array. In C, the user must allocate this local memory (for example, via the malloc function). In F77, the address is defined as a pointer to a local storage area.
rank - Specifies the number of dimensions the array will have. The range of legal values for rank is 1 <= rank <= 31.
type - Denotes the parallel array's data type. In C, it is a variable of type S3L_data_type. In F77, it is a variable of type integer*4.
extents - Specifies the extents of the parallel array.
blocks - Specifies the blocksizes of the block cyclic distribution of the parallel array along each axis. Note that, block cyclic distribution is a general classification that includes other distribution types, such as CYCLIC(1) and BLOCK(n) distribution.
sprocs - The starting processes of the block cyclic array distributions. If sprocs[i] = j, block 0 of the block cyclic distribution of the array along axis [i] is located in process j.
p_ext - The extents of the process grid upon which the array is distributed. If, for example, p_ext[0] = 2, p_ext[1] = 3, p_ext[2] = 4, the three-dimensional parallel array will be distributed on a 2 x 3 x 4 process grid.
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).
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/s3l/api ../examples/s3l/api-f
S3L_UnDefineArray(3)
S3L_set_process_grid allows the user to define various aspects of an internal process grid. It returns a process grid handle, which subsequent calls to other Sun S3L functions can use to refer to that process grid.
The C and Fortran syntax for S3L_DefineArray are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_set_process_grid(pgrid, rank, majorness, grid_extents, plist_length, process_list) S3L_pgrid_t *pgrid int rank int majorness int *grid_extents int plist_length int *process_list |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_set_process_grid(pgrid, rank, majorness, grid_extents, plist_length, process_list, ier) integer*8 pgrid integer*4 rank integer*4 majorness integer*4 grid_extents(*) integer*4 plist_length integer*4 process_list(*) integer*4 ier |
S3L_set_process_grid accepts the following arguments as input:
rank - Specifies the number of dimensions the array will have. The range of legal values for rank is 1 <= rank <= 31.
majorness - Use one of the following predefined values to specify the order of loop execution:
S3L_MAJOR_ROW - Rightmost axis varies fastest.
S3L_MAJOR_COLUMN - Leftmost axis varies fastest.
grid_extents - Integer array whose length equals the rank of the process grid. It contains a list of process grid extents. Each element in the array specifies the extent of the corresponding process grid axis. Note that axis indexing is zero-based for the C/C++ interface and one-based for the F77/F90 interface, as follows:
When called from a C or C++ application, the first element of grid_extents corresponds to axis 0, the second element to axis 1, and so forth.
When called from an F77 or F90 application, the first element corresponds to axis 1, the second to axis 2, and so forth.
plist_length - Specifies the length of the process. In C/C++ programs, if the process_list argument is a NULL pointer, plist_length must be 0.
process_list - Integer array whose length equals the number of processes in the grid. It contains a list of processes. For C/C++ programs, if process_list is a NULL pointer, plist_length must be 0.
S3L_set_process_grid uses the following arguments for output:
pgrid - The process grid handle returned by the function.
ier (Fortran only) - When called from a Fortran program, S3L_set_process_grid returns error status in ier.
On success, S3L_set_process_grid returns S3L_SUCCESS.
S3L_set_process_grid performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated error code.
S3L_ERR_ARG_RANK - Invalid rank.
S3L_ERR_ARG_MAJOR - Invalid majorness.
S3L_ERR_PGRID_EXTENTS - Grid size (calculated as product of process grid extents) is less than 1.
S3L_ERR_ARRTOOSMALL - plist_length is greater than 0 but less than the size of the grid (calculated from the product of process grid extents).
S3L_ERR_ARG_NULL - In a C/C++ program, plist_length is greater than 0 but process_list is a NULL pointer.
../examples/s3l/utils/scalapack_conv.c ../examples/s3l/utils-f/scalapack_conv.f
S3L_declare_detailed(3) S3L_free_process_grid(3)
S3L_free_process_grid frees the process grid handle returned by a previous call to S3L_set_process_grid.
The C and Fortran syntax for S3L_DefineArray are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_free_process_grid S3L_pgrid_t *pgrid |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_free_process_grid(pgrid, ier) integer*8 pgrid integer*4 ier |
S3L_free_process_grid accepts the following arguments as input:
pgrid - The process grid handle returned by a previous call to S3L_set_process_grid.
S3L_free_process_grid uses the following arguments for output:
ier (Fortran only) - When called from a Fortran program, S3L_free_process_grid returns error status in ier.
On success, S3L_free_process_grid returns S3L_SUCCESS.
On error, the following error code may be returned:
S3L_PGRID_ERR_NULL - An invalid process grid argument was supplied.
../examples/s3l/utils/scalapack_conv.c ../examples/s3l/utils-f/scalapack_conv.f
S3L_set_process_grid(3)
S3L_free deallocates the memory reserved for a parallel S3L array and undefines the associated array handle.
If memory was allocated for the array by the user rather than by S3L, S3L_free destroys the array handle, but does not deallocate the memory. This situation can arise when S3L_declare_detailed() is invoked with the atype option set to S3L_DONOT_ALLOCATE.
The C and Fortran syntax for S3L_free are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_free(a) S3L_array_t *a |
include `s3l/s3l-f.h include `s3l/s3l_errno-f.h' subroutine S3L_free(a, ier) integer*8 a integer*4 ier |
S3L_free accepts the following argument as input:
a - Handle for the parallel S3L array that is to be deallocated. This handle was returned by a previous call to S3L_declare, S3L_declare_detailed.
S3L_free uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_free returns error status in ier.
On success, S3L_free returns S3L_SUCCESS.
On error, the following error code may be returned:
S3L_ERR_ARG_ARRAY - a is a NULL pointer (C/C++) or 0 (F77/F90).
../examples/s3l/io/ex_print1.c ../examples/s3l/io-f/ex_print1.f
S3L_declare(3) S3L_declare_detailed(3)
S3L_UnDefineArray frees the array handle and the associated memory that were set up by a previous call to S3L_DefineArray.
S3L_UnDefineArray does not free the local (process-resident) memory, where the local part of a parallel array is stored. The user is responsible for deallocating local memory assigned to the parallel array before the parallel program exits.
The C and Fortran syntax for S3L_UnDefineArray are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_UnDefineArray(a) S3L_array_t a |
include `s3l/s3l-f.h include `s3l/s3l_errno-f.h' subroutine S3L_UnDefineArray(a) integer*8 a |
S3L_UnDefineArray accepts the following argument as input:
a - Handle for the parallel S3L array that is to be deallocated. This handle was returned by a previous call to S3L_DefineArray.
S3L_UnDefineArray does not return any value.
../examples/s3l/api ../examples/s3l/api.f ../examples/s3l/array_utils
S3L_DefineArray(3) S3L_declare(3) S3L_declare_detailed(3) S3L_free(3)
The toolkit functions described in this section enable the user to apply various kinds of operations on a parallel array's elements.
S3L_array_op1 applies a predefined unary (single-operand) operation to each element of an S3L parallel array. The S3L array handle argument, a, identifies the parallel array to be operated on and the op argument specifies the operation to be performed. The value of op must be:
S3L_OP_ABS - Replaces each element in a with its absolute value.
S3L_OP_MINUS - Replaces each element in a with its negative value.
S3L_OP_EXP - Replaces each element in the real or complex array a with its exponential.
The C and Fortran syntax for S3L_array_op1 are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_array_op1(a, op) S3L_array_t a int op |
include `s3l/s3l-f.h include `s3l/s3l_errno-f.h' subroutine S3L_array_op1(a, op, ier) integer*8 a integer*4 op integer*4 ier |
S3L_array_op1 accepts the following arguments as input:
a - S3L array handle for the parallel array on which the operation will be performed.
op - Predefined constant specifying the operation to be applied. See the Description section for details.
S3L_array_op1 uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_array_op1 returns error status in ier.
On success, S3L_array_op1 returns S3L_SUCCESS.
S3L_array_op1 performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following condition will cause the function to terminate and return the associated error code.
S3L_ERR_ARG_DTYPE - op is equal to S3L_OP_EXP but a is of integer type.
../examples/s3l/fft/ex_fft1.c ../examples/s3l/deconv-f/ex_deconv.f
S3L_array_op2(3) S3L_array_scalar_op2(3) S3L_reduce_scalar(3)
S3L_array_op2 applies the operation specified by op to elements of parallel arrays a and b, which must be of the same type and have the same distribution. The parameter op can be one of the following:
S3L_OP_MUL - a equals a .* b
S3L_OP_CMUL - a equals a .* conjg(b)
S3L_OP_DIV - a equals a ./ b
S3L_OP_MINUS - a equals a - b
S3L_OP_PLUS - a equals a + b
The operators ".*" and "./" denote pointwise multiplication and division of the elements in arrays a and b.
S3L_OP_MUL replaces each element in a with the elementwise product of multiplying a and b.
S3L_OP_CMUL performs the same operation as S3L_OP_MUL, except it multiplies each element in a by the conjugate of the corresponding element in b.
S3L_OP_DIV performs elementwise division of a by b, overwriting a with the integer (truncated quotient) results.
S3L_OP_MINUS performs elementwise subtraction of b from a, overwriting a with the differences.
S3L_OP_PLUS performs elementwise addition of a with b, overwriting a with the sum.
The C and Fortran syntax for S3L_array_op2 are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_array_op2(a, b, op) S3L_array_t a S3L_array_t b int op |
include `s3l/s3l-f.h include `s3l/s3l_errno-f.h' subroutine S3L_array_op2(a, b, op, ier) integer*8 a integer*8 b integer*4 op integer*4 ier |
S3L_array_op2 accepts the following arguments as input:
a - S3L array handle for one of two parallel arrays to which the operation will be applied.
b - S3L array handle for the second of two parallel arrays to which the operation will be applied.
op - Predefined constant specifying the operation to be applied. See the Description section for details.
S3L_array_op2 uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_array_op2 returns error status in ier.
On success, S3L_array_op2 returns S3L_SUCCESS.
S3L_array_op2 performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated error code:
S3L_ERR_MATCH_HOME - Both arrays are local but not on the same process.
S3L_ERR_MATCH_ALIGN - The arrays do not have the same subgrid sizes.
S3L_ERR_ARG_OP - An illegal operation was requested.
../examples/s3l/fft/ex_fft1.c ../examples/s3l/fft-f/ex_fft1.f
S3L_array_op1(3) S3L_array_scalar_op2(3) S3L_reduce_scalar(3)
S3L_array_scalar_op2 applies a binary operation to each element of an S3L array that involves the element and a scalar.
op determines which operation will be performed. It can be one of:
S3L_OP_MULT - pointwise multiplication.
S3L_OP_DIV - pointwise division.
S3L_OP_PLUS - pointwise addition.
S3L_OP_MINUS - pointwise subtraction.
S3L_OP_ASSIGN - assignment.
The C and Fortran syntax for S3L_array_scalar_op2 are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_array_scalar_op2(a, scalar, op) S3L_array_t a void *scalar int op |
include `s3l/s3l-f.h include `s3l/s3l_errno-f.h' subroutine S3L_array_scalar_op2(a, scalar, op, ier) integer*8 a <type> scalar integer*4 op integer*4 ier |
where <type> is one of: integer*4, integer*8, real*4, real*8, complex*8, or complex*16.
S3L_array_scalar_op2 accepts the following arguments as input:
a - S3L array handle for the parallel array to which the operation will be applied.
scalar - Scalar value used as an operand in the operation applied to each element of a.
op - Predefined constant specifying the operation to be applied. See the Description section for details.
S3L_array_scalar_op2 uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_array_scalar_op2 returns error status in ier.
On success, S3L_array_scalar_op2 returns S3L_SUCCESS.
S3L_array_scalar_op2 performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following condition will cause the function to terminate and return the associated error code:
S3L_ERR_ARG_OP - op is not one of: S3L_OP_MUL, S3L_OP_DIV, S3L_OP_PLUS, S3L_OP_MINUS, or S3L_OP_ASSIGN
../examples/s3l/fft/ex_fft1.c ../examples/s3l/fft-f/ex_fft1.f
S3L_array_op1(3) S3L_array_op2(3) S3L_reduce_scalar(3)
S3L_cshift performs a circular shift of a specified amount along a specified axis of the parallel array associated with array handle A. The argument axis indicates the dimension to be shifted, and index prescribes the shift distance.
Shift direction is upwards for positive index values and downward for negative index values.
For example, if A denotes a one-dimensional array of length n before the cshift, B denotes the same array after the cshift, and index is equal to 1, the array A will be circularly shifted upwards, as shown below:
For C Programs
B[1:n-1]=A[0:n-2], B[0]=A[n-1]
For Fortran Programs
B(2:n)=A(1:n-1), B(1)=A(n)
The C and Fortran syntax for S3L_cshift are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_cshift(A, axis, index) S3L_array_t A void axis int index |
include `s3l/s3l-f.h include `s3l/s3l_errno-f.h' subroutine S3L_cshift(A, axis, index, ier) integer*8 A integer*4 axis integer*4 index integer*4 ier |
S3L_cshift accepts the following arguments as input:
A - Array handle for the parallel array to be shifted.
axis - Specifies the axis along which the shift is to take place. This value must assume zero-based axis indexing when S3L_cshift is called from a C or C++ application and one-based indexing when called from an F77 or F90 application.
index - Specifies the shift distance. If the extent of the axis being shifted is N, legal values for index are: -N < index < N.
S3L_cshift uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_cshift returns error status in ier.
On success, S3L_cshift returns S3L_SUCCESS.
S3L_cshift performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following condition will cause the function to terminate and return the associated error code:
S3L_ERR_ARG_AXISNUM - Invalid axis value.
S3L_ERR_INDX_INVALID - index value is out of range.
../examples/s3l/utils/cshift_reduce.c ../examples/s3l/utils-f/cshift_reduce.f
S3L_reduce S3L_reduce_axis
S3L_forall applies a user-defined function to elements of a parallel Sun S3L array. and sets its values accordingly. Three different function types are supported. These types are described in Table 7-1.
Table 7-1 User-Defined Function Types for S3L_forall
fn_type |
C Prototype |
Fortran Interface |
---|---|---|
S3L_ELEM_FN1 |
void user_fn(void *elem_addr); |
subroutine user_fn(a) <type> a end user_fn |
S3L_ELEM_FNN |
void user_fn(void *elem_addr, int n); |
subroutine user_fn(a,n) <type> a integer*4 n end user_fn |
S3L_ELEM_FN |
void user_fn(void *elem_addr, int *coord); |
subroutine user_fn(a, coord) <type> a |
Here, <type> is one of: integer*4, integer*8, real*4, real*8, complex*8, or complex*16 and rank is the rank of the array.
For S3L_ELEM_FN1, the user function is applied to each element in the array.
For S3L_ELEM_FNN, the user function is supplied the local subgrid address and subgrid size and iterates over subgrid elements. This form delivers the highest performance because the looping over the elements is contained within the function call.
For S3L_INDEX_FN, the user function is applied to each element in the subarray specified by the triplets argument to S3L_forall. If the triplets argument is NULL in C/C++ or has a leading value of 0 in F77/F90, the whole array is implied. The user function may involve the global coordinates of the array element; these are contained in the coord argument. Global coordinates of array elements are 0-based for C programs and 1-based for Fortran programs.
When a Fortran program uses triplets, the length of first axis of the triplets must equal the rank of the array. Failure to meet this requirement can produce wrong results or a segmentation violation.
A subgrid is the portion of the parallel array that is owned by a process. A subarray is the portion of the parallel array that is described by a lower bound, an upper bound, and a stride in each dimension.
The C and Fortran syntax for S3L_cshift are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_forall(a, user_fn, fn_type, triplets) S3L_array_t a void (*user_fn)() int fn_type int triplets[rank][3] |
where rank is the rank of the array.
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_forall(a, user_fn, fn_type, triplets, ier) integer*8 a <external> user_fn integer*4 fn_type integer*4 triplets(rank,3) integer*4 ier |
where rank is the rank of the array.
S3L_forall accepts the following arguments as input:
a - Parallel array to which the function will be applied.
user_fn - Pointer to the user-defined function.
fn_type - Predefined value specifying the class of functions to which the function belongs. See the Description section for a list of valid fn_type entries.
triplets - An integer vector that is used to restrict the function to a range of elements. A triplet takes the form:
inclusive lower bound inclusive upper bound stride
for each axis of the array. The stride must be positive. To apply the function to all the elements in the array, set triplets to NULL (C/C++) or to 0 (F77/F90).
S3L_forall uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_forall returns error status in ier.
On success, S3L_forall returns S3L_SUCCESS.
S3L_forall performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following condition will cause the function to terminate and return the associated error code:
S3L_ERR_FORALL_INVFN - User-specified function is invalid. fn_type is not one of:
S3L_ELEM_FN1
S3L_ELEM_FNN
S3L_INDEX_FN
S3L_ERR_INDX_INVALID - fn_type is S3L_INDEX_FN and one or more of the elements in the triplets argument has an invalid value.
../examples/s3l/forall/ex_forall.c ../examples/s3l/forall/ex_forall2.cc ../examples/s3l/forall-f/ex_forall.f
S3L_reduce performs a predefined reduction function over all elements of a parallel array. The array is described by the S3L array handle argument A. The argument op specifiesthe type of reduction operations, which can be one of the following:
S3L_OP_SUM - Finds the sum of all the elements.
S3L_OP_MIN - Finds the smallest value among all the elements.
S3L_OP_MAX - Finds the largest value among all the elements.
The C and Fortran syntax for S3L_reduce are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_reduce(A, op, res) S3L_array_t A S3L_op_type op void *res |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_reduce(A, op, res, ier) integer*8 A integer*4 op <type> res integer*4 ier |
where <type> is one of: real*4, real*8, complex*8, or complex*16.
S3L_reduce accepts the following arguments as input:
A - Array handle for the parallel array to be reduced.
op - Specifies the type of operation to be performed; it can be one of:
S3L_OP_SUM
S3L_OP_MIN
S3L_OP_MAX
S3L_reduce uses the following arguments for output:
res - Contains the result of the reduction function.
ier (Fortran only) - When called from a Fortran program, S3L_reduce returns error status in ier.
On success, S3L_reduce returns S3L_SUCCESS.
S3L_reduce performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated error code.
S3L_ERR_ARG_OP - Requested operation is not supported.
S3L_ERR_ARG_DTYPE - Invalid data type.
../examples/s3l/utils/cshift_reduce.c ../examples/s3l/utils-f/cshift_reduce.f
S3L_reduce_axis(3)
S3L_reduce_axis applies a predefined reduction operation along a given axis of a parallel S3L array. If n is the rank (number of dimensions) of a, the result b is a parallel array of rank n-1. The argument op specifies the operation to be performed. The value of op must be one of:
S3L_OP_SUM - The sum reduction operation is applied.
S3L_OP_MIN - The minimum reduction operation is applied.
S3L_OP_MAX - The maximum reduction operation is applied.
The C and Fortran syntax for S3L_reduce_axis are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_reduce_axis(a, op, axis, b) S3L_array_t a S3L_op_type op int axis S3L_array_t b |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_reduce_axis(a, op, axis, b, ier) integer*8 a integer*4 op integer*4 axis integer*8 b integer*4 ier |
S3L_reduce_axis accepts the following arguments as input:
a - S3L array handle for the parallel array on which the operation will be applied.
op - Predefined constant specifying the operation to be applied.
axis - Specifies the axis along which the reduction will be performed. When S3L_reduce_axis is called from a C program, this value must reflect zero-based indexing of the array axes. If called from a Fortran program, it must reflect one-based indexing.
S3L_reduce_axis uses the following arguments for output:
b - S3L array handle for the parallel array that will contain the result of the reduction.
ier (Fortran only) - When called from a Fortran program, S3L_reduce_axis returns error status in ier.
On success, S3L_reduce_axis returns S3L_SUCCESS.
S3L_reduce_axis performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated error code:
S3L_ERR_ARG_OP - An illegal operation was requested.
S3L_ERR_MATCH_EXTENTS - The extents of a and b do not match. For example, if a is a 4D array with extents n1 x n2 x n3 x n4, and axis is equal to 2 (Fortran interface), b must be a 3D array with extents n1 x n3 x n4.
S3L_ERR_MATCH_RANK - The rank of b is not equal to rank of a minus 1.
S3L_ERR_ARG_AXISNUM - The axis specified is not valid; that is, it is either larger than the rank of the array or smaller than 1 (Fortran interface). For the C interface, the axis value would be equal to or larger than the rank of the array or smaller than 0.
../examples/s3l/utils/cshift_reduce.c ../examples/s3l/utils-f/cshift_reduce.f
S3L_reduce(3)
The four subroutines described in this section enable the user to alter (set) and retrieve (get) individual elements of an array. Two of these subroutines also allow the user to know which process will participate in the set/get activity.
S3L_set_array_element assigns the value stored in val to a specific element of a distributed S3L array, whose global coordinates are specified by coor. The val variable is colocated with the array subgrid containing the target element.
Because an S3L array is distibuted across a set of processes, each process has a subsection of the global array local to it. These array subsections are also referred to as array subgrids.
For example, if a parallel array is distributed across four processes, P0 - P3, and coor specifies an element in the subgrid that is local to P2, the val that is located on P2 will be the source of the value used to set the target element.
S3L_get_array_element is similar to S3L_set_array_element, but operates in the opposite direction. It assigns the value stored in the element specified by coor to val on every process. Since S3L_get_array_element broadcasts the element value to every process, upon completion, every process contains the same value in val.
S3L_set_array_element_on_proc specifies which process will be the source of the value to be assigned to the target element. That is, the argument pnum specifies the MPI rank of a particular process. The value of the variable val on that process will be assigned to the target element--that is, the element whose coordinates are specified by coor.
The MPI rank of a process is defined in the global communicator MPI_COMM_WORLD.
S3L_get_array_element_on_proc updates the variable val on the process whose MPI rank is supplied in pnum, using the element whose indices are given in coor as the source for the update.
The C and Fortran syntax for S3L_set_array_element and its related routines are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_set_array_element(a, coor, val) S3L_get_array_element(a, coor, val) S3L_set_array_element_on_proc(a, coor, val, pnum) S3L_get_array_element_on_proc(a, coor, val, pnum) S3L_array_t a int coor void val int pnum |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_set_array_element(a, coor, val, ier) S3L_get_array_element(a, coor, val, ier) S3L_set_array_element_on_proc(a, coor, val, pnum, ier) S3L_set_array_element_on_proc(a, coor, val, pnum, ier) integer*8 a integer*4 coor <type> val integer*4 pnum integer*4 ier |
where <type> is one of: integer*4, real*4, real*8, complex*8, or complex*16.
S3L_set_array_element and S3L_get_array_element accept the following arguments as input:
a - Array handle describing the parallel array containing the element of interest.
coor - Integer vector specifying the coordinates of an element of the distributed array a. This value follows zero-based notation for C/C++ programs and one-based notation for F77/F90 programs.
val - Variable that holds the value to be assigned to an element of an array or that accepts the value of that element.
pnum - Integer variable specifying the MPI rank of a process to supply or accept the value val. pnum is only used with S3L_set_array_element_on_proc and S3L_get_array_element_on_proc.
These functions use the following argument for output:
ier (Fortran only) - When called from a Fortran program, these functions return error status in ier.
On success, these functions return S3L_SUCCESS.
In addition, the following conditions will cause these functions to return the associated error code and terminate.
S3L_ERR_ARG_DTYPE - The data type of array a is not one of:
S3L_integer
S3L_float
S3L_double
S3L_complex
S3L_double_complex
S3L_ERR_ARG_COOR - The supplied coordinates are not valid; that is, they do not specify an element of a.
../examples/s3l/utils/cshift_reduce.c ../examples/s3l/utils-f/cshift_reduce.f
S3L_zero_elements sets to zero all elements of the S3L array whose array handle is A.
The C and Fortran syntax for S3L_zero_elements are illustrated below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_zero_elements(A) S3L_array_t A |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_zero_elements(A, ier) integer*8 A integer*4 ier |
A - S3L internal array handle for the parallel array that is to be initialized to zero.
This function uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, this function returns error status in ier.
On success, S3L_zero_elements returns S3L_SUCCESS.
S3L_zero_elements checks the arrays it accepts as argument. If the array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following condition will cause the function to terminate and return the associated code:
S3L_ERR_ARG_DTYPE - The data type of A is invalid.
../examples/s3l/utils/zero_elements.c ../examples/s3l/utils-f/zero_elements.f
The functions described in this section allow users to retrieve information about parallel arrays for which an array handle exists.
S3L_describe prints information about a parallel array or a process grid to standard output. If an array handle is supplied in argument A, the parallel array is described. If a process grid is supplied in A, the associated process grid is described. The info_node argument specifies the MPI rank of the process on which the subgrid of interest is located.
If A is an S3L array handle, the following is provided:
Information on the rank extents and the data type of the array, as well as the starting address in memory of its subgrid.
Note: If the entire array fits on the process specified by info_node, all parts of the S3L_describe output apply to the full array. Otherwise, some parts of the output, such as subgrid size, will apply only to the portion of the array that is on process info_node.
A description of the underlying grid of processes to which data is mapped.
If A is a process grid handle, S3L_describe provides only a description of the underlying grid of processes to which data is mapped.
To determine what value to enter for info_node, run MPI_Comm_rank on the process of interest.
The C and Fortran syntax for S3L_describe are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_describe(A, info_node) S3L_array_t A int info_node |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_zero_elements(A, ier) integer*8 A integer*4 info_node integer*4 ier |
S3L_describe accepts the following arguments as input:
A - May be a parallel array handle or a process grid handle.
info_node - Scalar integer variable that specifies the index or rank of the process from which the information will be gathered. Note that certain array parameters, such as the subgrid size and addresses, will vary from process to process.
S3L_describe uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_describe returns error status in ier.
On success, S3L_describe returns S3L_SUCCESS.
S3L_describe performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following condition will cause the function to terminate and return the associated error code.
S3L_ERR_ARG_ARRAY - A is not a valid parallel array or process grid handle.
../examples/s3l/utils/scalapack_conv.c ../examples/s3l/utils-f/scalapack_conv.f
MPI_Comm_rank(3) S3L_declare(3) S3L_declare_detailed(3) S3L_set_process_grid(3)
S3L_get_attribute returns a requested attribute of an S3L dense array or sparse matrix. The user specifies one of a set of predefined req_attr values and, on return, the integer value of the requested attribute is stored in attr. For attributes associated with array axes--such as the extents or blocksizes of an array--the user specifies the axis as well.
The req_attr entry must be one of the following:
S3L_ELEM_TYPE - Retrieves in attr the S3L type of the elements of an S3L dense array or sparse matrix as they are defined in s3l-c.h or s3l-f.h.
S3L_ELEM_SIZE - Retrieves in attr the size (in bytes) of the elements of an S3L dense array or sparse matrix.
S3L_RANK - Retrieves in attr the rank (number of dimensions) of an S3L dense array or sparse matrix.
S3L_EXTENT - If a is an S3L array handle, S3L_EXTENT retrieves in attr the extent of an S3L dense array or sparse matrix along the dimension given in axis. If a is an S3L process grid handle, it returns in attr the number of processes over which a given axis of an array is distributed.
S3L_BLOCK_SIZE - Retrieves in attr the block size of the block-cyclic distribution of an S3L dense array along the dimension given in axis.
S3L_BLOCK_START - Retrieves in attr the index of the starting process of the block-cyclic distribution of an S3L dense array along the dimension given in axis.
S3L_SGRID_SIZE - Retrieves in attr the subgrid size of the block-cyclic distribution of an S3L dense array along the dimension given in axis.
S3L_AXIS_LOCAL - Assigns 0 to attr if the axis is not distributed and 1 if it is.
S3L_SGRID_ADDRESS - Returns in attr the starting address of the local subgrid (local per-process part) of an S3L dense array.
S3L_MAJOR - If a is an S3L dense array, S3L_MAJOR returns in attr the majorness of the elements in the local part of the array. It can be either S3L_MAJOR_COLUMN (F77 major) or S3L_MAJOR_ROW (C major). If a is an S3L process grid descriptor, it returns in attr the majorness (F77 or C) of the internal process grid associated with an S3L process grid.
S3L_ALLOC_TYPE - Returns in attr one of the predefined allocation types for dense S3L arrays. The user can use this option to determine, for example, whether the array has been allocated in shared memory, whether the local (per-process) parts of the array are 64-bit aligned, and so forth.
S3L_SHARED_ADDR - For dense S3L arrays that have been allocated in shared memory (single SMP case), S3L_SHARED_ADDR returns in attr the global starting address of the array. All processes can directly access all elements of such arrays without the need for explicit intperprocess communication.
S3L_PGRID_DESC - Returns in attr the process grid descriptor associated with an S3L dense array or sparse matrix.
S3L_SCALAPACK_DESC - For 1D and 2D S3L dense arrays, S3L_SCALAPACK_DESC returns in attr the ScaLAPACK array descriptor associated with the distribution of that array.
S3L_NONZEROS - For an S3L sparse matrix, S3L_NONZEROS returns in attr the number of nonzero elements of that matrix.
S3L_RIDX_SGRID_ADDR - For an S3L sparse matrix stored in the S3L_SPARSE_COO format, S3L_RIDX_SGRID_ADDR returns in attr the starting address of an array of index sets containing the local row numbers that comprise each local submatrix (per-process).
For an S3L sparse matrix stored in the S3L_SPARSE_CSR format, S3L_RIDX_SGRID_ADDR returns in attr the starting address of an array containing the pointers to the beginning of each row of the local submatrix (per-process).
Note: Users must not change the data returned in attr. It is created for internal use only.
S3L_CIDX_SGRID_ADDR - For an S3L sparse matrix, S3L_CIDX_SGRID_ADDR returns in attr the starting address of an array of index sets containing the global column numbers that comprise each local submatrix (per-process).
Note: User must not change the data returned in attr. It is created for internal use only.
S3L_NRZS_SGRID_ADDR - For an S3L sparse matrix, S3L_NZRS_SGRID_ADDR returns in attr the starting address of an array containing nonzero elements of the local submatrix (per-process).
S3L_RIDX_SGRID_SIZE - For an S3L sparse matrix stored in the S3L_SPARSE_COO format, S3L_RIDX_SGRID_SIZE returns in attr the size of an array of index sets containing the local row numbers that comprise each local submatrix (per-process).
For an S3L sparse matrix stored in the S3L_SPARSE_CSR format, S3L_RIDX_SGRID_SIZE returns in attr the size of an array containing the pointers to the beginning of each row of the local submatrix (per-process).
S3L_CIDX_SGRID_SIZE - For an S3L sparse matrix, S3L_CIDX_SGRID_SIZE returns in attr the size of an array of index sets containing the global column numbers that comprise each local submatrix (per-process).
S3L_NRZS_SGRID_SIZE - For an S3L sparse matrix, S3L_NZRS_SGRID_SIZE returns in attr the size of an array containing nonzero elements of the local submatrix (per-process).
S3L_COORD - It returns in attr the coordinate of the calling process in an S3L process grid, along the dimension given in axis.
S3L_ON_SINGLE_SMP - It returns 1 in attr if an S3L process grid is defined on a single SMP and 0 if not.
The C and Fortran syntax for S3L_get_attribute are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_S3L_get_attribute(a, req_attr, axis, attr) S3L_array_t a int req_attr int axis void *attr |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_get_attribute(a, req_attr, axis, attr, ier) integer*8 a integer*4 req_attr integer*4 axis <type> attr integer*4 ier |
where <type> is either of integer*4 type or of pointer type. When attr is an address, it should be of type pointer. In all other cases, it should be of type integer*4.
S3L_get_attribute accepts the following arguments as input:
a - Pointer to a descriptor of an unknown type.
req_attr - A predefined value that specifies the attribute to be retrieved. See the Description section for a list of valid req_attr entries.
axis - Scalar integer variable. To retrieve axis-specific attributes, such as, extents or blocksizes, use this parameter to specify the axis of interest.
attr - Pointer to a variable of the appropriate type that will hold the retrieved attribute value.
S3L_get_attribute uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_get_attribute returns error status in ier.
On success, S3L_get_attribute returns S3L_SUCCESS.
S3L_get_attribute performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following condition will cause the function to terminate and return the associated error code:
S3L_ERR_ATTR_INVALID - Invalid attribute; the supplied descriptor does not have the requested attribute type.
../examples/s3l/utils/get_attribute.c ../examples/s3l/utils-f/get_attribute.f
S3L_set_array_element(3) S3L_set_array_element_on_proc(3)
The toolkit functions described in this section allow the user to read data from a file into a parallel array, to write data from a parallel array into a local file, and to print data from a parallel array to standard output.
S3L_read_array causes the process with MPI rank 0 to read the contents of a distributed array from a local file and distribute them to the processes that own the parts (subgrids) of the array. The local file is specified by the filename argument.
S3L_read_sub_array reads a specific section of the array, within the limits specified by the lbounds and ubounds arguments. The strides argument specifies the stride along each axis; it must be greater than zero. The format argument is a string that specifies the format of the file to be read. It can be either "ascii" or "binary".
The values of lbounds and ubounds should refer to zero-based indexed arrays for the C interface and to one-based indexed arrays for the Fortran interface.
The C and Fortran syntax for S3L_read_array and S3L_read_sub_array are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_read_array(a, filename, format) S3L_read_sub_array(a, lbounds, ubounds, strides, filename, format) S3L_array_t a int *lbounds int *ubounds int *strides char *filename char *format |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_read_array(a, filename, format, ier) S3L_read_sub_array(a, lbounds, ubounds, strides, filename, format, ier) integer*8 a integer*4 lbounds(*) integer*4 ubounds(*) integer*4 strides(*) character*1 filename(*) character*1 format(*) integer*4 ier |
S3L_read_array and S3L_read_sub_array accept the following arguments as input:
a - S3L array handle for the parallel array to be read. This array handle was returned when the array was declared.
lbounds - Integer vector specifying the lower bounds of the indices of a along each of its axes.
ubounds - Integer vector specifying the upper bounds of the indices of a along each of its axes.
strides - Integer vector specifying the strides on the indices of a along each of its axes.
filename - Scalar character variable specifing the name of the file from which the parallel array will be read.
format - Scalar character variable specifing the format of the data to be read. The value can be either "ascii" or "binary".
S3L_read_array and S3L_read_sub_array use the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_read_array and S3L_read_sub_array return error status in ier.
On success, S3L_read_array and S3L_read_sub_array return S3L_SUCCESS.
S3L_read_array and S3L_read_sub_array perform generic checking of the validity of the arrays they accept as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated error code:
S3L_ERR_ARG_RANGE_INV - The given range of indices is invalid:
A lower bound is less that the the smallest index of the array.
An upper bound is greater than the largest index of an array along the given axis.
A lower bound is larger than the corresponding upper bound.
A stride is negative or zero.
S3L_ERR_FILE_OPEN - Failed to open the file with the file name provided.
S3L_ERR_EOF - Encountered EOF while reading an array from a file.
S3L_ERR_IO_FORMAT - Format is not one of "ascii" or "binary".
S3L_ERR_IO_FILENAME - The file name is equal to the NULL string (C/C++) or to an empty string (F77/F90).
../examples/s3l/io/ex_io.c ../examples/s3l/io-f/ex_io.f
S3L_print_array(3) S3L_write_array(3)
S3L_print_array causes the process with MPI rank 0 to print the parallel array represented by the array handle a to standard output.
S3L_print_sub_array prints a specific section of the parallel array. This array section is defined by the lbounds, ubounds, and strides arguments. lbounds and ubounds specify the array section's lower and upper index bounds. strides specifies the stride to be used along each axis; it must be greater than zero.
The values of lbounds and ubounds should refer to zero-based indexed arrays for the C interface and to one-based indexed arrays for the Fortran interface.
The C and Fortran syntax for S3L_print_array and S3L_print_sub_array are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_print_array(a) S3L_print_sub_array(a, lbounds, ubounds, strides) S3L_array_t a int *lbounds int *ubounds int *strides |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_print_array(a, ier) S3L_print_sub_array(a, lbounds, ubounds, strides, ier) integer*8 a integer*4 lbounds(*) integer*4 ubounds(*) integer*4 strides(*) integer*4 ier |
S3L_print_array and S3L_print_sub_array accept the following arguments as input:
a - S3L array handle for the parallel array to be printed. This array handle was returned when the array was declared.
lbounds - Integer vector specifying the lower bounds of the indices of a along each of its axes.
ubounds - Integer vector specifying the upper bounds of the indices of a along each of its axes.
strides - Integer vector specifying the strides on the indices of a along each of its axes.
S3L_print_array and S3L_print_sub_array use the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_print_array and S3L_print_sub_array return error status in ier.
On success, S3L_print_array and S3L_print_sub_array return S3L_SUCCESS.
S3L_print_array and S3L_print_sub_array perform generic checking of the validity of the arrays they accept as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following condition will cause the function to terminate and return the associated error code:
S3L_ERR_ARG_RANGE_INV - The given range of indices is invalid:
A lower bound is less that the the smallest index of the array.
An upper bound is greater than the largest index of an array along the given axis.
A lower bound is larger than the corresponding upper bound.
A stride is negative or zero.
../examples/s3l/io/ex_print1.c ../examples/s3l/io/ex_io.c ../examples/s3l/io-f/ex_io.f
S3L_read_array(3) S3L_write_array(3)
S3L_write_array causes the process with MPI rank 0 to write the parallel array represented by the array handle a into a file specified by the filename argument. The file filename resides on the process with rank 0.
S3L_write_sub_array writes a specific section of the parallel array to filename. This section is defined by the lbounds, ubounds, and strides arguments. lbounds and ubounds specify the array section's lower and upper index bounds. strides specifies the stride along each axis; it must be greater than zero.
The values of lbounds and ubounds should refer to zero-based indexed arrays for the C interface and to one-based indexed arrays for the Fortran interface.
The C and Fortran syntax for S3L_write_array and S3L_write_sub_array are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_write_array(a, filename, format) S3L_write_sub_array(a, lbounds, ubounds, strides, filename, format) S3L_array_t a int *lbounds int *ubounds int *strides char *filename char *format |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_write_array(a, filename, format, ier) S3L_write_sub_array(a, lbounds, ubounds, strides, filename, format, ier) integer*8 a integer*4 lbounds(*) integer*4 ubounds(*) integer*4 strides(*) character*1 filename(*) character*1 format(*) integer*4 ier |
S3L_write_array and S3L_write_sub_array accept the following arguments as input:
a - S3L array handle for the parallel array to be written. This array handle was returned when the array was declared.
lbounds - Integer vector specifying the lower bounds of the indices of a along each of its axes.
ubounds - Integer vector specifying the upper bounds of the indices of a along each of its axes.
strides - Integer vector specifying the strides on the indices of a along each of its axes.
filename - Scalar character variable specifying the name of the file to which the parallel array will be written.
format - Scalar character variable specifying the format of the data to be written. The value can be either "ascii" or "binary".
S3L_write_array and S3L_write_sub_array use the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_write_array and S3L_write_sub_array return error status in ier.
On success, S3L_write_array and S3L_write_sub_array return S3L_SUCCESS.
S3L_write_array and S3L_write_sub_array perform generic checking of the validity of the arrays they accept as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated error code:
S3L_ERR_ARG_RANGE_INV - The given range of indices is invalid:
A lower bound is less that the the smallest index of the array.
An upper bound is greater than the largest index of an array along the given axis.
A lower bound is larger than the corresponding upper bound.
A stride is negative or zero.
S3L_ERR_FILE_OPEN - Failed to open the file with the file name provided.
S3L_ERR_IO_FORMAT - Format is not one of "ascii" or "binary".
S3L_ERR_IO_FILENAME - The file name is equal to the NULL string (C/C++) or to an empty string (F77/F90).
../examples/s3l/io/ex_io.c ../examples/s3l/io-f/ex_io.f
S3L_print_array(3) S3L_read_array(3)
S3L_copy_array copies the contents of array A into array B, which must have the same rank, extents and data type as A.
The C and Fortran syntax for S3L_copy_array are illustrated below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_write_array(a, filename, format) S3L_array_t A S3L_array_t B char *format |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_copy_array(A, B, ier) integer*8 A integer*8 B integer*4 ier |
A - S3L_array handle for the parallel array to be copied.
This function uses the following arguments for output:
B - S3L array handle for a parallel array of the same rank, extents, and data type as A. On successful completion, B contains a copy of the contents of A.
ier (Fortran only) - When called from a Fortran program, this function returns error status in ier.
On success, S3L_copy_array returns S3L_SUCCESS.
S3L_copy_array checks the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated code:
S3L_ERR_MATCH_RANK - The ranks of A and B do not match.
S3L_ERR_MATCH_EXTENTS - The extents of A and B do not match.
S3L_ERR_MATCH_DTYPE - The data types of A and B do not match.
S3L_ERR_ARG_DTYPE - The data type of A and/or B is invalid.
../examples/s3l/utils/copy_array.c ../examples/s3l/utils-f/copy_array.f
The functions described in this section make it possible to convert ScaLAPACK descriptors to S3L array handles and vice versa.
S3L_from_ScaLAPACK_desc converts the ScaLAPACK descriptor and subgrid address specified by scdesc and address into an S3L array handle, which is returned in s3ldesc.
The C and Fortran syntax for S3L_from_ScaLAPACK_desc are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_from_ScaLAPACK_desc(s3ldesc, scdesc, data_type, address) S3L_array_t *s3ldesc int *scdesc S3L_data_type data_type void *address |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_from_ScaLAPACK_desc(s3ldesc, scdesc, data_type, address, ier) integer*8 s3ldesc integer*4 scdesc(*) integer*4 data_type pointer address integer*4 ier |
S3L_from_ScaLAPACK_desc accepts the following arguments as input:
scdesc - ScaLAPACK descriptor for a parallel array.
data_type - Specifies the data type of the S3L array. It must specify a data type supported by Sun S3L.
address - This input argument holds the starting address of an existing array subgrid.
In Fortran programs, address should either be a pointer (see the Fortran documentation for details) or the starting address of a local array, as determined by the loc(3F) function.
S3L_from_ScaLAPACK_desc uses the following arguments for output:
s3ldesc - S3L array handle that is the output of S3L_from_ScaLAPACK_desc.
ier (Fortran only) - When called from a Fortran program, S3L_from_ScaLAPACK_desc returns error status in ier.
On success, S3L_from_ScaLAPACK_desc returns S3L_SUCCESS.
S3L_from_ScaLAPACK_desc performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated error code:
S3L_ERR_ARG_NULL - The scdesc argument is a NULL pointer (C/C++) or 0 (F77/F90).
S3L_ERR_NOT_SUPPORT - The ScaLAPACK descriptor data type is not supported by Sun S3L.
S3L_ERR_PGRID_NOPROCS - The ScaLAPACK descriptor has an invalid BLACS context.
../examples/s3l/utils/scalapack_conv.c ../examples/s3l/utils-f/scalapack_conv.f
S3L_to_ScaLAPACK_desc(3)
S3L_to_ScaLAPACK_desc converts the S3L array handle specified by s3ldesc into a ScaLAPACK array descriptor and subgrid address, which are returned in scdesc and address, respectively.
The array referred to by s3ldesc must be two-dimensional; that is, it must be a rank 2 array.
The C and Fortran syntax for S3L_to_ScaLAPACK_desc are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_to_ScaLAPACK_desc(s3ldesc, scdesc, data_type, address) S3L_array_t *s3ldesc int *scdesc int data_type void **address |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_to_ScaLAPACK_desc(s3ldesc, scdesc, data_type, address, ier) integer*8 s3ldesc integer*4 scdesc(*) integer*4 data_type pointer address integer*4 ier |
S3L_to_ScaLAPACK_desc accepts the following arguments as input:
s3ldesc - Contains the S3L array handle that is provided as input to S3L_to_ScaLAPACK_desc.
S3L_to_ScaLAPACK_desc uses the following argument for output:
scdesc - Contains the ScaLAPACK descriptor output generated by S3L_to_ScaLAPACK_desc.
data_type - Contains the data type of the S3L array. It must specify a data type supported by Sun S3L.
address - This argument will hold the starting address of an existing array subgrid.
ier (Fortran only) - When called from a Fortran program, S3L_from_ScaLAPACK_desc returns error status in ier.
On success, S3L_to_ScaLAPACK_desc returns S3L_SUCCESS.
S3L_to_ScaLAPACK_desc performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated error code:
S3L_ERR_ARG_NULL - The s3ldesc argument is a NULL pointer (C/C++) or 0 (F77/F90).
S3L_ERR_ARG_RANK - The S3L array handle refers to an array with a rank not equal to 2.
S3L_ERR_PGRID_NOPROCS - The ScaLAPACK descriptor has an invalid BLACS context.
../examples/s3l/utils/scalapack_conv.c ../examples/s3l/utils-f/scalapack_conv.f
S3L_from_ScaLAPACK_desc(3)
This section describes three toolkit functions that support the following tasks:
Enabling thread-safe operation of Sun S3L routines.
Checking the current safety level.
Setting the safety level.
S3L_thread_comm_setup establishes the appropriate internal MPI communicators and data for thread-safe operation of S3L functions. It should be called from each thread in which S3L functions will be used.
Only S3L_init can be called before S3L_thread_comm_setup.
The argument comm specifies an MPI communicator, which should be congruent with, but not identical to, MPI_COMM_WORLD.
A unique communicator must be used for each thread or set of cooperating threads. The term "cooperating threads" refers to a set of threads that will be working on the same data. For example, one thread can initialize a random number generator, obtain a setup ID, and pass this to a fellow cooperating thread, which will then use the random number generator.
In such cases, the user must ensure that the threads within a cooperating set are properly synchronized.
A unique communicator is required because S3L performs internal communications. For example, when S3L_mat_mult is called from a multithreaded program, the thread on one node needs to communicate with the appropriate thread on another node. This can be done only if a communicator that is unique to these threads has been previously defined and passed to the communications routines within S3L.
S3L_thread_comm_setup need not be invoked if S3L functions are called from only one thread in the user's program.
S3L_thread_comm_setup is useful when a user performs explicit multithreading via threads library functions. Since threads library functions are not available in F77, the F77 interface for S3L_thread_comm_setup is not provided.
The C and Fortran syntax for S3L_thread_comm_setup are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_thread_comm_setup(comm) MPI_Comm comm |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_thread_comm_setup(comm, ier) integer*4 comm integer*4 ier |
S3L_thread_comm_setup accepts the following argument as input:
comm - An MPI communicator that is congruent with, but not identical to, MPI_COMM_WORLD.
S3L_thread_comm_setup uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_thread_comm_setup returns error status in ier.
On success, S3L_thread_comm_setup returns S3L_SUCCESS.
S3L_thread_comm_setup performs generic checking of the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.
In addition, the following conditions will cause the function to terminate and return the associated error code:
S3L_ERR_ARG_NULL - The comm argument is a NULL pointer (C/C++) or 0 (F77/F90)
S3L_ERR_COMM_INVAL - The comm argument is not congruent to MPI_COMM_WORLD.
S3L_ERR_THREAD_UNSAFE - The application program is using libraries that are not thread-safe.
See the following C and Fortran 77 program examples for illustrations of S3L_thread_comm_setup in use:
../examples/s3l/dense_matrix_ops/inner_prod_mt.c ../examples/s3l/dense_matrix_ops/matmult_mt.c
The following may be of related interest.
MPI_Comm_dup(3) S3L_set_safety(3) threads(3T) Also, "Multithreaded Programming" is a relevant section in the Sun MPI User's Guide
The S3L safety mechanism offers two types of services:
It performs error checking and reporting during execution of S3L routines.
It synchronizes S3L processes so that, when an error is detected, the section of code associated with the error can be more readily identified.
The S3L safety mechanism can be set to operate at ony one of four levels, which are described in Table 7-2.
Table 7-2 S3L Safety Levels
Safety Level |
Description |
---|---|
0 |
Turns the safety mechanism off. Explicit synchronization and errorchecking are not performed. This level is appropriate for productionruns of code that have already been thoroughly tested. |
2 |
Detects potential race conditions in multithreaded S3L operations on parallel arrays. To avoid race conditions, an S3L function locks all parallel array handles in its argument list before proceeding. This safety level causes warning messages to be generated if more than one S3L function attempts to use the same parallel array at the same time. |
5 |
In addition to checking for and reporting level 2 errors, performsexplicit synchronization before and after each call and locates eacherror with respect to the synchronization points. This safety level isappropriate during program development or during runs for which a small performance penalty can be tolerated. |
9 |
Checks for and reports all level 2 and level 5 errors, as well as errorsgenerated by any lower levels of code called from within S3L. Performs explicit synchronization in these lower levels of code and locates each error with respect to the synchronization points. This level is appropriate for detailed debugging following the occurrenceof a problem. |
The S3L safety mechanism can be controlled in either of two ways:
By setting the environment variable S3L_SAFETY.
By using the calls S3L_set_safety and S3L_get_safety in a program.
To set the S3L safety level using the S3L_SAFETY environment variable, issue the command:
setenv S3L_SAFETY { 0 | 2 | 5 | 9 }
The C and Fortran syntax for S3L_set_safety are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_set_safety(n) int n |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_set_safety(n, ier) integer*4 n integer*4 ier |
S3L_set_safety accepts the following argument as input:
n - An integer specifying one of four safety levels: 0, 2, 5, and 9. See the Description section for details.
S3L_set_safety uses the following argument for output:
ier (Fortran only) - When called from a Fortran program, S3L_set_safety returns error status in ier.
On success, S3L_set_safety returns S3L_SUCCESS.
On error, the following condition will cause the function to return the associated error code and terminate:
S3L_ERR_SAFELEV_INVAL - Safety level has an invalid value.
../examples/s3l/utils/copy_array.c ../examples/s3l/utils-f/copy_array.f
S3L_get_safety(3)
When S3L_get_safety is called from within an application, the value it returns indicates the current setting of the S3L safety mechanism. The possible return values are listed and their meaning explained in Table 7-2.
The C and Fortran syntax for S3L_set_safety are shown below.
#include <s3l/s3l-c.h> #include <s3l/s3l_errno-c.h> int S3L_get_safety() |
include `s3l/s3l-f.h' include `s3l/s3l_errno-f.h' subroutine S3L_get_safety(ier) integer*4 ier |
S3L_get_safety takes no input arguments.
S3L_get_safety returns the S3L safety level. When called by a Fortran program, it uses the following argument for output:
ier - When called from a Fortran program, S3L_get_safety returns error status in ier.
../examples/s3l/utils/copy_array.c ../examples/s3l/utils-f/copy_array.f
S3L_set_safety(3)