submitting_an_openmp_job.md 1.47 KB
Newer Older
Adam Caprez's avatar
Adam Caprez committed
1
2
3
+++
title = "Submitting an OpenMP Job"
description =  "How to submit an OpenMP job on HCC resources."
4
weight = 45
Adam Caprez's avatar
Adam Caprez committed
5
6
7
8
9
10
11
12
+++

Submitting an OpenMP job is different from
[Submitting an MPI Job]({{< relref "submitting_an_mpi_job" >}})
since you must request multiple cores from a single node.

{{% panel theme="info" header="OpenMP example submission" %}}
{{< highlight batch >}}
13
#!/bin/bash
Adam Caprez's avatar
Adam Caprez committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#SBATCH --ntasks-per-node=16     # 16 cores
#SBATCH --nodes=1                # 1 node
#SBATCH --mem-per-cpu=1024       # Minimum memory required per CPU (in megabytes)
#SBATCH --time=03:15:00          # Run time in hh:mm:ss
#SBATCH --error=/work/[groupname]/[username]/job.%J.err
#SBATCH --output=/work/[groupname]/[username]/job.%J.out
 
export OMP_NUM_THREADS=${SLURM_NTASKS_PER_NODE}
./openmp-app.exe 
{{< /highlight >}}
{{% /panel %}}

Notice that we used `ntasks-per-node` to specify the number of cores we
want on a single node.  Additionally, we specify that we only want
`node`.  

`OMP_NUM_THREADS` is required to limit the number of cores that OpenMP
will use on the node.  It is set to ${SLURM_NTASKS_PER_NODE} to
automatically  match the `ntasks-per-node` value (in this example 16).

### Compiling

Directions to compile OpenMP can be found on 
[Compiling an OpenMP Application]
({{< relref "/applications/user_software/compiling_an_openmp_application" >}}).  

### Further Documentation

Further OpenMP documentation can be found on LLNL's
[OpenMP](https://computing.llnl.gov/tutorials/openMP) website.