OpenMP Jobs under LSF


This is an example script for running an OpenMP application under LSF.

There are at least two items you have to specify:

  • The number of cores you request for the job.
  • The name and options of your program.
#!/bin/sh
### General options
### -- set the job Name --
#BSUB -J OpenMPjob
### -- ask for number of cores (default: 1) --
#BSUB -n 4
### -- specify that the cores MUST BE on a single host! It's a SMP job! --
#BSUB -R "span[hosts=1]"
### -- set walltime limit: hh:mm --
#BSUB -W 16:00 
### -- specify that we need 4GB of memory per core/slot -- 
#BSUB -R "rusage[mem=4GB]"
### -- set the email address --
# please uncomment the following line and put in your e-mail address,
# if you want to receive e-mail notifications on a non-default address
##BSUB -u your_email_address
### -- send notification at start --
#BSUB -B
### -- send notification at completion--
#BSUB -N
### -- Specify the output and error file. %J is the job-id -- 
### -- -o and -e mean append, -oo and -eo mean overwrite -- 
#BSUB -o Output_%J.out
#BSUB -e Output_%J.err 

# set OMP_NUM_THREADS _and_ export! 
OMP_NUM_THREADS=$LSB_DJOB_NUMPROC 
export OMP_NUM_THREADS 
# ------------------------------- Program_name_and_options 
your_openmp_program [options]

If you make use of special environment variables for your OpenMP program, remember to put them in your script (use the same syntax as the OMP_NUM_THREADS line in the script).