From 30b57eef402c2919c923b710ba0254f14d57055d Mon Sep 17 00:00:00 2001 From: tensor-tang Date: Tue, 7 Nov 2017 11:51:23 +0800 Subject: [PATCH] auto KMP setting with HT --- benchmark/paddle/image/run_mkldnn.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/benchmark/paddle/image/run_mkldnn.sh b/benchmark/paddle/image/run_mkldnn.sh index 4a196015073..68f3747e030 100755 --- a/benchmark/paddle/image/run_mkldnn.sh +++ b/benchmark/paddle/image/run_mkldnn.sh @@ -2,9 +2,6 @@ set -e function train() { unset OMP_NUM_THREADS MKL_NUM_THREADS - export OMP_DYNAMIC="FALSE" - # TODO(TJ): auto 1.0 or 0,0 for HT on or off - export KMP_AFFINITY="granularity=fine,compact,0,0" topology=$1 layer_num=$2 bs=$3 @@ -42,6 +39,17 @@ if [ ! -d "logs" ]; then mkdir logs fi +total_cores=`ls -l /sys/devices/system/cpu/ | grep "cpu[0-9]*$" | wc -l` +online_cores=`cat /sys/devices/system/cpu/cpu*/online | grep -o '1' | wc -l` +if [ $online_cores -eq $total_cores ]; then + echo "Hyper Threading is ON" + export KMP_AFFINITY="granularity=fine,compact,1,0" +else + echo "Hyper Threading is OFF" + export OMP_DYNAMIC="FALSE" + export KMP_AFFINITY="granularity=fine,compact,0,0" +fi + for use_mkldnn in True False; do for batchsize in 64 128 256; do # vgg-19 and vgg-16 -- GitLab