Sun S3L 3.0 Programming and Reference Guide

Description

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.


Note -

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.



Note -

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.