Use Slurm job array instead of multiple jobs
This commit is contained in:
parent
0a37272620
commit
f1bd37b0d8
14
README.md
14
README.md
@ -50,20 +50,20 @@ By default, each node is allocated:
|
||||
|
||||
By default, this script searches for prime numbers from `1-10,000` and `10,001-20,000`
|
||||
|
||||
You can adjust the range searched per node by providing an integer argument, e.g.:
|
||||
You can adjust the range searched per node by providing an integer argument, e.g.:
|
||||
|
||||
/vagrant/primes.sh 20000
|
||||
|
||||
The script will then drop you into a `watch -n0.1 squeue` view so you can see
|
||||
each job computing on `nodes[3-4]`. You may `CTRL+c` out of this view, and
|
||||
the jobs will continue in the background. The home directory for the `submit`
|
||||
user is in the shared `/vagrant` directory, so the results from each node are
|
||||
shared back to the login node.
|
||||
the job computing on `nodes[3-4]`. You may `CTRL+c` out of this view, and
|
||||
the job will continue in the background. The home directory for the `submit`
|
||||
user is in the shared `/vagrant` directory, so the results from each node are
|
||||
shared back to the login node.
|
||||
|
||||
4. View the resulting prime numbers found, check `ls` for exact filenames
|
||||
|
||||
less slurm-1.out
|
||||
less slurm-2.out
|
||||
less slurm-1_0.out
|
||||
less slurm-2_1.out
|
||||
|
||||
### Configuration Tool
|
||||
|
||||
|
13
primes.sh
13
primes.sh
@ -24,7 +24,7 @@ RANGE=${1:-10000}
|
||||
function find_primes() {
|
||||
local START="$1"
|
||||
local END="$2"
|
||||
echo "INFO: Job $SLURM_JOB_ID looking for prime numbers from $START to $END"
|
||||
echo "INFO: Job ${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID} looking for prime numbers from $START to $END"
|
||||
for ((i=START;i<=END;i++)); do
|
||||
if [ "$(factor "$i")" == "$i: $i" ]; then
|
||||
echo "$i"
|
||||
@ -32,10 +32,13 @@ function find_primes() {
|
||||
done
|
||||
}
|
||||
|
||||
if [ -z "$SLURM_JOB_ID" ]; then
|
||||
sbatch -N1 --wrap="$0 1 $RANGE"
|
||||
sbatch -N1 --wrap="$0 $((RANGE + 1)) $((RANGE * 2))"
|
||||
if [ -z "$SLURM_ARRAY_JOB_ID" ]; then
|
||||
sbatch -N1 -a0-1 "$0" "$RANGE"
|
||||
watch -n0.1 squeue
|
||||
else
|
||||
find_primes "$1" "$2"
|
||||
if [ "$SLURM_ARRAY_TASK_ID" -eq 0 ]; then
|
||||
find_primes 1 "$RANGE"
|
||||
else
|
||||
find_primes $((RANGE + 1)) $((RANGE * 2))
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user