|
| 1 | +#!/bin/bash |
| 2 | +#! |
| 3 | +#! Example SLURM job script for Peta4-Skylake (Skylake CPUs, OPA) |
| 4 | +#! Last updated: Mon 13 Nov 12:25:17 GMT 2017 |
| 5 | +#! |
| 6 | + |
| 7 | +#!############################################################# |
| 8 | +#!#### Modify the options in this section as appropriate ###### |
| 9 | +#!############################################################# |
| 10 | + |
| 11 | +#! sbatch directives begin here ############################### |
| 12 | +#! Name of the job: |
| 13 | +#SBATCH -J cpujob |
| 14 | +#! Redirect stderr and stdout |
| 15 | +#SBATCH --output results/dask/mpitest-@@NODETYPE@@-@@NUMNODES@@-@@NUMTASKS@@.out |
| 16 | +#SBATCH --error results/dask/mpitest-@@NODETYPE@@-@@NUMNODES@@-@@NUMTASKS@@.err |
| 17 | +#! Which project should be charged (NB Wilkes projects end in '-GPU'): |
| 18 | +#SBATCH -A SKA-SDP-SL2-CPU |
| 19 | +#! How many whole nodes should be allocated? |
| 20 | +#SBATCH --nodes=@@NUMNODES@@ |
| 21 | +#! How many (MPI) tasks will there be in total? (<=nodes*12) |
| 22 | +#! The skylake/skylake-himem nodes have 32 CPUs (cores) each. ntasks=64 |
| 23 | +#! We will allocate one process per node |
| 24 | +#SBATCH --ntasks=@@NUMNODES@@ |
| 25 | +#! How much wallclock time will be required? |
| 26 | +#SBATCH --time=24:22:00 |
| 27 | +#! What types of email messages do you wish to receive? |
| 28 | +#SBATCH --mail-type=FAIL |
| 29 | +#! Uncomment this to prevent the job from being requeued (e.g. if |
| 30 | +#! interrupted by node failure or system downtime): |
| 31 | +##SBATCH --no-requeue |
| 32 | + |
| 33 | +# Request the nodes in exclusive mode |
| 34 | +#SBATCH --exclusive |
| 35 | +# Request the nodes to be on the same switch |
| 36 | +#SBATCH --switches=1 |
| 37 | + |
| 38 | +#! For 6GB per CPU, set "-p skylake"; for 12GB per CPU, set "-p skylake-himem": |
| 39 | +#SBATCH -p @@NODETYPE@@ |
| 40 | + |
| 41 | +#! sbatch directives end here (put any additional directives above this line) |
| 42 | + |
| 43 | +#! Notes: |
| 44 | +#! Charging is determined by core number*walltime. |
| 45 | +#! The --ntasks value refers to the number of tasks to be launched by SLURM only. This |
| 46 | +#! usually equates to the number of MPI tasks launched. Reduce this from nodes*32 if |
| 47 | +#! demanded by memory requirements, or if OMP_NUM_THREADS>1. |
| 48 | +#! Each task is allocated 1 core by default, and each core is allocated 5990MB (skylake) |
| 49 | +#! and 12040MB (skylake-himem). If this is insufficient, also specify |
| 50 | +#! --cpus-per-task and/or --mem (the latter specifies MB per node). |
| 51 | + |
| 52 | +#! Number of nodes and tasks per node allocated by SLURM (do not change): |
| 53 | +numnodes=$SLURM_JOB_NUM_NODES |
| 54 | +numtasks=$SLURM_NTASKS |
| 55 | +mpi_tasks_per_node=$(echo "$SLURM_TASKS_PER_NODE" | sed -e 's/^\([0-9][0-9]*\).*$/\1/') |
| 56 | +#! ############################################################ |
| 57 | +#! Modify the settings below to specify the application's environment, location |
| 58 | +#! and launch method: |
| 59 | + |
| 60 | +#! Optionally modify the environment seen by the application |
| 61 | +#! (note that SLURM reproduces the environment at submission irrespective of ~/.bashrc): |
| 62 | +. /etc/profile.d/modules.sh # Leave this line (enables the module command) |
| 63 | +module purge # Removes all modules still loaded |
| 64 | +module load rhel7/default-peta4 # REQUIRED - loads the basic environment |
| 65 | + |
| 66 | +export ARLROOT=/home/mf582/scratch/ARL/algorithm-reference-library |
| 67 | +export ARL=/home/mf582/scratch/ARL/algorithm-reference-library |
| 68 | + |
| 69 | +#! Insert additional module load commands after this line if needed: |
| 70 | +echo "source ${ARLROOT}/scripts/csd3-slurm/activate-env-csd3.sh" |
| 71 | +source $ARLROOT/scripts/csd3-slurm/activate-env-csd3.sh |
| 72 | + |
| 73 | +#module load intel/bundles/psxe/2017.4 |
| 74 | + |
| 75 | +#! Full path to application executable: |
| 76 | +application="$ARLROOT/workflows/mpi/imaging-pipelines_arlexecute.py" |
| 77 | + |
| 78 | +#! Run options for the application: |
| 79 | +#! the number of frequencies and the json file? |
| 80 | +#!options="--nfreqwin=@@NFREQ@@" |
| 81 | + |
| 82 | +#! Work directory (i.e. where the job will run): |
| 83 | +workdir="$SLURM_SUBMIT_DIR" # The value of SLURM_SUBMIT_DIR sets workdir to the directory |
| 84 | + # in which sbatch is run. |
| 85 | +workdir="$ARLROOT/workflows/mpi/results/dask" |
| 86 | + |
| 87 | +#! Are you using OpenMP (NB this is unrelated to OpenMPI)? If so increase this |
| 88 | +#! safe value to no more than 32: |
| 89 | +export OMP_NUM_THREADS=1 |
| 90 | + |
| 91 | +#! Number of MPI tasks to be started by the application per node and in total (do not change): |
| 92 | +np=$[${numnodes}*${mpi_tasks_per_node}] |
| 93 | + |
| 94 | +#! The following variables define a sensible pinning strategy for Intel MPI tasks - |
| 95 | +#! this should be suitable for both pure MPI and hybrid MPI/OpenMP jobs: |
| 96 | +export I_MPI_PIN_DOMAIN=omp:compact # Domains are $OMP_NUM_THREADS cores in size |
| 97 | +export I_MPI_PIN_ORDER=scatter # Adjacent domains have minimal sharing of caches/sockets |
| 98 | +#! Notes: |
| 99 | +#! 1. These variables influence Intel MPI only. |
| 100 | +#! 2. Domains are non-overlapping sets of cores which map 1-1 to MPI tasks. |
| 101 | +#! 3. I_MPI_PIN_PROCESSOR_LIST is ignored if I_MPI_PIN_DOMAIN is set. |
| 102 | +#! 4. If MPI tasks perform better when sharing caches/sockets, try I_MPI_PIN_ORDER=compact. |
| 103 | + |
| 104 | + |
| 105 | +#! Uncomment one choice for CMD below (add mpirun/mpiexec options if necessary): |
| 106 | + |
| 107 | +#! Choose this for a MPI code (possibly using OpenMP) using Intel MPI. |
| 108 | +#CMD="mpirun -ppn $mpi_tasks_per_node -np $np $application $options" |
| 109 | +#CMD="mpiexec -trace -np $np python $application $options" |
| 110 | +#CMD="mpiexec -np $np python $application $options" |
| 111 | +#! NUMTASKS is not correct here, it should be numthreads numtasks referes to the total threads |
| 112 | +#CMD="mpiexec -np $np dask-mpi --no-nanny --nthreads @@NUMTASKS@@ --memory-limit 0.75 --scheduler-file TEXT --interface ib0 --local-directory TEXT" |
| 113 | +#CMD="mpiexec -np $np dask-mpi --no-nanny --nthreads @@NUMTASKS@@ --memory-limit 0.75 --interface ib0" |
| 114 | + |
| 115 | +#CMD2="python $application $options" |
| 116 | +#CMD="mpirun -ppn $mpi_tasks_per_node -np $np $application $options" |
| 117 | +#mpi_tasks_per_node=$[${mpi_tasks_per_node}/2] |
| 118 | +#CMD2="mpirun -ppn $mpi_tasks_per_node -np $np $application $options" |
| 119 | + |
| 120 | +#! Choose this for a pure shared-memory OpenMP parallel program on a single node: |
| 121 | +#! (OMP_NUM_THREADS threads will be created): |
| 122 | +#CMD="$application $options" |
| 123 | + |
| 124 | +#! Choose this for a MPI code (possibly using OpenMP) using OpenMPI: |
| 125 | +#CMD="mpirun -npernode $mpi_tasks_per_node -np $np $application $options" |
| 126 | + |
| 127 | + |
| 128 | +############################################################### |
| 129 | +### You should not have to change anything below this line #### |
| 130 | +############################################################### |
| 131 | + |
| 132 | +cd $workdir |
| 133 | +echo -e "Changed directory to `pwd`.\n" |
| 134 | + |
| 135 | +# Make sure there is no scheduler.json file and tmp directory for threads in workflows/mpi |
| 136 | +# We can make it cleaner by passing it as a parameter to dask-mpi ... |
| 137 | +#rm -fr ../../dask-worker-space |
| 138 | +#rm ../../scheduler.json |
| 139 | + |
| 140 | +JOBID=$SLURM_JOB_ID |
| 141 | +mkdir $JOBID |
| 142 | +cd $JOBID |
| 143 | +echo -e "JobID: $JOBID\n======" |
| 144 | +echo "Time: `date`" |
| 145 | +echo "Running on master node: `hostname`" |
| 146 | +echo "Current directory: `pwd`" |
| 147 | + |
| 148 | +if [ "$SLURM_JOB_NODELIST" ]; then |
| 149 | + #! Create a machine file: |
| 150 | + export NODEFILE=`generate_pbs_nodefile` |
| 151 | + cat $NODEFILE | uniq > machine.file.$JOBID |
| 152 | + echo -e "\nNodes allocated:\n================" |
| 153 | + echo `cat machine.file.$JOBID | sed -e 's/\..*$//g'` |
| 154 | +fi |
| 155 | + |
| 156 | +echo -e "\nnumtasks=$numtasks, numnodes=$numnodes, mpi_tasks_per_node=$mpi_tasks_per_node (OMP_NUM_THREADS=$OMP_NUM_THREADS)" |
| 157 | +schedulerfile="$workdir/$JOBID/scheduler.json" |
| 158 | +tmpdir="$workdir/$JOBID/dask-worker-space" |
| 159 | +machines="$workdir/$JOBID/machine.file.$JOBID" |
| 160 | +CMD="mpiexec -np $np -machinefile $machines dask-mpi --no-nanny --nthreads @@NUMTASKS@@ --memory-limit 0.75 --scheduler-file $schedulerfile --interface ib0 --local-directory $tmpdir" |
| 161 | +echo -e "\nExecuting command:\n==================\n$CMD\n" |
| 162 | + |
| 163 | +sleep 10 |
| 164 | +eval $CMD &> mpiexec-${JOBID}.log & |
| 165 | +sleep 10 |
| 166 | +echo -e "\n After command:\n==================\n$CMD\n" |
| 167 | + |
| 168 | +#NFREQ_LIST='7 21 41' |
| 169 | +NFREQ_LIST='@@NFREQ_LIST@@' |
| 170 | +for NFREQ in $NFREQ_LIST |
| 171 | + do |
| 172 | + options="--nfreqwin=$NFREQ" |
| 173 | + options="--nfreqwin=$NFREQ --schedulerfile=${schedulerfile}" |
| 174 | + CMD2="python $application $options > ../mpitest-@@NODETYPE@@-@@NUMNODES@@-@@NUMTASKS@@-$NFREQ.out" |
| 175 | + echo -e "\nExecuting command:\n==================\n$CMD2\n" |
| 176 | + eval $CMD2 |
| 177 | +done |
| 178 | + |
0 commit comments