Serial jobs use only a single CPU-core. This is in contrast to parallel jobs which use multiple CPU-cores simultaneously. Below is a sample Slurm script for a serial test job:
#!/bin/bash #SBATCH --job-name=slurm-test # create a short name for your job #SBATCH --nodes=1 # node count #SBATCH --ntasks=1 # total number of tasks across all nodes #SBATCH --cpus-per-task=1 # cpu-cores per task (>1 if multi-threaded tasks) #SBATCH --mem-per-cpu=4G # memory per cpu-core (4G is default) #SBATCH --time=00:01:00 # total run time limit (HH:MM:SS) #SBATCH --mail-type=begin # send email when job begins #SBATCH --mail-type=end # send email when job ends #SBATCH --mail-user=noreply@uni-a.de # set number of threads export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK # Load application module here if necessary srun my_program
Slurm scripts are more or less shell scripts with some extra parameters to set the resource requirements:
- --nodes=1 - specify one node
- --ntasks=1 - claim one task (by default 1 per CPU-core)
- --cpus-per-task=1 - claim one CPU thread per task (by default 1 per Task)
- --time - claim a time allocation, here 1 minute. Format is DAYS-HOURS:MINUTES:SECONDS
The other settings configure automated emails. You can delete these lines if you prefer not to receive emails.
Hidden Parallization/Threading
Always assume you application might be parallized via threading (OpenMP, Posix-threads)! The definition of export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
will make sure that your application will not use more ressources than requested. Without this evironment variable, a threaded application might use the maximum number of CPU threads available on a single Node. Since Slurm will limit hardware ressources according to what was requested, omission of this evironment variable may result in significant overhead, crashed, out-of-memory situations and an artificially increased load on the Nodes.
Submit the job to the Slurm job scheduler using the following command:
$ sbatch job.slurm
In the command above, job.slurm is the filename of your Slurm script. Feel free to use a different name such as submit.sh.
As a Slurm job runs, unless you redirect output, a file named slurm-######.out will be produced in the directory where the sbatch command was ran. You can use cat, less or any text editor to view it. The file contains the output your program would have written to a terminal if run interactively.