Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
abstract:farber:runjobs:prog_env [2018-02-13 12:20] – [Application development] sraskar | abstract:farber:runjobs:prog_env [2018-05-21 22:51] (current) – removed sraskar | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | ||
- | ====== Application development ====== | ||
- | //This section uses the wiki's [[:# | ||
- | ===== Programming models ===== | ||
- | |||
- | There are two memory models for computing: distributed-memory and shared-memory. In the former, the message passing interface (%%MPI%%) is employed in programs to communicate between processors that use their own memory address space. In the latter, open multiprocessing (OMP) programming techniques are employed for multiple threads (light weight processes) to access memory in a common address space. When your job spans several compute nodes, you must use an MPI model. | ||
- | |||
- | Distributed memory systems use single-program multiple-data (SPMD) and multiple-program multiple-data (MPMD) programming paradigms. In the SPMD paradigm, each processor loads the same program image and executes and operates on data in its own address space (different data). It is the usual mechanism for MPI code: a single executable is available on each node (through a globally accessible file system such as $WORKDIR or ''/ | ||
- | |||
- | The shared-memory programming model is used on Symmetric Multi-Processor (SMP) nodes such as a single typical compute node (20 or 24 cores, 64 GB memory). The programming paradigm for this memory model is called Parallel Vector Processing (PVP) or Shared-Memory Parallel Programming (SMPP). The former name is derived from the fact that vectorizable loops are often employed as the primary structure for parallelization. The main point of SMPP computing is that all of the processors in the same node share data in a single memory subsystem. There is no need for explicit messaging between processors as with MPI coding. | ||
- | |||
- | The SMPP paradigm employs compiler directives (as pragmas in C/C++ and special comments in Fortran) or explicit threading calls (e.g. with Pthreads). The majority of science codes now use OpenMP directives that are understood by most vendor compilers, as well as the GNU compilers. | ||
- | |||
- | In cluster systems that have SMP nodes and a high-speed interconnect between them, programmers often treat all CPUs within the cluster as having their own local memory. On a node, an MPI executable is launched on each processor core and runs within a separate address space. In this way, all processor cores appear as a set of distributed memory machines, even though each node has processor cores that share a single memory subsystem. | ||
- | |||
- | Clusters with SMPs sometimes employ hybrid programming to take advantage of higher performance at the node-level for certain algorithms that use SMPP (OMP) parallel coding techniques. In hybrid programming, | ||
- | |||
- | |||
- | |||
- | ===== Compiling code ===== | ||
- | <note important> | ||
- | Fortran, C and C++ programs can only be compiled on the login node. Java and Matlab (.m) programs may only be compiled on the compute nodes. **//All resulting executables should only be run on the compute nodes.//** | ||
- | </ | ||
- | |||
- | |||
- | ===== The compiler suites ===== | ||
- | |||
- | There are four 64-bit compiler suites that IT generally installs and supports: PGI CDK (Portland Group Inc.'s Cluster Development Kit), Open64, Intel Composer XE 2011, and GNU. In addition, IT has installed OpenJDK (Open Java Development Kit), which must only be used on the compute nodes. (Type **vpkg_info openjdk** for more information on OpenJDK.) | ||
- | |||
- | The PGI compilers exploit special features of AMD processors. If you use open-source compilers, we recommend the Open64 collection. Open64 is based on the GNU compilers, but its performance is much enhanced and may be comparable to the PGI suite. However, the extent of published Open64 documentation is very small compared to that of the other compiler suites. | ||
- | |||
- | You can use a [[04_compute_environ# | ||
- | |||
- | A general command for basic source code compilation is: | ||
- | |||
- | <// | ||
- | |||
- | For each compiler suite, the table below displays the compiler name, a link to documentation describing the compiler flags, and the appropriate filename extension for the source code file. The executable will be named **a.out** unless you use the **-o** **<// | ||
- | |||
- | To view the compiler option flags, their syntax, and a terse explanation, | ||
- | |||
- | ^ PGI ^ VALET command ^ Reference manuals ^ User guides ^ | ||
- | ^ ::: | **vpkg_require pgi** | [[http:// | ||
- | | ^ Compiler | ||
- | | ::: | pgfortran | F90, F95, F2003 | .f, .for, .f90, .f95 | | ||
- | | ::: | pgf77 | F77 | .f | | ||
- | | ::: | pgCC | C++ | .C, .cc | | ||
- | | ::: | pgcc | C | .c | | ||
- | ^ Open64 ^ VALET command ^ Reference manuals ^ User guides ^ | ||
- | ^ ::: | **vpkg_require open64** | [[http:// | ||
- | | ^ Compiler | ||
- | | ::: | openf95 | F95 | .f, .f95 | | ||
- | | ::: | openf90 | F90 | .f, .f90 | | ||
- | | ::: | openCC | ||
- | | ::: | opencc | ||
- | ^ Intel ^ VALET command ^ Reference manuals ^ User guides ^ | ||
- | ^ ::: | **vpkg_require intel** | [[http:// | ||
- | | ^ Compiler | ||
- | | ::: | ifort | F77, F90, F95 | .f, .for, .f90, .f95 | | ||
- | | ::: | icpc | C++ | .C, .c, .cc, .cpp, .cxx, .c++, .i, .ii | | ||
- | | ::: | icc | C | .c | | ||
- | ^ GCC ^ VALET command ^ Reference manuals ^ User guides ^ | ||
- | ^ ::: |**vpkg_require gcc** | [[http:// | ||
- | | ^ Compiler | ||
- | | ::: | gfortran, f95 | F77, F90, F95 | .f, .f90, .f95 | | ||
- | | ::: | g++ | C++ | .C, .c, .cc, .cpp, .cxx, .c++, .i, .ii | | ||
- | | ::: | gcc | C | .c | | ||
- | |||
- | ==== Local compiler documentation ==== | ||
- | |||
- | === Intel === | ||
- | |||
- | To find all the Intel compiler documentation local on a cluster, first use VALET to load the version of the Intel compiler. | ||
- | |||
- | vpkg_require intel | ||
- | |||
- | Next load the page to begin using C or Fortran documentation by using Firefox. Remember you must be running X-Windows for Firefox to work. | ||
- | |||
- | * C | ||
- | |||
- | firefox $MKLROOT/ | ||
- | |||
- | * Fortran | ||
- | |||
- | firefox $MKLROOT/ | ||
- | |||
- | ==== Compiling serial programs ==== | ||
- | |||
- | This section uses the PGI compiler suite to illustrate simple Fortran and C compiler commands that create an executable. For each compiler suite, you must first set the UNIX environment so the compilers and libraries are available to you. [[04_compute_environ# | ||
- | |||
- | The examples below show the compile and link steps in a single command. These illustrations use source code files named fdriver.f90 (Fortran 90) or cdriver.c (C). They all use the **-o** option to produce an executable named ' | ||
- | |||
- | You can use the **-c** option instead to create a **.o** object file that you would later link to other object files to create the executable. | ||
- | |||
- | Some people use the UNIX **make** command to compile source code. There are many good online tutorials on the [[http:// | ||
- | |||
- | == Using the PGI suite to illustrate: == | ||
- | |||
- | First use a VALET command to set the environment: | ||
- | |||
- | | ||
- | |||
- | Then use that compiler suite' | ||
- | |||
- | == Fortran 90 example: == | ||
- | |||
- | | ||
- | |||
- | == C example: == | ||
- | |||
- | pgcc -fpic cdriver.c -o driver | ||
- | |||
- | ==== Compiling parallel programs that use OpenMP ==== | ||
- | |||
- | If your program only uses OpenMP directives, has __no__ message passing, and your target is a single SMP node, you should add the [[http:// | ||
- | |||
- | ^ Compiler suite ^ OpenMP compiler flag ^ | ||
- | | **PGI** | -mp | | ||
- | | **Open64** | -mp | | ||
- | | **Intel** | -openmp | | ||
- | | **Intel-2016** | -qopenmp | | ||
- | | **GCC** | -fopenmp | | ||
- | |||
- | \\ Instead of using OpenMP directives in your program, you can add an OpenMP-based library. You will still need the OpenMP compiler flag when you use the library. | ||
- | |||
- | ==== Compiling parallel programs that use MPI ==== | ||
- | |||
- | === MPI implementations === | ||
- | |||
- | In the distributed-memory model, the [[file:// | ||
- | |||
- | **OpenMPI is the most desirable MPI implementation to use**.** **It is the only one that works for job suspension, checkpointing, | ||
- | |||
- | Some software comes packaged with other MPI implementations that IT cannot change. In those cases, their VALET configuration files use the bundled MPI implementation. However, we recommend that you use OpenMPI whenever you need an MPI implementation. | ||
- | |||
- | === MPI compiler wrappers === | ||
- | |||
- | The [[http:// | ||
- | |||
- | The compiler suite that's used depends on your UNIX environment settings. Use VALET commands to simultaneously set your environment to use the OpenMPI implementation and to select a particular compiler suite. The commands for the four compiler suites are: | ||
- | |||
- | vpkg_require openmpi/ | ||
- | vpkg_require openmpi/ | ||
- | vpkg_require openmpi/ | ||
- | vpkg_require openmpi/ | ||
- | |||
- | (Type// // | ||
- | |||
- | The **vpkg_require** command selects the MPI and compiler suite combination, | ||
- | |||
- | == Fortran example: == | ||
- | |||
- | <code bash> | ||
- | vpkg_reguire openmpi/ | ||
- | mpif90 -fpic fdriver.f90 -o driver | ||
- | </ | ||
- | |||
- | == C example: == | ||
- | <code bash> | ||
- | vpkg_reguire openmpi/ | ||
- | mpicc -fpic cdriver.c -o driver | ||
- | </ | ||
- | |||
- | === === | ||
- | |||
- | You may use other compiler flags listed in each [[# | ||
- | |||
- | To modify the options used by the MPI wrapper commands, consult the [[http:// | ||
- | |||
- | ===== Programming libraries ===== | ||
- | |||
- | ==== Introduction ==== | ||
- | |||
- | IT installs high-quality math and utility libraries that are used by many applications. These libraries provide highly optimized math packages and functions. To determine which compilers IT used to prepare a library version, use the **vpkg_versions** VALET command. | ||
- | |||
- | Here is a representative sample of installed libraries. Use the **vpkg_list**** **command to see the most current list of libraries.**** | ||
- | |||
- | == Open-source libraries == | ||
- | |||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | |||
- | == Commercial libraries == | ||
- | |||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | |||
- | The libraries will be optimized a given cluster architecture. Note that the calling sequences of some of the commercial library routines differ from their open-source counterparts. | ||
- | |||
- | ==== Using libraries ==== | ||
- | |||
- | === Introduction === | ||
- | |||
- | This section shows you how to link your program with libraries you or your colleagues have created or with centrally installed libraries such as ACML or FFTW. The examples introduce special environment variables (FFLAGS, CFLAGS, CPPFLAGS and LDFLAGS) whose use simplifies a command' | ||
- | |||
- | Joint use of VALET and these environment variables will also prepare your UNIX environment to support your use of **make** for program development. VALET will accommodate using one or several libraries, and you can extend its functionality for software you develop or install. | ||
- | |||
- | === Fortran examples illustrated with the PGI compiler suite === | ||
- | |||
- | == Reviewing the basic compilation command == | ||
- | |||
- | The general command for compiling source code: | ||
- | |||
- | <<// | ||
- | |||
- | For example: | ||
- | |||
- | <code bash> | ||
- | vpkg_require pgi | ||
- | pgfortran -fpic fdriver.f90 -o driver | ||
- | </ | ||
- | |||
- | == Using user-supplied libraries == | ||
- | |||
- | To compile fdriver.f90 and link it to a shared F90 library named lib**// | ||
- | |||
- | <code bash> | ||
- | pgfortran -fast -fpic -L$HOME/lib fdriver.f90 -lfstat -o driver | ||
- | </ | ||
- | |||
- | The **-L** option flag is for the shared library directory' | ||
- | |||
- | You can simplify this compiler command by creating and exporting two special environment variables. FFLAGS represents a set of Fortran compiler option flags; LDFLAGS represents the location and choice of your library. | ||
- | |||
- | <code bash> | ||
- | vpkg_require pgi | ||
- | export FFLAGS=' | ||
- | export LDFLAGS=' | ||
- | export LDLIBS=' | ||
- | pgfortran $FFLAGS $LDFLAGS fdriver.f90 $LDLIBS -o driver | ||
- | </ | ||
- | |||
- | Extending this further, you might have several libraries in one or more locations. In that case, list all of the ' | ||
- | |||
- | <code bash> | ||
- | export LDLIBS=' | ||
- | </ | ||
- | |||
- | and all of the ' | ||
- | |||
- | == Using centrally supplied libraries (ACML, MKL, FFTW, etc.) == | ||
- | |||
- | This extends the previous section' | ||
- | |||
- | To view your choices, use VALET' | ||
- | |||
- | <code bash> | ||
- | vpkg_versions acml | ||
- | </ | ||
- | |||
- | The example below uses the acml/ | ||
- | |||
- | <code bash> | ||
- | vpkg_devrequire acml/ | ||
- | </ | ||
- | |||
- | jointly sets the UNIX environment for both ACML and the PGI compiler suite. Therefore, you __should not also issue__ a **vpkg_require pgi** command. | ||
- | |||
- | Unlike **vpkg_require**, | ||
- | |||
- | Putting it all together, the complete example using the library named **acml** is: | ||
- | |||
- | <code bash> | ||
- | vpkg_devrequire acml/ | ||
- | export FFLAGS=' | ||
- | export LDLIBS=' | ||
- | pgfortran $FFLAGS $LDFLAGS fdriver.f90 $LDLIBS -o driver | ||
- | </ | ||
- | |||
- | Note that **$LDFLAGS** must be in the compile statement but does not need an explicit **export** command here. The **vpkg_devrequire** command above defined and exported LDFLAGS and its value. | ||
- | |||
- | == Using user-supplied libraries and centrally supplied libraries together == | ||
- | |||
- | This final example illustrates how to use your **fstat** and **fpoly** libraries (both in $HOME/lib) with the acml5.0.0 library: | ||
- | |||
- | <code bash> | ||
- | vpkg_devrequire acml/ | ||
- | export FFLAGS=' | ||
- | export LDFLAGS=' | ||
- | export LDLIBS=' | ||
- | pgfortran $FFLAGS $LDFLAGS fdriver.f90 $LDLIBS -o driver | ||
- | </ | ||
- | |||
- | Remember that the library search order depends on the order of the LDFLAGS libraries. | ||
- | |||
- | === C examples illustrated with the PGI compiler suite === | ||
- | |||
- | == Reviewing the basic compilation command == | ||
- | |||
- | The general command for compiling source code: | ||
- | |||
- | <<// | ||
- | |||
- | For example, | ||
- | |||
- | <code bash> | ||
- | vpkg_require pgi | ||
- | pgcc -fpic cdriver.c -o driver | ||
- | </ | ||
- | |||
- | == Using user-supplied libraries == | ||
- | |||
- | To compile cdriver.c and link it to a shared C library named lib**// | ||
- | |||
- | <code bash> | ||
- | pgcc -fpic –I$HOME/ | ||
- | </ | ||
- | |||
- | The **-I** option flag is for the include library' | ||
- | |||
- | You can simplify this compiler command by creating and exporting two special environment variables. CFLAGS represents a set of C compiler option flags; CPPFLAGS represents the C++ preprocessor flags; and LDFLAGS represents the location and choice of your shared library. | ||
- | |||
- | <code bash> | ||
- | pkg_require pgi | ||
- | export CFLAGS=' | ||
- | export CPPFLAGS=' | ||
- | export LDFLAGS=' | ||
- | export LDLIBS=' | ||
- | pgcc $CFLAGS $CPPFLAGS $LDFLAGS cdriver.c $LDLIBS -o driver | ||
- | </ | ||
- | |||
- | Extending this further, you might have several libraries in one or more locations. In that case, list all of the ' | ||
- | |||
- | <code bash> | ||
- | export LDLIBS=' | ||
- | </ | ||
- | |||
- | and all of the ' | ||
- | |||
- | == Using centrally supplied libraries (ACML, MKL, FFTW, etc.) == | ||
- | |||
- | This extends the previous section' | ||
- | |||
- | To view your choices, use VALET' | ||
- | |||
- | <code bash> | ||
- | vpkg_versions acml | ||
- | </ | ||
- | |||
- | The example below uses the acml/ | ||
- | |||
- | <code bash> | ||
- | vpkg_devrequire acml/ | ||
- | </ | ||
- | |||
- | jointly sets the UNIX environment for both ACML and the PGI compiler suite. Therefore, you __should not also issue__ a **vpkg_require pgi** command. | ||
- | |||
- | Unlike **vpkg_require**, | ||
- | |||
- | Putting it all together, the complete example using the library named **acml**, is: | ||
- | |||
- | <code bash> | ||
- | vpkg_devrequire acml/ | ||
- | export CFLAGS=' | ||
- | export LDLIBS=' | ||
- | pgcc $CFLAGS $CPPFLAGS $LDFLAGS cdriver.c $LDLIBS -o driver | ||
- | </ | ||
- | |||
- | Note that, $CPPFLAGS and $LDFLAGS must be in the compile statement even though the **export CPPFLAGS** and **export LDFLAGS** statement didn't appear above. The **vpkg_devrequire** command above defined and exported CPPFLAGS and LDFLAGS and their values. | ||
- | |||
- | == Using user-supplied libraries and centrally supplied libraries together == | ||
- | |||
- | The final example illustrates how to use your **cstat **and **cpoly** libraries (both in $HOME/lib) with the **acml** library: | ||
- | |||
- | <code bash> | ||
- | vpkg_devrequire acml/ | ||
- | export CFLAGS=' | ||
- | export CPPFLAGS=' | ||
- | export LDFLAGS=' | ||
- | export LDLIBS=' | ||
- | pgcc $CFLAGS $CPPFLAGS $LDFLAGS cdriver.c $LDLIBS -o driver | ||
- | </ | ||
- | |||
- | Remember that the library search order depends on the order of the LDFLAGS libraries. | ||
- | |||
- | |||
- | ====== Next section ====== | ||
- | [[06_runtime_environ|Running applications]] |