C H A P T E R 3 |
Getting Started |
This chapter explains how to develop, compile and link, execute, and debug a Sun MPI program. The chapter focuses on what is specific to the Sun MPI implementation and does not repeat information that can be found in related documents. Information about programming with the Sun MPI I/O routines is in Chapter 4.
Include syntax must be placed at the top of any program that calls Sun MPI routines.
These lines enable the program to access the Sun MPI version of the mpi header file, which contains the definitions, macros, and function prototypes required when compiling the program. Ensure that you are referencing the Sun MPI include file.
The include files are usually found in /opt/SUNWhpc/include/ or /opt/SUNWhpc/include/v9/for SPARC-based systems. For x64-based systems, the files reside in /opt/SUNWhpc/include/amd64.If the compiler cannot find them, verify that they exist and are accessible from the machine on which you are compiling your code. The location of the include file is specified by the -l compiler option (see Compiling and Linking).
Three simple Sun MPI programs are available in /opt/SUNWhpc/examples/mpi and are included here in their entirety. In the same directory you will find the Readme file, which provides instructions for using the examples, and the make file Makefile.
Sun MPI programs are compiled with ordinary C, C++, or Fortran compilers, just like any other C, C++, or Fortran program, and linked with the Sun MPI library.
The mpf77, mpf90, mpcc, and mpCC utilities can be used to compile Fortran 77, Fortran 90, C, and C++ programs, respectively. For example, you might use the following entry to compile a Fortran 77 program that uses Sun MPI:
See the man pages for more information on these utilities.
For performance, the single most important compilation switch is -fast. This is a macro that expands to settings appropriate for high performance for a general set of circumstances. Because its expansion varies from one compiler release to another, you might prefer to specify the underlying switches. To see what -fast expands to, use -v for "verbose" compilation output in Fortran, and -# for C. Also, -fast assumes native compilation, so you should compile on UltraSPARC processors.
The next important compilation switch is -xarch. The Sun Studio Compiler Collection compilers set -xarch by default when you select -fast for native compilations. If you plan to compile on one type of processor and run the program on another type (non-native compilation), be sure to use the -xarch flag. You should also use it to compile in 64-bit mode. To compile in 64-bit mode on UltraSPARC processors, specify -xarch=v9. For AMD Opteron x64 processors, specify -xarch=amd64.
For more information, see the Sun HPC ClusterTools Software Performance Guide and the documents that came with your compiler.
The Sun Studio Compiler Collection software releases 8, 9, 10, and 11 are supported for the Sun HPC ClusterTools 6 suite.
Sun MPI programs compiled using the Sun Studio Compiler Collection Fortran compiler should be compiled with -xalias=actual. The
-xalias=actual workaround requires patch 111718-01 (which requires 111714-01).
This recommendation arises because the MPI Fortran binding is inconsistent with the Fortran 90 standard in several respects. Specifically, this is documented in the MPI 2 standard, which you can find on the World Wide Web:
http://www-unix.mcs.anl.gov/mpi/mpi-standard/mpi-report-2.0/node19.htm#Node19
This recommendation applies to the use of high levels of compiler optimization. A highly optimizing Fortran compiler could break MPI codes that use nonblocking operations.
The failure modes are varied and insidious and include the following:
Note - If your program has previously been linked to any static libraries, you must relink it to libmpi.so before executing it. |
The paths for the MPI libraries, which you must specify when you are compiling and linking your program, are listed in TABLE 3-2.
sparcv9/SCx.0/libmpi++.so (SPARC)
|
||
Note that x.0 denotes the version of your compiler.
The libthread.so libraries are automatically linked into the respective libmpi.so libraries. This means that any thread-function calls in your program can be resolved by the libthread.so library. Simply omitting libthread.so from the link line does not cause thread calls to be stubbed out; you must remove the thread calls yourself. For more information about the libthread.so library, see its man page. (For the location of Solaris man pages at your site, see your system administrator.)
If you plan to extract MPI profiling information from the execution of a job, you need to set the MPI_PROFILE environment variable to 1 before you start the job execution.
If you want to set any other mpprof environment variables, you must set them also before starting the job. See Appendix B for detailed descriptions of the mpprof environment variables.
The CRE environment provides close integration with batch-processing systems, also known as resource managers. You can launch parallel jobs from a batch system to control resource allocation, and continue to use the CRE environment to monitor job status. For a list of currently supported resource managers, see TABLE 3-3.
To enable the integration between the CRE environment and the supported resource managers, you must call mprun from a script in the resource manager. Use the -x flag to specify the resource manager, and the -np and -nr flags to specify the resources you need. Instructions and examples for each resource manager are provided in the Sun HPC ClusterTools Software User's Guide.
Before starting your job, you might want to set one or more environment variables, which are also described in Appendix B and in the Sun HPC ClusterTools Software Performance Guide.
When using CRE software, parallel jobs are launched using the mprun command. For example, to start a job with six processes named mpijob, use this command:
Parallel jobs can be either launched by the LSF Parallel Application Manager (PAM) or submitted in queues configured to run PAM as the parallel job starter. LSF's bsub command launches both parallel interactive and batch jobs. For example, to start a batch job named mpijob on four CPUs, use this command:
To launch an interactive job, add the -I argument to the command line. For example, to launch an interactive job named earth on a single CPU in the queue named sun, which is configured to launch jobs with PAM, use this command:
Debugging parallel programs is notoriously difficult, because you are in effect debugging a program potentially made up of many distinct programs executing simultaneously. Even if the application is an SPMD (single-program, multiple-data) application, each instance can be executing a different line of code at any instant.
The DTrace utility comes as part of the Solaris 10 OS. DTrace is a comprehensive dynamic tracing utility that you can use to monitor the behavior of applications programs as well as the operating system itself. You can use DTrace on live production systems to understand those systems' behavior and to track down any problems that might be occurring.
For more information about the D language and DTrace, refer to the Solaris Dynamic Tracing Guide (Part Number 817-6223). This guide is part of the Solaris 10 OS Software Developer Collection.
Solaris 10 OS documentation can be found on the web at the following location:
http://www.sun.com/documentation
Follow these links to the Solaris Dynamic Tracing Guide:
Solaris Operating Systems -> Solaris 10 -> Solaris 10 Software Developer Collection
TotalView is a third-party multiprocess debugger from Etnus that runs on many platforms. Support for using the TotalView debugger on Sun MPI applications includes:
The following sections provide a brief description of how to use the TotalView debugger with Sun MPI applications, including:
Refer to your TotalView documentation for more information about using TotalView.
For more information, refer to the following related documentation:
Note - The example program connectivity used in this section and other sample programs can be found in /opt/SUNWhpc/examples/mpi. |
You can start a new job from the Total View Graphical User Interface (GUI) using:
2. When the GUI appears, type g for go, or click Go in the TotalView window.
TotalView may display a dialog box:
3. Click Yes to open the TotalView debugger window with the Sun MPI source window, if compiled with option -g, and to leave all processes in a traced state.
2. Select the menu option File and then New Program.
3. Type mprun as the executable name in the dialog box.
TotalView displays the main debug window.
5. Select the menu option Process and then Startup Parameters, which are the mprun args.
2. When the job starts, type dgo.
TotalView displays this message:
3. Type y to start the MPI job, attach TotalView, and leave all processes in a traced state.
This section describes how to attach to an already running mprun job from both the TotalView GUI and CLI.
1. Find the host name and process identifier (PID) of the mprun job by typing:
mprun displays the PID and host name in a similar manner to this example:
For more information, refer to the mpps(1M) man page, option -b.
2. In the TotalView GUI, select File and then New Program.
3. Type the PID in Process ID.
4. Type mprun in the field Executable Name.
1. Find the process identifier (PID) of the launched job.
See the example under the preceding GUI procedure. For more information, refer to the mpps(1M) man page, option -b.
2. Start totalviewcli by typing:
3. Attach the executable program to the mprun PID:
This section describes how to launch Sun MPI batch jobs, including:
This section provides examples of launching batch jobs in Sun Grid Engine (SGE). Refer to Chapter 5 of the Sun HPC ClusterTools Software User's Guide for descriptions of launching batch jobs in the Load Sharing Facility (LSF) and the Portable Batch System (PBS).
Executing startup in batch mode for the TotalView CLI is not practical, because there is no controlling terminal for input and output. This procedure describes executing startup in batch mode for the TotalView GUI:
1. Write a batch script, which contains a line similar to the following:
2. Then submit the script to SGE for execution with a command similar to the following:
The TotalView GUI appears upon successful allocation of resources and execution of the batch script in SGE.
The interactive mode creates an xterm window for your use, so you can use either the TotalView GUI or the CLI.
1. Run the following, or an equivalent path, to source the SGE environment:
The system displays an xterm window.
2. Submit an interactive mode job to SGE with a command similar to the following:
3. Execute a typical totalview or totalviewcli command.
The multiprocessing environment (MPE) available from Argonne National Laboratory includes a debugger that can also be used for debugging at the thread level. For information about obtaining and building MPE, see MPE: Extensions to the Library.
Copyright © 2006, Sun Microsystems, Inc. All Rights Reserved.