Mercurial > hg > cc > cirrus_work
diff bin/_runme.sh @ 2:b4801f5696b2
compute node workers, see cirrus_home/bin repo for login node masters
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Mon, 18 Jul 2022 19:22:42 +0100 |
parents | |
children | e3c440666f1a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/_runme.sh Mon Jul 18 19:22:42 2022 +0100 @@ -0,0 +1,54 @@ +#!/bin/bash +# This runs on the compute nodes... +# Args: wd [-b CMDS] [-i input] CMDS + +N=$SLURM_JOB_NUM_NODES +n=$SLURM_NTASKS +c=$SLURM_CPUS_PER_TASK +nodename=$SLURMD_NODENAME +local=$SLURM_LOCALID +node=$SLURM_NODEID +task=$SLURM_PROCID + +cd "$1" +shift + +threadsPerTask=2 +pjobs=$((c / $threadsPerTask)) + +echo $(date) task $n.$task on $nodename:$N.$node start $(pwd) 1>&2 + +PATH=$W/$USER/bin:$W/shared/bin:$PATH +export task PATH n + +if [ "$1" = "-b" ] +then + shift + eval "$1" + shift +fi + +if [ "$1" = "-i" ] +then + shift + input="$1" + shift +fi + +export cmd="$1" +shift + +doit () { + arg="$1" + echo $(date) start $task $PARALLEL_SEQ $arg + eval "$cmd" + echo $(date) end $task $PARALLEL_SEQ +} + +export -f doit + +eval "$input" | \ + parallel -j $pjobs doit '{}' + +echo $(date) task $n.$task on $nodename:$N.$node end 1>&2 +