Compiling and Linking Overview on Polaris
Compiling on Polaris Login and Compute Nodes
If your build system does not require GPUs for the build process, as is usually the case, compilation of GPU-accelerated codes is generally expected to work well on the Polaris login nodes. If your build system does require GPUs, you cannot yet compile on the Polaris login nodes, as they do not currently have GPUs installed. You may in this case compile your applications on the Polaris compute nodes. Do this by submitting an interactive single-node job, or running your build system in a batch job.
Home File System
Is it helpful to realize that there is a single HOME
filesystem for users that can be accessed from the login and computes of each production resource at ALCF. Thus, users should be mindful of modifications to their environments (e.g. .bashrc
) that may cause issues to arise due to differences between the systems.
Cray Programming Environment
The Cray Programming Environment (PE) uses three compiler wrappers for building software. These compiler wrappers should be used when building MPI-enabled applications.
cc
- C compilerCC
- C++ compilerftn
- Fortran compiler
Each of these wrappers can select a specific vendor compiler based on the PrgEnv module loaded in the environment. The following are some helpful options to understand what the compiler wrapper is invoking.
--craype-verbose
: Print the command which is forwarded to the compiler invocation--cray-print-opts=libs
: Print library information--cray-print-opts=cflags
: Print include information
The output from these commands may be useful in build scripts where a compiler other than that invoked by a compiler wrapper is desired. Defining some variables as such may prove useful in those situations.
Further documentation and options are available viaman cc
and similar.
Compilers provided by Cray Programming Environments
The default programming environment on Polaris is currently NVHPC
. The GNU
compilers are available via another programming environment. The following sequence of module
commands can be used to switch to the GNU
programming environment (gcc, g++, gfortran) and also have NVIDIA
compilers available in your path.
The compilers invoked by the Cray MPI wrappers are listed for each programming environment in the following table.
module | C | C++ | Fortran |
---|---|---|---|
MPI Compiler Wrapper | cc | CC | ftn |
PrgEnv-nvhpc | nvc | nvc++ | nvfortran |
PrgEnv-gnu | gcc | g++ | gfortran |
Note, while gcc and g++ may be available in the default environment, the PrgEnv-gnu
module is needed to provide gfortran.
Additional Compilers Provided by ALCF
The ALCF additionally provides compilers to enable the OpenMP and SYCL programming models for GPUs viaLLVM
as documented here
Additional documentation for using compilers is available on the respective programming model pages: OpenMP and SYCL.
Linking
Dynamic linking of libraries is currently the default on Polaris. The Cray MPI wrappers will handle this automatically.
Notes on Default Modules
-
craype-accel-nvidia80
: This module adds compiler flags to enable GPU acceleration forNVHPC
compilers along with gpu-enabled MPI libraries as it is assumed that the majority of applications to be compiled on Polaris will target the GPUs for acceleration. Users building cpu-only applications may find it useful to unload this module to silence "gpu code generation" warnings. -
xalt
: This module enables library tracking; it helps ALCF identify software important to our users. More information can be found on the XALT page.
Mixed C/C++ & Fortran Applications
For applications consisting of a mix of C/C++ and Fortran that also uses MPI, it is suggested that the programming environment chosen for Fortran be used to build the full application because of mpi.mod (and similar) incompatibilities.
Compiling for GPUs
It is assumed the majority of applications to be built on Polaris will make use of the GPUs. As such, the craype-accel-nvidia80
module is in the default environment. This has the effect of the Cray compiler wrappers adding -gpu
to the compiler invocation along with additional include paths and libraries. Additional compilers flags may be needed depending on the compiler and GPU programming model used (e.g. -cuda
, -acc
, or -mp=gpu
).
This module also adds GPU Transport Layer (GTL) libraries to the link-line to support GPU-aware MPI applications.
Man Pages
For additional information on the Cray wrappers, please refer to the man pages.