CPU Examples¶
Standard job using a single CPU¶
#!/bin/bash
#
#SBATCH -p wn
#SBATCH --account=t3
#SBATCH --job-name=job-name
#SBATCH --mem=3000M # memory 3GB (per job)
#SBATCH --time 01:00:00
#SBATCH -o %x-%j.out # replace default slurm-SLURM_JOB_ID.out; %x is a job-name (or script name when there is no job-name)
#SBATCH -e %x-%j.err # replace default slurm-SLURM_JOB_ID.err
echo HOME: $HOME
echo USER: $USER
echo SLURM_JOB_ID: $SLURM_JOB_ID
echo HOSTNAME: $HOSTNAME
# You should use a node's local /scratch space for creating files and
# intensive I/O. Never use /tmp, and make sure that you also
# set TMPDIR, so that your programs create temporary files there
JOB_SCRATCH=/scratch/$USER/$SLURM_JOB_ID
mkdir -p "$JOB_SCRATCH"
export TMPDIR="$JOB_SCRATCH"
#########################################################
# Please fill in your code here
#########################################################
# cleaning of temporary working dir after job is completed:
rm -rf "$JOB_SCRATCH"
date
Jobs using multiple CPUs¶
Example of the job header for running 8 parallel threads within a single task, each thread getting it's own logical CPU (hardware thread).
#!/bin/bash
#SBATCH --job-name=smp_example # Job name
#SBATCH -p wn
#SBATCH --account=t3
#SBATCH --ntasks=1 # Run a single task
#SBATCH --cpus-per-task=8 # Number of CPU cores per task; Example of submitting 8-core parallel SMP job
#SBATCH --mem=3gb # memory request for whole job
## Alternatively, you could set instead a memory per CPU requirement
## #SBATCH --mem-per-cpu=3072
#SBATCH --time=02:00:00 # Time limit hrs:min:sec
#SBATCH --output=smp_%j.log # Standard output and error log
your_script.sh