-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhpl.save
executable file
·327 lines (294 loc) · 8.46 KB
/
hpl.save
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#!/bin/bash
# FIXME - workaround for Singularity
export LD_LIBRARY_PATH="/opt/cuda-11.3/lib64/:/opt/intel/oneapi/mkl/2022.0.2/lib/intel64/:/opt/openmpi/lib/:${LD_LIBRARY_PATH}"
echo ${LD_LIBRARY_PATH}
# Global settings
export MONITOR_GPU=1
export GPU_TEMP_WARNING=78
export GPU_CLOCK_WARNING=1410
export GPU_POWER_WARNING=400
export GPU_PCIE_GEN_WARNING=3
export GPU_PCIE_WIDTH_WARNING=2
export TRSM_CUTOFF=9000000
export TEST_LOOPS=1
export MAX_H2D_MS=200
export MAX_D2H_MS=200
export OMP_PROC_BIND=TRUE
export OMP_PLACES=sockets
# HPL specific
export CUDA_DEVICE_MAX_CONNECTIONS=16 #HPL
export GPU_DGEMM_SPLIT=1.00 #HPL
export MKL_DEBUG_CPU_TYPE=5 #HPL
export TEST_SYSTEM_PARAMS=1 #HPL-AI=0
# HPL-AI specific
export USE_LP_GEMM=3
export PAD_LDA_ODD=64
export NUM_WORK_BUF=3
export FACT_GEMM_PRINT=0
export FACT_GEMM=1
export FACT_GEMM_MIN=0 #32
export TEST_SYSTEM_PARAMS_COUNT=0
usage() {
echo ""
echo "$(basename $0) [OPTION]"
# echo " --clock <string> comma seperated GPU memory and core clock"
# echo " settings"
echo " --config <string> name of config with preset options ('dgx-a100'),"
echo " or path to a shell file"
echo " --cpu-affinity <string> colon separated list of cpu index ranges"
echo " --cpu-cores-per-rank <num> number of threads per rank"
echo " --cuda-compat manually enable CUDA forward compatibility"
echo " --dat <string> path to HPL.dat"
echo " --gpu-affinity <string> colon separated list of gpu indices"
echo " --mem-affinity <string> colon separated list of memory indices"
echo " --ucx-affinity <string> colon separated list of UCX devices"
echo " --ucx-tls <string> UCX transport to use"
echo " --xhpl-ai use the HPL-AI-NVIDIA benchmark"
echo ""
echo "Either --config or the combination of --cpu-affinity, --cpu-cores-per-rank,"
echo "and --gpu-affinity is required."
echo ""
echo "Examples:"
echo " mpirun ... $(basename $0) --config dgx-a100"
echo " mpirun ... $(basename $0) --config /path/to/config.sh"
echo " mpirun ... $(basename $0) --cpu-affinity 0:0:0:0:1:1:1:1 --cpu-cores-per-rank 4 --gpu-affinity 0:1:2:3:4:5:6:7"
}
info() {
local msg=$*
echo -e "INFO: ${msg}"
}
warning() {
local msg=$*
echo -e "WARNING: ${msg}"
}
error() {
local msg=$*
echo -e "ERROR: ${msg}"
exit 1
}
set_config() {
local config="$1"
if [ -z "${config}" ]; then
return 0
fi
case ${config} in
dgx-a100 )
CPU_AFFINITY="32-47:48-63:0-15:16-31:96-111:112-127:64-79:80-95"
CPU_CORES_PER_RANK=16
GPU_AFFINITY="0:1:2:3:4:5:6:7"
MEM_AFFINITY="2:3:0:1:6:7:4:5"
local num_hcas=$(find /sys/class/infiniband -maxdepth 1 -not -type d -print 2>/dev/null | wc -l)
if [ ${num_hcas} -eq 10 ]; then
# Slot 5 is not populated
NET_AFFINITY="mlx5_0:mlx5_1:mlx5_2:mlx5_3:mlx5_4:mlx5_5:mlx5_6:mlx5_7"
else
NET_AFFINITY="mlx5_0:mlx5_1:mlx5_2:mlx5_3:mlx5_6:mlx5_7:mlx5_8:mlx5_9"
fi
GPU_CLOCK="1380,1410"
;;
* )
if [ -f ${config} ]; then
source ${config}
else
error "unrecognized config: ${config}\nvalid preset config is 'dgx-a100', or a valid shell file"
fi
esac
}
read_rank() {
# Global rank
if [ -n "${OMPI_COMM_WORLD_RANK}" ]; then
RANK=${OMPI_COMM_WORLD_RANK}
elif [ -n "${PMIX_RANK}" ]; then
RANK=${PMIX_RANK}
elif [ -n "${PMI_RANK}" ]; then
RANK=${PMI_RANK}
elif [ -n "${SLURM_PROCID}" ]; then
RANK=${SLURM_PROCID}
else
warning "could not determine rank"
fi
# Node local rank
if [ -n "${OMPI_COMM_WORLD_LOCAL_RANK}" ]; then
LOCAL_RANK=${OMPI_COMM_WORLD_LOCAL_RANK}
elif [ -n "${SLURM_LOCALID}" ]; then
LOCAL_RANK=${SLURM_LOCALID}
else
error "could not determine local rank"
fi
}
# split the affinity string, e.g., '0:2:4:6' into an array,
# e.g., map[0]=0, map[1]=2, ... The array index is the MPI rank.
read_cpu_affinity_map() {
local affinity_string=$1
readarray -t CPU_AFFINITY_MAP <<<"$(tr ':' '\n'<<<"$affinity_string")"
}
# split the affinity string, e.g., '0:2:4:6' into an array,
# e.g., map[0]=0, map[1]=2, ... The array index is the MPI rank.
read_gpu_affinity_map() {
local affinity_string=$1
readarray -t GPU_AFFINITY_MAP <<<"$(tr ':' '\n'<<<"$affinity_string")"
}
# split the affinity string, e.g., '0:2:4:6' into an array,
# e.g., map[0]=0, map[1]=2, ... The array index is the MPI rank.
read_mem_affinity_map() {
local affinity_string=$1
readarray -t MEM_AFFINITY_MAP <<<"$(tr ':' '\n'<<<"$affinity_string")"
}
# split the affinity string, e.g., '0:2:4:6' into an array,
# e.g., map[0]=0, map[1]=2, ... The array index is the MPI rank.
read_net_affinity_map() {
local affinity_string=$1
readarray -t NET_AFFINITY_MAP <<<"$(tr ':' '\n'<<<"$affinity_string")"
}
# set PMIx client configuration to match the server
# enroot already handles this, so only do this under singularity
# https://github.com/NVIDIA/enroot/blob/master/conf/hooks/extra/50-slurm-pmi.sh
set_pmix() {
if [ -d /.singularity.d ]; then
if [ -n "${PMIX_PTL_MODULE-}" ] && [ -z "${PMIX_MCA_ptl-}" ]; then
export PMIX_MCA_ptl=${PMIX_PTL_MODULE}
fi
if [ -n "${PMIX_SECURITY_MODE-}" ] && [ -z "${PMIX_MCA_psec-}" ]; then
export PMIX_MCA_psec=${PMIX_SECURITY_MODE}
fi
if [ -n "${PMIX_GDS_MODULE-}" ] && [ -z "${PMIX_MCA_gds-}" ]; then
export PMIX_MCA_gds=${PMIX_GDS_MODULE}
fi
fi
}
### main script starts here
#XHPL="/home/benchmark/hpl-main-wyt/hpl-main/hpl-linux-x86_64/xhpl"
XHPL="./hpl-linux-x86_64/xhpl"
# Read command line arguments
while [ "$1" != "" ]; do
case $1 in
--clock )
if [ -n "$2" ]; then
GPU_CLOCK="$2"
else
usage
exit 1
fi
shift
;;
--config )
if [ -n "$2" ]; then
set_config $2
else
usage
exit 1
fi
shift
;;
--cpu-affinity )
if [ -n "$2" ]; then
CPU_AFFINITY="$2"
else
usage
exit 1
fi
shift
;;
--cpu-cores-per-rank )
if [ -n "$2" ]; then
CPU_CORES_PER_RANK="$2"
else
usage
exit 1
fi
shift
;;
--cuda-compat )
export LD_LIBRARY_PATH="/usr/local/cuda/compat:$LD_LIBRARY_PATH"
;;
--dat )
if [ -n "$2" ]; then
DAT="$2"
else
usage
exit 1
fi
shift
;;
--gpu-affinity )
if [ -n "$2" ]; then
GPU_AFFINITY="$2"
else
usage
exit 1
fi
shift
;;
--mem-affinity )
if [ -n "$2" ]; then
MEM_AFFINITY="$2"
else
usage
exit 1
fi
shift
;;
--ucx-affinity )
if [ -n "$2" ]; then
NET_AFFINITY="$2"
else
usage
exit 1
fi
shift
;;
--ucx-tls )
if [ -n "$2" ]; then
export UCX_TLS="$2"
else
usage
exit 1
fi
shift
;;
--xhpl-ai )
XHPL=/workspace/hpl-ai-linux-x86_64/xhpl_ai
;;
* )
usage
exit 1
esac
shift
done
# Setup PMIx, if using
if [[ -z "${SLURM_MPI_TYPE-}" || "${SLURM_MPI_TYPE}" == pmix* ]]; then
set_pmix
fi
if [ -z "$CPU_AFFINITY" ] || [ -z "${GPU_AFFINITY}" ]; then
error "necessary parameters not set, see $(basename $0) --help"
fi
# Figure out the right parameters for this particular rank
read_rank
read_cpu_affinity_map $CPU_AFFINITY
read_gpu_affinity_map $GPU_AFFINITY
read_mem_affinity_map $MEM_AFFINITY
read_net_affinity_map $NET_AFFINITY
CPU=${CPU_AFFINITY_MAP[$LOCAL_RANK]}
GPU=${GPU_AFFINITY_MAP[$LOCAL_RANK]}
MEM=${MEM_AFFINITY_MAP[$LOCAL_RANK]}
NET=${NET_AFFINITY_MAP[$LOCAL_RANK]}
if [ -z "$CPU" ] || [ -z "$GPU" ] || [ -z "$CPU_CORES_PER_RANK" ]; then
error "cpu and/or gpu values not set"
fi
if [ -z "$DAT" ]; then
error "DAT file not provided"
fi
# if [ $LOCAL_RANK -eq 0 ]; then
# sudo nvidia-smi -lgc ${GPU_CLOCK}
# fi
export CUDA_VISIBLE_DEVICES=${GPU}
export OMP_NUM_THREADS=${CPU_CORES_PER_RANK}
export MKL_NUM_THREADS=${CPU_CORES_PER_RANK}
if [ -n "${NET}" ]; then
export UCX_NET_DEVICES="$NET:1"
fi
if [ -n "${MEM}" ]; then
MEMBIND="--membind=${MEM}"
fi
info "host=$(hostname) rank=${RANK} lrank=${LOCAL_RANK} cores=${CPU_CORES_PER_RANK} gpu=${GPU} cpu=${CPU} mem=${MEM} net=${UCX_NET_DEVICES} bin=$XHPL"
numactl --cpunodebind=${CPU} ${MEMBIND} ${XHPL} ${DAT}