Skip to content

Commit 30b57ee

Browse files
committed
auto KMP setting with HT
1 parent d34780e commit 30b57ee

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

benchmark/paddle/image/run_mkldnn.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ set -e
22

33
function train() {
44
unset OMP_NUM_THREADS MKL_NUM_THREADS
5-
export OMP_DYNAMIC="FALSE"
6-
# TODO(TJ): auto 1.0 or 0,0 for HT on or off
7-
export KMP_AFFINITY="granularity=fine,compact,0,0"
85
topology=$1
96
layer_num=$2
107
bs=$3
@@ -42,6 +39,17 @@ if [ ! -d "logs" ]; then
4239
mkdir logs
4340
fi
4441

42+
total_cores=`ls -l /sys/devices/system/cpu/ | grep "cpu[0-9]*$" | wc -l`
43+
online_cores=`cat /sys/devices/system/cpu/cpu*/online | grep -o '1' | wc -l`
44+
if [ $online_cores -eq $total_cores ]; then
45+
echo "Hyper Threading is ON"
46+
export KMP_AFFINITY="granularity=fine,compact,1,0"
47+
else
48+
echo "Hyper Threading is OFF"
49+
export OMP_DYNAMIC="FALSE"
50+
export KMP_AFFINITY="granularity=fine,compact,0,0"
51+
fi
52+
4553
for use_mkldnn in True False; do
4654
for batchsize in 64 128 256; do
4755
# vgg-19 and vgg-16

0 commit comments

Comments
 (0)