[Image] Cornell Theory Center ------------------------------------------------------------------------------- Tutorial on Compiling MPL Codes Runs on: SP2 parallel interactive nodes ------------------------------------------------------------------------------- Table of Contents * Purpose of this Tutorial * Prerequisites * Overview of the Parallel Environment and Parallel Operating Environment * Syntax of Compile Commands * General Approach * Step by Step Example * References ------------------------------------------------------------------------------- Purpose of this Tutorial This tutorial gives an overview of compiling MPL (IBM's Message Passing Library) programs on the SP2. It includes an example of compiling and linking a program which we provide. It does not describe the subroutines in the MPL library; for more information on MPL calls and examples of codes, see these tutorials and lab exercises: * MPL Template Codes * MPL Programming in C * MPL Programming in Fortran * MPL Message Passing in C * MPL Message Passing in Fortran * MPL Collective Communication in C * MPL Collective Communication in Fortran ------------------------------------------------------------------------------- Prerequisites You should be familiar with using either the xlf compiler (for FORTRAN), the xlc compiler (for C), or the xlC compiler (for C++). To learn about the xlf compiler and some of its options, refer to the tutorial Introduction to XL FORTRAN and/or the document Using XL FORTRAN. To learn about the xlc compiler, refer to the tutorial Introduction to XL C. ------------------------------------------------------------------------------- Overview of the Parallel Environment (PE) and Parallel Operating Environment (POE) The IBM AIX Parallel Environment (PE) is an environment designed for the development and execution of parallel FORTRAN, C, or C++ programs. It consists of libraries, tools and system support processes. The software used to compile, run, and monitor parallel programs (except the vt visualization tool) under the PE is called the Parallel Operating Environment (POE). POE's parallel compiler scripts (mpxlf, mpcc, and mpCC) are used to compile programs which include calls to IBM's MPL subroutines. POE's system processes include the resource manager (resd), which is responsible for allocating nodes to jobs, and the partition manager, which oversees parallel execution of individual jobs. PE and POE are discussed briefly in the Running MPL Interactively tutorial. POE's analysis tools (e.g, the Program Marker Array) and debuggers (pdbx, xpdbx) are discussed in separate tutorials. ------------------------------------------------------------------------------- Syntax of Compile Commands To compile a program containing MPL calls, use the appropriate POE compiler command for the language you are using (see syntax below). These commands are actually scripts which set up several UNIX environment variables and then invoke the standard xlf, cc, or CC compiler and link with the Partition Manager and message-passing (i.e., MPL) interface libraries. All flags, options, and other information which you can normally specify on compile commands are permitted and will be passed to the compiler. The commands to compile and link have the following syntax: FORTRAN: mpxlf [xlf_flags] sourcefile(s) [-ip | -us] C: mpcc [cc_flags] sourcefile(s) [-ip | -us] C++: mpCC [CC_flags] sourcefile(s) [-ip | -us] where: xlf_flags or cc_flags or CC_flags are the options available with the xlf, cc, or CC commands. -ip or -us indicate which library to statically bind to the executable. The default (i.e., neither flag specified) is to not bind a library to the executable. source_file(s) is a list of files to be compiled. Normally you will want to compile without binding either implementation of the communication subsystem (CSS) library. This has two advantages: * You decide at run time which library to use; that means you will not need to recompile if/when you decide to use a different library. * The size of your executable is significantly smaller. Since you will not normally be choosing a CSS library at compile time, we defer discussion of these libraries to the Running MPL Interactively tutorial. ------------------------------------------------------------------------------- General Approach * You should always begin with a serial version of the code (compiled with xlf, cc, or CC) which is thoroughly debugged. Keep this version available; it can be valuable for verifying that your parallel program produces correct results. * Add appropriate message-passing calls from IBM's Message Passing Library. * Compile using the mpxlf, mpcc, or mpCC command. See syntax in the preceding section. Normally you will not want to bind a communication library, so you will not specify the -ip or -us flag. Compilation can be done interactively or, for very large programs, in batch. ------------------------------------------------------------------------------- Example 1. Login to the SP2 parallel interactive site, using the node name sploginp. This will put you on one of the interactive nodes. Our example illustrates a simple parallel program coded both in FORTRAN (simple.f) and C (simple.c). Choose whichever language you prefer and copy the example source code file to your current working directory: cp /usr/local/doc/training/sp2/MPL/Compiling/simple.f . or cp /usr/local/doc/training/sp2/MPL/Compiling/simple.c . Calls to MPL subroutines have already been added to this example; see the comments in the source code for information on what the program does. 2. Compile the code. Since our code is very small, we can easily compile it interactively. Issue one of the following commands: for FORTRAN: mpxlf -o simple simple.f for C: mpcc -o simple simple.c Each of these commands will produce an executable named "simple" which is a parallel program. To learn how to execute this program under POE, see the Running MPL Interactively tutorial. 3. Remember, we have not linked in the Communication Subsystem library; this keeps the executable small and gives us the flexibility to choose the communication library at run time. But just for fun, let's re-compile and statically link in each of the libraries. First statically link with the IP library and save the executable under the name "simple-ip". for FORTRAN: mpxlf -o simple-ip simple.f -ip for C: mpcc -o simple-ip simple.c -ip Then statically link with the US library and save the executable under the name "simple-us". for FORTRAN: mpxlf -o simple-us simple.f -us for C: mpcc -o simple-us simple.c -us 4. Now compare the sizes of the three executables with the command: ls -al simple* Notice that the statically linked executables (simple-ip and simple-us) are each significantly larger in size than the executable that does not have a communication library linked (simple). 5. Cleanup: This tutorial example will leave the following files in your directory: simple.f (for the Fortran example) simple.c (for the C example) simple simple-ip simple-us ------------------------------------------------------------------------------- References IBM AIX Parallel Environment, Operation and Use, Release 2.0 (IBM order number SH26-7230-01). This manual is available online in InfoExplorer with the command: info -l pe.sp2 You can also consult the appropriate man pages; i.e., man mpxlf man mpcc man mpCC ------------------------------------------------------------------------------- Original: RLF 12/15/93 Revised: RYL 4/13/94 Revised for SP2: LB 11/22/94 Revised: RYL 3/20/95