|
| 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/mpi/mpitest-@@NODETYPE@@-@@NUMNODES@@-@@NUMTASKS@@-@@NFREQ@@.out |
| 16 | +#SBATCH --error results/mpi/mpitest-@@NODETYPE@@-@@NUMNODES@@-@@NUMTASKS@@-@@NFREQ@@.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 | +#SBATCH --ntasks=@@NUMTASKS@@ |
| 24 | +#! How much wallclock time will be required? |
| 25 | +#SBATCH --time=04:22:00 |
| 26 | +#! What types of email messages do you wish to receive? |
| 27 | +#SBATCH --mail-type=FAIL |
| 28 | +#! Uncomment this to prevent the job from being requeued (e.g. if |
| 29 | +#! interrupted by node failure or system downtime): |
| 30 | +##SBATCH --no-requeue |
| 31 | + |
| 32 | +# Request the nodes in exclusive mode |
| 33 | +#SBATCH --exclusive |
| 34 | +# Request the nodes to be on the same switch |
| 35 | +#SBATCH --switches=1 |
| 36 | + |
| 37 | +#! For 6GB per CPU, set "-p skylake"; for 12GB per CPU, set "-p skylake-himem": |
| 38 | +#SBATCH -p @@NODETYPE@@ |
| 39 | + |
| 40 | +#! sbatch directives end here (put any additional directives above this line) |
| 41 | + |
| 42 | +#! Notes: |
| 43 | +#! Charging is determined by core number*walltime. |
| 44 | +#! The --ntasks value refers to the number of tasks to be launched by SLURM only. This |
| 45 | +#! usually equates to the number of MPI tasks launched. Reduce this from nodes*32 if |
| 46 | +#! demanded by memory requirements, or if OMP_NUM_THREADS>1. |
| 47 | +#! Each task is allocated 1 core by default, and each core is allocated 5990MB (skylake) |
| 48 | +#! and 12040MB (skylake-himem). If this is insufficient, also specify |
| 49 | +#! --cpus-per-task and/or --mem (the latter specifies MB per node). |
| 50 | + |
| 51 | +#! Number of nodes and tasks per node allocated by SLURM (do not change): |
| 52 | +numnodes=$SLURM_JOB_NUM_NODES |
| 53 | +numtasks=$SLURM_NTASKS |
| 54 | +mpi_tasks_per_node=$(echo "$SLURM_TASKS_PER_NODE" | sed -e 's/^\([0-9][0-9]*\).*$/\1/') |
| 55 | +#! ############################################################ |
| 56 | +#! Modify the settings below to specify the application's environment, location |
| 57 | +#! and launch method: |
| 58 | + |
| 59 | +#! Optionally modify the environment seen by the application |
| 60 | +#! (note that SLURM reproduces the environment at submission irrespective of ~/.bashrc): |
| 61 | +. /etc/profile.d/modules.sh # Leave this line (enables the module command) |
| 62 | +module purge # Removes all modules still loaded |
| 63 | +module load rhel7/default-peta4 # REQUIRED - loads the basic environment |
| 64 | + |
| 65 | +export ARLROOT=/home/mf582/scratch/ARL/algorithm-reference-library |
| 66 | + |
| 67 | +#! Insert additional module load commands after this line if needed: |
| 68 | +echo "source ${ARLROOT}/scripts/csd3-slurm/activate-env-csd3.sh" |
| 69 | +source $ARLROOT/scripts/csd3-slurm/activate-env-csd3.sh |
| 70 | + |
| 71 | +#module load intel/bundles/psxe/2017.4 |
| 72 | + |
| 73 | +#! Full path to application executable: |
| 74 | +application="$ARLROOT/workflows/mpi/imaging-pipelines-mpi.py" |
| 75 | + |
| 76 | +#! Run options for the application: |
| 77 | +options="--nfreqwin=@@NFREQ@@" |
| 78 | + |
| 79 | +#! Work directory (i.e. where the job will run): |
| 80 | +workdir="$SLURM_SUBMIT_DIR" # The value of SLURM_SUBMIT_DIR sets workdir to the directory |
| 81 | + # in which sbatch is run. |
| 82 | +#workdir="$ARLROOT/workflows/mpi" |
| 83 | + |
| 84 | +#! Are you using OpenMP (NB this is unrelated to OpenMPI)? If so increase this |
| 85 | +#! safe value to no more than 32: |
| 86 | +export OMP_NUM_THREADS=1 |
| 87 | + |
| 88 | +#! Number of MPI tasks to be started by the application per node and in total (do not change): |
| 89 | +np=$[${numnodes}*${mpi_tasks_per_node}] |
| 90 | + |
| 91 | +#! The following variables define a sensible pinning strategy for Intel MPI tasks - |
| 92 | +#! this should be suitable for both pure MPI and hybrid MPI/OpenMP jobs: |
| 93 | +export I_MPI_PIN_DOMAIN=omp:compact # Domains are $OMP_NUM_THREADS cores in size |
| 94 | +export I_MPI_PIN_ORDER=scatter # Adjacent domains have minimal sharing of caches/sockets |
| 95 | +#! Notes: |
| 96 | +#! 1. These variables influence Intel MPI only. |
| 97 | +#! 2. Domains are non-overlapping sets of cores which map 1-1 to MPI tasks. |
| 98 | +#! 3. I_MPI_PIN_PROCESSOR_LIST is ignored if I_MPI_PIN_DOMAIN is set. |
| 99 | +#! 4. If MPI tasks perform better when sharing caches/sockets, try I_MPI_PIN_ORDER=compact. |
| 100 | + |
| 101 | + |
| 102 | +#! Uncomment one choice for CMD below (add mpirun/mpiexec options if necessary): |
| 103 | + |
| 104 | +#! Choose this for a MPI code (possibly using OpenMP) using Intel MPI. |
| 105 | +#CMD="mpirun -ppn $mpi_tasks_per_node -np $np $application $options" |
| 106 | +#CMD="mpiexec -trace -np $np python $application $options" |
| 107 | +CMD="mpiexec -np $np python $application $options" |
| 108 | +#CMD="mpirun -ppn $mpi_tasks_per_node -np $np $application $options" |
| 109 | +#mpi_tasks_per_node=$[${mpi_tasks_per_node}/2] |
| 110 | +#CMD2="mpirun -ppn $mpi_tasks_per_node -np $np $application $options" |
| 111 | + |
| 112 | +#! Choose this for a pure shared-memory OpenMP parallel program on a single node: |
| 113 | +#! (OMP_NUM_THREADS threads will be created): |
| 114 | +#CMD="$application $options" |
| 115 | + |
| 116 | +#! Choose this for a MPI code (possibly using OpenMP) using OpenMPI: |
| 117 | +#CMD="mpirun -npernode $mpi_tasks_per_node -np $np $application $options" |
| 118 | + |
| 119 | + |
| 120 | +############################################################### |
| 121 | +### You should not have to change anything below this line #### |
| 122 | +############################################################### |
| 123 | + |
| 124 | +cd $workdir |
| 125 | +echo -e "Changed directory to `pwd`.\n" |
| 126 | + |
| 127 | +JOBID=$SLURM_JOB_ID |
| 128 | + |
| 129 | +echo -e "JobID: $JOBID\n======" |
| 130 | +echo "Time: `date`" |
| 131 | +echo "Running on master node: `hostname`" |
| 132 | +echo "Current directory: `pwd`" |
| 133 | + |
| 134 | +if [ "$SLURM_JOB_NODELIST" ]; then |
| 135 | + #! Create a machine file: |
| 136 | + export NODEFILE=`generate_pbs_nodefile` |
| 137 | + cat $NODEFILE | uniq > machine.file.$JOBID |
| 138 | + echo -e "\nNodes allocated:\n================" |
| 139 | + echo `cat machine.file.$JOBID | sed -e 's/\..*$//g'` |
| 140 | +fi |
| 141 | + |
| 142 | +echo -e "\nnumtasks=$numtasks, numnodes=$numnodes, mpi_tasks_per_node=$mpi_tasks_per_node (OMP_NUM_THREADS=$OMP_NUM_THREADS)" |
| 143 | + |
| 144 | +echo -e "\nExecuting command:\n==================\n$CMD\n" |
| 145 | + |
| 146 | +eval $CMD |
| 147 | +#echo -e "\nExecuting command:\n==================\n$CMD2\n" |
| 148 | +#eval $CMD2 |
0 commit comments