# PDC Summer School: General Instructions for the OpenMP Labs
# PDC Summer School 2022: General Instructions for the OpenMP Labs
## Where to run
## Where to run
The exercises will be run on PDC's cluster [Tegner](https://www.pdc.kth.se/hpc-services/computing-systems/tegner-1.737437):
The exercises will be run on PDC's supercomputer [Dardel](https://www.pdc.kth.se/hpc-services/computing-systems/dardel-1.1043529):
```
```
tegner.pdc.kth.se
dardel.pdc.kth.se
```
```
## How to login
## How to login
To access PDC's systems you need an account at PDC. Check the [instructions for obtaining an account](https://www.pdc.kth.se/support/documents/getting_access/get_access.html#apply-via-pdc-webpage).
To access PDC's systems you need an account at PDC. Check the [instructions for obtaining an account](https://www.pdc.kth.se/support/documents/getting_access/get_access.html#apply-via-pdc-webpage).
Once you have an account, you can follow the [instructions on how to connect from various operating systems](https://www.pdc.kth.se/support/documents/login/login.html).
Once you have an account, you can follow the Quick Start for Dardel instructions for [how to log in](https://www.pdc.kth.se/support/documents/basics/quickstartdardel.html#how-to-log-in).
Related to the Kerberos-based authentication environment, please check the [Kerberos commands documentation](https://www.pdc.kth.se/support/documents/login/login.html#general-information-about-kerberos)
## More about the environment on Dardel
## More about the environment on Tegner
Software, which is not available by default, needs to be loaded as a [module](https://www.pdc.kth.se/support/documents/basics/quickstartdardel.html#the-lmod-module-system) at login. Use ``ml avail`` to get a list of available modules. Many software modules become available after loading the latest PDC module using ``ml PDC``.
Software, which is not available by default, needs to be loaded as a [module](https://www.pdc.kth.se/support/documents/run_jobs/job_scheduling.html#accessing-software) at login. Use ``module avail`` to get a list of available modules. The following modules are of interest for this lab exercises:
To setup the development environment see: [Compilers and Libraries on Dardel](https://www.pdc.kth.se/support/documents/software_development/development_dardel.html).
- Different versions of the GNU compiler suite (``gcc/*``)
The home directories on Dardel are provided through a Lustre service. See the page [Data Management](https://www.pdc.kth.se/support/documents/data_management/data_management.html) for more information.
- Different versions of the Intel compiler suite (``i-compilers/*``)
For more information see the [software development documentation page](https://www.pdc.kth.se/support/documents/software_development/development.html).
To use the Dardel compute nodes you have to use the resource manager as described here: [How to Run jobs](https://www.pdc.kth.se/support/documents/run_jobs/job_scheduling.html).
Home directories are provided through an OpenAFS services. See the [AFS data management page](https://www.pdc.kth.se/support/documents/data_management/afs.html) for more information.
To use the Tegner compute nodes you have to submit [SLURM batch jobs](https://www.pdc.kth.se/support/documents/run_jobs/queueing_jobs.html) or run [SLURM interactive jobs](https://www.pdc.kth.se/support/documents/run_jobs/run_interactively.html).
## Compiling programs
## Compiling programs
By default you are provided with the compilers that come with the OS and are not the most recent versions of the compilers. To use a recent version of the GNU compiler suite or the Intel compilers use
By default you are provided with the compilers that come with the OS and are not the most recent versions of the compilers. To use a recent version of the GNU compiler suite use
```
```
module load gcc
ml gcc
```
ml cpe/21.11
or
ml PrgEnv-gnu
```
module load i-compilers
```
```
## Running OpenMP programs
## Running OpenMP programs
After having compiled your code with the
First it is necessary to book a node for interactive use:
[correct compilers flags for OpenMP](https://www.pdc.kth.se/support/documents/software_development/development.html),
it is necessary to book a node for interactive use:
```
```
salloc -A <allocation-name> -N 1 -t 1:0:0
salloc -A <allocation-name> -p main -N 1 -t 1:0:0
```
```
You might also need to specify a **reservation** by adding the flag ``--reservation=<name-of-reservation>``.
You might also need to specify a **reservation** by adding the flag ``--reservation=<name-of-reservation>``.
For the 2022 PDC Summer School the reservation name is ``summer-<date>``, where ``date`` is to be provided in the format ``YYYY-MM-DD``, e.g. ``summer-2022-08-16``.
An environment variable specifying the number of threads should also be set:
An environment variable specifying the number of threads should also be set:
```
```
export OMP_NUM_THREADS=24
export OMP_NUM_THREADS=128
```
```
Then the srun command is used to launch an OpenMP application:
Then the ``srun`` command is used to launch an OpenMP application:
```
```
srun -n 1 ./example.x
srun -n 1 ./example.x
```
```
In this example we will start one task with 24 threads.
In this example we will start one task with 128 threads.
It is important to use the `srun` command since otherwise the job will run on the login node.
It is important to use the `srun` command since otherwise the job will run on the login node.