Submitting an OpenMP job is different from Submitting an MPI Job since you must request multiple cores from a single node.
#!/bin/bash
#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
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
1 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).
Directions to compile OpenMP can be found on Compiling an OpenMP Application.
Further OpenMP documentation can be found on LLNL’s OpenMP website.