Slurm OpenMP Examples

Slurm OpenMP Examples

This example shows a 48 core OpenMP Job (maximum size for one node on Abisko).

    #!/bin/bash
    # Example with 48 cores for OpenMP
    #
    # Project/Account
    #SBATCH -A hpc2n-1234-56
    #
    # Number of cores per task
    #SBATCH -c 48
    #
    # Runtime of this jobs is less then 12 hours.
    #SBATCH --time=12:00:00
    #

    # Set OMP_NUM_THREADS to the same value as -c
    # with a fallback in case it isn't set.
    # SLURM_CPUS_PER_TASK is set to the value of -c, but only if -c is explicitly set
    if [ -n "$SLURM_CPUS_PER_TASK" ]; then
      omp_threads=$SLURM_CPUS_PER_TASK
    else
      omp_threads=1
    fi
    export OMP_NUM_THREADS=$omp_threads

    srun ./openmp_program

    # End of submit file

 

You can submit this into slurm with:

    sbatch submit_script.sh

Kebnekaise

On Kebnekaise, the core-number of one node is 28, so in order to use the above script on Kebnekaise, you should make these changes:

# Number of cores per task
#SBATCH -c 28

You submit the job in the same manner as on Abisko.

Updated: 2017-11-21, 20:49