C H A P T E R 5 |
Using Sun S3L |
This chapter explains how to incorporate calls to Sun S3L routines into your message-passing program. It covers t he following topics:
Note - Sun S3L documentation includes sample online programs that demonstrate how to call each Sun S3L routine. You are encouraged to experiment with these sample programs. See Accessing Online Program Examples and Man Pages. |
The basic steps required for incorporating Sun S3L function calls into an MPI program are relatively simple and can be summarized as shown in TABLE 5-1.
CODE EXAMPLE 5-1 illustrates these steps with a simple program example. They are also discussed more fully in the following subsections.
Place the appropriate include lines at the top of any program unit that makes a Sun S3L call. The correct include files are as follows for both C and Fortran language interfaces:
The first line allows the program to access the header file containing prototypes of the routines and defines the symbols and data types required by the interface. The second line includes the header file containing error codes the routines might return.
If the compiler cannot find the Sun S3L include file, verify that a path to the directory does exist. The default path is
/opt/SUNWhpc/include/ |
Before a message-passing program can start using Sun S3L functions, every MPI process in the program must call S3L_init. This will create a Sun S3L environment to handle calls from MPI processes. S3L_init also initializes the BLACS environment.
See Chapter 6 for detailed instructions on using S3L_init.
If your MPI program is multithreaded, you can use S3L_thread_comm_setup to create a safe environment for individual threads and sets of cooperating threads to call Sun S3L functions. S3L_thread_comm_setup creates the internal MPI communicators and data structures needed for thread-safe operation of Sun S3L routines.
Note - If S3L_thread_comm_setup is used, it must be the first Sun S3L function called after S3L_init. |
See Setting Up Support for Thread-Safe Operation for additional information.
Sun S3L provides a user-controlled mechanism for increasing the level of error checking performed during Sun S3L operations. This safety mechanism provides, in addition to the default level, three incrementally higher levels of error checking of Sun S3L functions.
When either of the two highest error checking modes is specified, the safety mechanism also causes the MPI processes to be synchronized. This synchronization can simplify the task of isolating errors to particular processes.
The safety mechanism can be controlled either by setting the environment variable S3L_SAFETY or with a call to the S3L_set_safety function.
The safety mechanism also provides the inquiry function S3L_get_safety, which returns the current safety level.
See Controlling the Sun S3L Safety Mechanism for more information.
S3L_declare and S3L_declare_detailed each creates a Sun S3L array handle that describes a dense Sun S3L parallel array. Both support calling arguments that enable the user to specify:
S3L_declare_detailed provides additional arguments, which may be used to control:
See Creating and Destroying Array Handles for Dense Sun S3L Arrays for detailed instructions on using S3L_declare and S3L_declare_detailed.
If the simpler S3L_declare routine is used, Sun S3L will automatically assign a process grid to the Sun S3L array. The size of the process grid will be based on values supplied by the S3L_declare arguments, with the goal of distributing the array as evenly as possible across the processes.
If S3L_declare_detailed is used instead, the programmer will have the choice of either using the default process grid assigned by Sun S3L or of specifying a custom process grid through a call to S3L_set_process_grid. This topic is discussed more fully in MPI Processes and Sun S3L Process Grids and in Creating a Custom Process Grid.
Sun S3L provides the following functions for creating Sun S3L array handles for sparse arrays:
An overview of each is provided below. All are described more fully in Chapter 12.
Note - S3L_convert_sparse, which is used to convert an array from one sparse format to another, also creates a Sun S3L array handle. But, it does so for the converted array, not for a newly created array. Since this discussion is about creating array handles for new sparse arrays, S3L_convert_sparse is not covered here. It is discussed in Converting a Sparse Matrix From One Format to Another. |
S3L_declare_sparse is similar in purpose to S3L_declare, except that it applies to sparse matrices in one of the following sparse formats:
See Supported Sparse Formats for detailed descriptions of these sparse formats.
Before calling S3L_declare_sparse, you must create three 1D arrays using S3L_declare or S3L_declare_detailed. Two of these arrays, designated row and col, hold mapping information (pointer and index values) that specify where the nonzero values are located in the sparse matrix. The third array, designated val, contains all the nonzero elements belonging to the sparse matrix.
See Declaring a Sparse Matrix for more detailed descriptions of row, col, and val.
When calling S3L_declare_sparse, the following information is passed to the function through the argument string:
See Declaring a Sparse Matrix for detailed descriptions of the arguments taken by S3L_declare_sparse.
Upon completion, S3L_declare_sparse returns a Sun S3L array handle that describes the sparse array.
S3L_read_sparse reads sparse matrix data from an ASCII file and distributes the data to all participating processes. The data read from the file includes the nonzero values of the sparse matrix, as well as mapping information that specifies the row and column layout of the nonzero values in the sparse matrix.
The data must be stored in one of the following sparse formats:
When calling S3L_read_sparse, the following information is passed to the function:
Upon completion, S3L_read_sparse returns a Sun S3L array handle that represents the newly created sparse array.
See Initializing a Sparse Matrix From a File for detailed descriptions of the arguments taken by S3L_read_sparse.
S3L_rand_sparse enables you to create a sparse matrix without either supplying the nonzero data content or specifying the exact locations of the nonzero elements. It creates a global general sparse matrix, populating it with a set of random values. The sparse format can be any one of:
When calling S3L_rand_sparse, the following information is passed to the function:
Upon completion, S3L_rand_sparse returns a Sun S3L array handle that represents the newly created sparse array. See Initializing a Sparse Matrix With Random Values for detailed descriptions of the arguments taken by S3L_rand_sparse.
Sun S3L provides separate functions for deallocating Sun S3L array handles for dense and sparse arrays. This is necessary because sparse arrays involve more complex internal data structures, which require more steps to be deallocated.
Use S3L_free to deallocate a dense Sun S3L array.
Use S3L_free_sparse to deallocate a sparse Sun S3L array.
In either case, the only argument is the Sun S3L array handle that describes the array.
To link in Sun S3L at compile time, include the switch -ls3l. This automatically links in the Forte Developer 6 library as well.
Sun S3L requires the presence of the Sun Performance Library routines and its associated license file. This library is not installed with the Sun HPC ClusterTools components. Instead, it is included as part of the Forte Developer 6 compiler suite.
The following examples show the -ls3l in use with the various supported compilers:
Note - The -dalign option is needed because libs3l and libsunperf libraries are compiled with it. |
The online sample programs are located in subdirectories of the Sun S3L examples directory. Separate C and Fortran versions are provided. The generic path for these examples is:
/opt/SUNWhpc/examples/s3l/op_class[-lang_suffix]/ex_name.lang |
This shows the default location of the examples directory. If it is not in /opt/SUNWhpc/, ask your system administrator for the correct path.
op_class refers to the general class of operations to which the routines of interest belong.
Note - The -lang_suffix part of the name is used for Fortran implementations only. The op_class directory name does not include -lang_suffix for examples implemented in C. |
ex_name.lang is the example's file name. The lang extension is .c, or .f. For example, the following is the Fortran version of a program example that illustrates use of
s3l_outer_prod routines:
/opt/SUNWhpc/examples/s3l/dense_matrix_ops-f/outer_prod.f |
The following shows the equivalent example for the C interface:
/opt/SUNWhpc/examples/s3l/dense_matrix_ops/outer_prod.c |
Each example subdirectory has a makefile. Each makefile references the file
/opt/SUNWhpc/Make.simple. If you are copying the example sources and makefiles to one of your own subdirectories, you should also copy Make.simple to your subdirectory's parent directory.
Make.simple contains definitions of compilers, compiler flags, and other variables that are needed to compile and run the examples. Note that the compiler flags in this file will not provide highly optimized executables. Information on optimization flags is best obtained from the documentation for the compiler being used.
Each makefile has several targets that are meant to simplify the compilation and execution of examples. If you want to compile the source codes and create all executables in a particular example directory, use the command, make.
If you wish to run the executables, enter make run. This command will also perform any necessary compilation and linking steps, so you need not issue make before entering make run.
By default, your executables will be run on two processes. You can change this by specifying the NPROCS variable on the command line. For example, the following will start execution on four processes:
% make run NPROCS=4
Executables and object files can be deleted by make clean.
To read the online man page for a Sun S3L routine, enter the following:
% man routine_name
Copyright © 2003, Sun Microsystems, Inc. All rights reserved.