-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-machfile.sh
executable file
·50 lines (41 loc) · 1.36 KB
/
generate-machfile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Generate a machinefile for a job running in the Taito-mic cluster.
if !(( $# ))
then
echo "Usage: ./generate-machfile.sh <machfile>"
echo " Environmental variables used:"
echo " MPIRUN -- command to launch MPI jobs (default: mpirun)"
echo " HOST_PPN -- no. of MPI tasks on host CPUs (default: 1)"
echo " MIC_PPN -- no. of MPI tasks per MIC card (default: 12)"
echo " NODES (optional) -- number of nodes to use, if unset"
echo " SLURM_NNODES will be used"
echo " MICS (optional) -- no. of MICs to use, if unset will assume a"
echo " dual-socket layout"
exit
fi
OUTPUT=$1
host=tmp.hostfile
mach=tmp.machfile
[[ ${MPIRUN:+x} ]] || MPIRUN=mpirun
[[ ${NODES:+x} ]] || NODES=$SLURM_NNODES
[[ ${MICS:+x} ]] || MICS=(0 1)
[[ ${HOST_PPN:+x} ]] || HOST_PPN=1
[[ ${MIC_PPN:+x} ]] || MIC_PPN=12
echo "Generating a machinefile for $NODES MIC nodes"
echo " using offload devices (${MICS[@]})"
echo " with $HOST_PPN and $MIC_PPN MPI tasks on each host CPU and MIC card, respectively."
$MPIRUN -n $NODES -ppn 1 hostname > $host
cat $host | sort | uniq > $mach
if [ -e $OUTPUT ]
then
rm $OUTPUT
fi
for i in $(cat $mach)
do
for d in ${MICS[@]}
do
echo ${i}-mic${d}:${MIC_PPN} >> $OUTPUT
echo ${i}:${HOST_PPN} >> $OUTPUT
done
done
(( $DEBUG )) || rm $host $mach