First test jobs
This page contains two batch job examples, that can be used to get started with batch processing:
First Slurm job job which could be run on any SLURM installation.
First Hummel-2 jobs which has the properties of all batch jobs to be run on Hummel-2.
First Slurm job
This job is generic, i.e. it contains nothing that is specific to
Hummel-2. It contains resource specifications (--ntasks
and
--time
) and one command (echo
).
line no. |
/sw/batch/examples/first-test-jobs/first-slurm-job.sh |
1 2 3 4 5 6 7 8 9 |
#!/bin/bash #SBATCH --ntasks=1 #SBATCH --time=00:01:00
# This batch job should run on every Slurm batch system.
echo "Hello, world!"
exit |
---|
First Hummel-2 job
This job has all characteristic properties of a batch job to be run on Hummel-2:
- First of all it is a parallel job. It has the smallest possible job size which is 8 CPU cores.
- The recommended submit option –export=NONE is set.
- The recommended initialization source /sw/batch/init.sh is included.
The job uses the srun
command for demonstration purpose.
(OpenMP programs do not need srun
. MPI programs shall be
started with mpirun
.)
line no. |
/sw/batch/examples/first-test-jobs/first-hummel2-job.sh |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#!/bin/bash # # Do not forget to select a proper partition and account if the # default one is no fit for the job! You can do that with environment # variables SBATCH_PARTITION and SBATCH_ACCOUNT, in the sbatch command # line or here with the other #SBATCH settings. # # Never forget "--export=NONE" and "source /sw/batch/init.sh" ! # Strange happenings ensue otherwise. # #SBATCH --job-name=hello #SBATCH --ntasks=8 #SBATCH --time=00:10:00 #SBATCH --export=NONE
source /sw/batch/init.sh
# Load environment modules for your application here.
# Useful settings: set -e # Stop operation on first error. set -u # Treat undefined variables as an error. set -x # Print command lines as they are executed.
# Actual work starting here. You might need to call mpirun for MPI # programs or srun depending on your type of application for proper # parallel work. Examples of simple commands (that might themselves # handle parallelisation): echo "Hello World! I am node $(hostname -s) greeting you!" echo "Also, my current TMPDIR is $TMPDIR"
# Let's pretend our started processes are working on a predetermined # parameter set, and are finding their specific parameters using the # set number and the process number inside the batch job: export PARAMETER_SET=42
# Simplest way to run an identical command on all allocated # cores. Environment variables can be used to tell apart the # instances: srun bash -c 'echo "process $SLURM_PROCID \ (out of $SLURM_NPROCS total) on $(hostname -s), \ parameter set: $PARAMETER_SET"'
# Demonstration of process binding: each "grep" uses # only the CPU core printed: srun --cpu-bind=cores grep Cpus_allowed_list: /proc/self/status
exit |
---|
The commands for trying this batch job are:
shell$
cd $BEEGFS
shell$sbatch /sw/batch/examples/first-test-jobs/first-hummel2-job.sh
Submitted batch job 12345 shell$cat slurm-12345.out
module: loaded site/slurm module: loaded site/tmpdir module: loaded site/hummel2 module: loaded env/system-gcc ++ hostname -s + echo 'Hello World! I am node n123 greeting you!' Hello World! I am node n123 greeting you! + echo 'Also, my current TMPDIR is /tmp' Also, my current TMPDIR is /tmp + export PARAMETER_SET=42 + PARAMETER_SET=42 + srun bash -c 'echo "process $SLURM_PROCID \ (out of $SLURM_NPROCS total) on $(hostname -s), \ parameter set: $PARAMETER_SET"' process 5 (out of 8 total) on n123, parameter set: 42 process 0 (out of 8 total) on n123, parameter set: 42 process 4 (out of 8 total) on n123, parameter set: 42 process 1 (out of 8 total) on n123, parameter set: 42 process 2 (out of 8 total) on n123, parameter set: 42 process 6 (out of 8 total) on n123, parameter set: 42 process 3 (out of 8 total) on n123, parameter set: 42 process 7 (out of 8 total) on n123, parameter set: 42 + srun --cpu-bind=cores grep Cpus_allowed_list: /proc/self/status Cpus_allowed_list: 160 Cpus_allowed_list: 161 Cpus_allowed_list: 162 Cpus_allowed_list: 163 Cpus_allowed_list: 164 Cpus_allowed_list: 165 Cpus_allowed_list: 166 Cpus_allowed_list: 167 + exit