Skip to content

Instantly share code, notes, and snippets.

@marcc-hpc
Created August 7, 2018 14:05
Show Gist options
  • Save marcc-hpc/6598b25f9a4182d6627378d88447e6bc to your computer and use it in GitHub Desktop.
Save marcc-hpc/6598b25f9a4182d6627378d88447e6bc to your computer and use it in GitHub Desktop.
Matching job script for example_lapack.py
#!/bin/bash -l
#SBATCH --job-name=test_with_gnu_parallel
#SBATCH --partition=parallel
#SBATCH --time=1:0:0
#SBATCH --nodes=1
#SBATCH --ntasks=4
#SBATCH --cores=6
# in this example we are using multithreading via MKL threads
# if you have single core tasks set ntasks=24
# You can optionally use these
###SBATCH --output test_with_gnu_parallel%a.out
###SBATCH --error test_with_gnu_parallel_%a.err
###SBATCH --mail-user=username@jhu.edu
###SBATCH --mail-type=ALL
# See this resource for 'inspiration' in using GNU parallel
# https://rcc.uchicago.edu/docs/tutorials/kicp-tutorials/running-jobs.html
ml anaconda-python/2.7
ml parallel
ml
mkdir -p logs
# start timestamp
date
# this call is good for single core but exclusive may degrade performance in multithreading
srun="srun --exclusive -N1 -n1 -c6"
# --delay .2 prevents overloading the controlling node
# -j is the number of tasks parallel runs so we set it to 24 (the number of steps we want to run)
# --joblog makes parallel create a log of tasks that it has already run
# --resume makes parallel use the joblog to resume from where it has left off
# the combination of --joblog and --resume allow jobs to be resubmitted if
# necessary and continue from where they left off
parallel="parallel --delay .2 -j 4 --joblog logs/runtask.log --resume"
# gnu parallel: this runs the parallel command we want
# in this case, we are running a script named runtask
# parallel uses ::: to separate options. Here {1..20} is a shell expansion
# so parallel will run the command passing the numbers 1 through 10
# via argument {1}
# srun arguments:
# (single core) the --exclusive to srun makes srun use distinct CPUs for each job step
# -N1 -n6 allocates a matching cores to each job step
echo $parallel "$srun python example_lapack.py {1}000 6" ::: {1..10}
$parallel "$srun python example_lapack.py {1}000 6" ::: {1..10}
# end timestamp
date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment