-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen_job.sh
executable file
·202 lines (186 loc) · 6.52 KB
/
gen_job.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
source defaults.sh
## Output
BUILD=0
NSYS=0
NCU=0
RESULTS_DIR=$PWD/results/$(date +%F)/
GLOBAL_PROF_CMD=
while [ : ]; do
case "$1" in
--cells)
export CELLS=$2
shift 2
;;
--particles)
export PARTICLES=$2
shift 2
;;
--niters)
export ITERS=$2
shift 2
;;
--build)
export BUILD=1
shift
;;
--mpi_procs)
export MPI_PER_NODE=$2
shift 2
;;
--nodes)
export NODES=$2
shift 2
;;
--gpus)
export NGPUS=$2
shift 2
;;
--container)
export CONTAINER=$2
shift 2
;;
--results_name)
export RESULTS_DIR=$RESULTS_DIR/$2
shift 2
;;
--job_template)
export JOB_TEMPLATE=$2
shift 2
;;
--walltime)
export WALLTIME=$2
shift 2
;;
--enroot)
USE_ENROOT=1
shift
;;
--nsys)
NSYS=1
GLOBAL_PROF_CMD="$NSYS_CMD"
shift
;;
--ncu)
NCU=1
GLOBAL_PROF_CMD="$NCU_CMD"
shift
;;
--prof_ranks)
PROF_RANKS="$2"
shift 2
;;
--interactive)
export INTERACTIVE=1
export INTERACTIVE_RUN=1
shift
;;
--jump_into_container)
export INTERACTIVE=1
export INTERACTIVE_RUN=0
export USE_ENROOT=1
shift
;;
--no_container)
export NO_CONTAINER=1
shift
;;
--)
shift;
break
;;
esac
done
RANKS=$(( MPI_PER_NODE*NODES ))
PRANKS=$(( RANKS - NGPUS*NODES ))
FRANKS=$(( RANKS - PRANKS ))
print_config () {
rm -f $OUTFILE.log
echo "MiniCombust configuration: " | tee -a $OUTFILE.log
echo " nodes: $NODES" | tee -a $OUTFILE.log
echo " ngpus: $NGPUS" | tee -a $OUTFILE.log
echo " ranks: $RANKS" | tee -a $OUTFILE.log
echo " pranks: $PRANKS" | tee -a $OUTFILE.log
echo " franks: $FRANKS" | tee -a $OUTFILE.log
echo " mpi_procs_per_node: $MPI_PER_NODE" | tee -a $OUTFILE.log
echo " cells: $CELLS" | tee -a $OUTFILE.log
echo " particles: $PARTICLES" | tee -a $OUTFILE.log
echo " iters: $ITERS" | tee -a $OUTFILE.log
echo " container: $CONTAINER" | tee -a $OUTFILE.log
echo " results_dir: $RESULTS_DIR" | tee -a $OUTFILE.log
echo " job_template: $JOB_TEMPLATE" | tee -a $OUTFILE.log
echo " mount: $MOUNT" | tee -a $OUTFILE.log
echo " wdir: $WDIR" | tee -a $OUTFILE.log
echo " walltime: $WALLTIME" | tee -a $OUTFILE.log
echo " amgx_path: $AMGX_PATH" | tee -a $OUTFILE.log
echo " cuda_path: $CUDA_PATH" | tee -a $OUTFILE.log
echo " mpi_path: $MPI_PATH" | tee -a $OUTFILE.log
echo " profile_ranks: $PROF_RANKS" | tee -a $OUTFILE.log
echo " create_cmd: $CREATE_CMD" | tee -a $OUTFILE.log
echo " global_prof_cmd: $GLOBAL_PROF_CMD" | tee -a $OUTFILE.log
echo " inner_cmd: $INNER_CMD" | tee -a $OUTFILE.log
echo " outer_cmd: $OUTER_CMD" | tee -a $OUTFILE.log
echo ""
echo ""
}
mkdir -p $RESULTS_DIR
CREATE_CMD=""
INNER_CMD="./wrapper.sh ./bin/gpu_minicombust $PRANKS $PARTICLES $CELLS -1 $ITERS"
OUTER_CMD="source unset.sh; srun --overlap -N${NODES} --ntasks-per-node=${MPI_PER_NODE} --mem-bind=none --cpu-bind=none --mpi=pmix --container-image=${CONTAINER} --distribution=cyclic:cyclic --container-mounts=${MOUNT}:${MOUNT} bash -c"
if [ $USE_ENROOT -eq 1 ]
then
CREATE_CMD="enroot create --name minicombust -- $CONTAINER || true > /dev/null 2>&1 "
OUTER_CMD="enroot start --mount $MOUNT:$MOUNT minicombust bash -c"
INNER_CMD="mpirun -bind-to none -np ${RANKS} ${INNER_CMD}"
fi
if [ $BUILD -eq 1 ]
then
INNER_CMD="source build.sh"
OUTER_CMD="source unset.sh; srun --overlap -N1 --ntasks-per-node=1 --mem-bind=none --cpu-bind=none --mpi=pmix --container-image=${CONTAINER} --distribution=cyclic:cyclic --container-mounts=${MOUNT}:${MOUNT} bash -c"
fi
if [ $NO_CONTAINER -eq 1 ]
then
OUTER_CMD="bash -c"
fi
OUTFILE="$RESULTS_DIR/NODES${NODES}-RANKS$RANKS-GPUS$NGPUS-CELLS$CELLS-PARTICLES$PARTICLES-ITERS$ITERS"
if [ $NSYS -eq 1 ] || [ $NCU -eq 1 ];
then
GLOBAL_PROF_CMD="$GLOBAL_PROF_CMD -o $OUTFILE"
fi
print_config
cp $JOB_TEMPLATE $OUTFILE.job
sed -i "s/#NODES#/$NODES/g" $OUTFILE.job
sed -i "s/#NGPUS#/$NGPUS/g" $OUTFILE.job
sed -i "s/#MPI_PER_NODE#/$MPI_PER_NODE/g" $OUTFILE.job
sed -i "s@#OUTFILE#@$OUTFILE@g" $OUTFILE.job
sed -i "s@#CONTAINER#@$CONTAINER@g" $OUTFILE.job
sed -i "s@CREATE_CMD@$CREATE_CMD@g" $OUTFILE.job
sed -i "s@INNER_CMD@$INNER_CMD@g" $OUTFILE.job
sed -i "s@OUTER_CMD@$OUTER_CMD@g" $OUTFILE.job
sed -i "s@#WALLTIME#@$WALLTIME@g" $OUTFILE.job
sed -i "s@#RANKS#@$RANKS@g" $OUTFILE.job
sed -i "s@#PRANKS#@$PRANKS@g" $OUTFILE.job
sed -i "s@#CELLS#@$CELLS@g" $OUTFILE.job
sed -i "s@#PARTICLES#@$PARTICLES@g" $OUTFILE.job
sed -i "s@#ITERS#@$ITERS@g" $OUTFILE.job
sed -i "s@OUTFILE@$OUTFILE@g" $OUTFILE.job
sed -i "s@#AMGX_PATH#@$AMGX_PATH@g" $OUTFILE.job
sed -i "s@#MPI_PATH#@$MPI_PATH@g" $OUTFILE.job
sed -i "s@#CUDA_PATH#@$CUDA_PATH@g" $OUTFILE.job
sed -i "s@#PROF_CMD#@$GLOBAL_PROF_CMD@g" $OUTFILE.job
sed -i "s@#PROF_RANKS#@$PROF_RANKS@g" $OUTFILE.job
if [ $INTERACTIVE -eq 1 ]
then
if [ $INTERACTIVE_RUN -eq 1 ]
then
chmod +x $OUTFILE.job
bash $OUTFILE.job
else
echo "Running CREATE_CMD: $CREATE_CMD"
$CREATE_CMD
enroot start --mount $MOUNT minicombust
fi
else
echo "Submitting job"
sbatch $OUTFILE.job
fi