@@ -49,7 +49,18 @@ function cpu_config() {
49
49
if [ " @WITH_MKL@" == " OFF" ]; then
50
50
return 0
51
51
fi
52
- ht=` lscpu | grep " per core" | awk -F' :' ' {print $2}' | xargs`
52
+ platform=" ` uname -s` "
53
+ ht=0
54
+ if [ $platform == " Linux" ]; then
55
+ ht=` lscpu | grep " per core" | awk -F' :' ' {print $2}' | xargs`
56
+ elif [ $platform == " Darwin" ]; then
57
+ if [` sysctl -n hw.physicalcpu` -eq ` sysctl -n hw.logicalcpu` ]; then
58
+ # HT is OFF
59
+ ht=1
60
+ fi
61
+ else
62
+ return 0
63
+ fi
53
64
if [ $ht -eq 1 ]; then # HT is OFF
54
65
if [ -z " $KMP_AFFINITY " ]; then
55
66
export KMP_AFFINITY=" granularity=fine,compact,0,0"
@@ -72,7 +83,15 @@ function threads_config() {
72
83
# according to trainer_count and total processors
73
84
# only when MKL enabled
74
85
# auto set OPENBLAS_NUM_THREADS when do not use MKL
75
- processors=` grep " processor" /proc/cpuinfo| sort -u| wc -l`
86
+ platform=" ` uname -s` "
87
+ processors=0
88
+ if [ $platform == " Linux" ]; then
89
+ processors=` grep " processor" /proc/cpuinfo| sort -u| wc -l`
90
+ elif [ $platform == " Darwin" ]; then
91
+ processors=` sysctl -n hw.logicalcpu`
92
+ else
93
+ return 0
94
+ fi
76
95
trainers=` grep -Eo ' trainer_count.[0-9]+' <<< " $@" | grep -Eo ' [0-9]+' | xargs`
77
96
if [ -z $trainers ]; then
78
97
trainers=1
@@ -148,11 +167,7 @@ else:
148
167
sys.exit(0)
149
168
EOF
150
169
151
- if [ " ` uname -s` " == " Linux" ]; then
152
- # only support on linux yet, with mac can use v2
153
- cpu_config
154
- fi
155
-
170
+ cpu_config
156
171
# echo $KMP_AFFINITY $OMP_DYNAMIC
157
172
158
173
case " $1 " in
0 commit comments