未验证 提交 04bfed66 编写于 作者: T Tao Luo 提交者: GitHub

Merge pull request #7413 from tensor-tang/v1mac

enbale auto set env of V1 on Mac
......@@ -49,7 +49,18 @@ function cpu_config() {
if [ "@WITH_MKL@" == "OFF" ]; then
return 0
fi
platform="`uname -s`"
ht=0
if [ $platform == "Linux" ]; then
ht=`lscpu |grep "per core"|awk -F':' '{print $2}'|xargs`
elif [ $platform == "Darwin" ]; then
if [`sysctl -n hw.physicalcpu` -eq `sysctl -n hw.logicalcpu`]; then
# HT is OFF
ht=1
fi
else
return 0
fi
if [ $ht -eq 1 ]; then # HT is OFF
if [ -z "$KMP_AFFINITY" ]; then
export KMP_AFFINITY="granularity=fine,compact,0,0"
......@@ -72,7 +83,15 @@ function threads_config() {
# according to trainer_count and total processors
# only when MKL enabled
# auto set OPENBLAS_NUM_THREADS when do not use MKL
platform="`uname -s`"
processors=0
if [ $platform == "Linux" ]; then
processors=`grep "processor" /proc/cpuinfo|sort -u|wc -l`
elif [ $platform == "Darwin" ]; then
processors=`sysctl -n hw.logicalcpu`
else
return 0
fi
trainers=`grep -Eo 'trainer_count.[0-9]+' <<< "$@" |grep -Eo '[0-9]+'|xargs`
if [ -z $trainers ]; then
trainers=1
......@@ -148,11 +167,7 @@ else:
sys.exit(0)
EOF
if [ "`uname -s`" == "Linux" ]; then
# only support on linux yet, with mac can use v2
cpu_config
fi
cpu_config
# echo $KMP_AFFINITY $OMP_DYNAMIC
case "$1" in
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册