We have the following code in our TaskProlog:

## Set $OMP_NUM_THREADS unless it was set when calling sbatch or in the job 
script:
if [[ -z $OMP_NUM_THREADS ]]; then
    if [[ -n $SLURM_CPUS_PER_TASK ]]; then
        echo export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
    else
        echo export OMP_NUM_THREADS=1
    fi
fi

It sets OMP_NUM_THREADS to SLURM_CPUS_PER_TASK (or 1 if --cpus-per-task
is not specified), unless already set.  That way, users can override it
in their job script if they wish.  It seems to work fine.

-- 
Regards,
Bjørn-Helge Mevik, dr. scient,
Department for Research Computing, University of Oslo

Attachment: signature.asc
Description: PGP signature

Reply via email to