This page will give you an overview of the Cray programming environment. It starts with a presentation of the programming environments and compiler wrappers that you can use to compile your C, C++ or Fortran code. Finally, some basic information on how to compile an MPI or OpenMP programs are given.
On LUMI, the different compiler suites are accessible using module collections. These collections load the appropriates modules to use one of the supported programming environments for LUMI.
Switching compiler suites
The compiler collections are accessible through modules and in
module load command:
$ module load PrgEnv-<name>
<name> is the name of the compiler suite. There are 3 collections
available on LUMI. The default collection is Cray.
|CCE||Cray Compiling Environment||
|GCC||GNU Compiler Collection||
|AOCC||AMD Optimizing C/C++ Compiler||
For example, if you want to use the GNU’s compiler collection:
$ module load PrgEnv-gnu
After you have loaded a programming environment, the compiler wrappers (
ftn) are available.
Changing compiler versions
If the default compiler version does not suit you, you can change the version
after having a loaded a programming environment. This operation is performed using
module swap command.
$ module swap <compiler> <compiler>/<version>
<compiler> is the name of the compiler module for the loaded programming
<compiler> the version you want to use. For example
$ module swap cce cce/11.0.2
$ module swap gcc gcc/10.2.0
The module collection provides wrappers to the C, C++ and Fortran compilers. The command used to invoke these wrappers are listed below.
cc: C compiler
CC: C++ compiler
ftn: Fortran compiler
No matter which vendor's compiler module is loaded, always use one of the above commands to invoke the compiler. Using these wrappers will invoke the underlying compiler according to the compiler suite that is loaded in the environment. For some libraries, the appropriate option for the linking will also be included. See here for more information.
About MPI Wrappers
The Cray compiler wrappers replace other wrappers commonly found on HPC
systems like the
mpif90 wrappers. You don't need to
use these wrappers to compile an MPI code on LUMI. See here.
Below are examples on how to use the wrappers for the different programming languages.
cc -c source1.c cc -c source2.c cc source1.o source2.o -o myprogram
CC -c source1.cpp CC -c source2.cpp CC source1.o source2.o -o myprogram
ftn -c source1.f90 ftn -c source2.f90 ftn source1.o source2.o -o myprogram
In the example above, no additional options are provided. However, in most cases this is not the case and the arguments used with the commands vary according to which compiler module is loaded. For example, the arguments and options supported by the GNU Fortran compiler are different from those supported by the Cray Fortran compiler.
Wrapper and compiler options
The following flags are a good starting point to achieved good performance:
|Compilers||Good performance||Aggressive optimizations|
Detailed information about the available compiler options are available here:
The man pages of the wrappers and of the underlying compilers are also a good place to explore the options. The command to access the man pages are presented in the table below.
Choosing the target architecture
When using the Cray programming environment, there is no need to specify compiler flags to target specific CPU architecture, like
-mtune in gcc. Instead, you load an appropriate combination of modules to choose the target architecture when compiling. These modules influence the optimizations performed by the compiler, as well as the libraries (e.g. which BLAS routines are used in Cray LibSci) used. Therefore, we recommend that you compile with
craype-x86-milan for LUMI-C, even if the compiler optimizations for Zen 3 processors are immature at the moment.
The table below summarize the available modules.
||LUMI-D CPUs, login nodes CPUs and EAP CPUs|
The wrapper will pass the appropriate linking information to the compiler and
linker for libraries accessible via
modules prefixed by
cray-. These libraries don't require
user-provided options in order to be linked. For other libraries, the user
should provide the appropriate include (
-I) and library (
-L) search paths
as well as linking command (
If you have used a Cray system in the past, you may be familiar with the legacy linking behaviour of the Cray compiler wrappers. Historically, the wrappers built statically linked executables. In recent versions of the Cray programming environment, this not the case anymore, libraries are now dynamically linked. The following options are available to you to control the behaviour of your application
- Follow the default Linux policy and at runtime use the system default version of the shared libraries (so may change as and when system is upgraded)
- Hard code the path of each library into the binary at compile time so that a
specific version is loaded when the application start (as long as the library is still
CRAY_ADD_RPATH=yesat compile time to use this mode.
- Allow the currently loaded programming environment modules to select the
library version at runtime. Applications must not be linked with
CRAY_ADD_RPATH=yesand must add the following line to the Slurm script:
Static linking is unsupported by Cray at the moment.
Using the wrapper with a
In order to compile an application that uses a series of
make install commands, you can pass the compiler wrappers in the
appropriate environment variables. This should be sufficient for a configure
step to succeed.
./configure CC=cc CXX=CC FC=ftn
For other tools, you can try to export environment variables so that the tool you are using is aware of the wrappers.
export FC=ftn export F77=ftn export F90=ftn
Compile an MPI Program
When you load a programming environment, the appropriate MPI module is loaded in
the environment (
cray-mpich). In order to compile your MPI program, you
should use the set of compiler wrappers (
ftn). The wrappers
will automatically link codes with the MPI libraries.
If you are using a build system that uses a
configure script, you may need to
provide the appropriate variables so that the correct wrapper is used.
./configure MPICC=cc MPICXX=CC MPIF77=ftn MPIF90=ftn
Compile an OpenMP Program
The table below summarizes the compiler flags used to enable OpenMP for the different compilers.
When using the OpenMP compiler flag, the wrapper will link to the multithreaded version of the Cray libraries.