Instructions and hints on how to run for the OpenMP lab
The exercises will be run on PDC's CRAY XC-40 system Beskow:
beskow.pdc.kth.se
To access PDC's cluster you should use your laptop and the Eduroam or KTH Open wireless networks.
Instructions on how to connect from various operating systems.
The Cray automatically loads several modules at login.
- Heimdal - Kerberos commands
- OpenAFS - AFS commands
- SLURM - batch jobs and interactive jobs
- Programming environment - Compilers for software development
By default the cray compiler is loaded into your environment. In order to use another compiler you have to swap compiler modules:
module swap PrgEnv-cray PrgEnv-gnu
or
module swap PrgEnv-cray PrgEnv-intel
On Beskow one should always use the compiler wrappers cc
, CC
or
ftn
(for C, C++ and Fortran codes, respectively),
which will automatically link to MPI libraries and linear
algebra libraries like BLAS, LAPACK, etc.
Examples:
# Intel
ftn -openmp source.f90
cc -openmp source.c
CC -openmp source.cpp
# Cray
ftn -openmp source.f90
cc -openmp source.c
CC -openmp source.cpp
# GNU
ftn -fopenmp source.f90
cc -fopenmp source.c
CC -fopenmp source.cpp
After having compiled your code with the correct compilers flags for OpenMP, it is necessary to book a node for interactive use:
salloc -A <allocation-name> -N 1 -t 1:0:0
You might also need to specify a reservation by adding the flag
--reservation=<name-of-reservation>
.
An environment variable specifying the number of threads should also be set:
export OMP_NUM_THREADS=32
Then the srun command is used to launch an OpenMP application:
srun -n 1 ./example.x
In this example we will start one task with 32 threads (there are 32 cores per node on the Beskow nodes).
It is important to use the srun
command since otherwise the job will run on the Beskow login node.
The aim of these exercises is to give an introduction to OpenMP programming. All examples are available in both C and Fortran90.
- OpenMP Intro lab:
- Instructions
- Simple hello world program in C and in Fortran
- Calculate ฯ in C and in Fortran
- Solutions will be made available later during the lab
- OpenMP Advanced Lab:
- Instructions
- In C: shwater2d.c, vtk_export.c and Makefile
- In Fortran: shwater2d.f90, vtk_export.f90 and Makefile
- Solutions will be made available later during the lab