-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·65 lines (51 loc) · 1.91 KB
/
run.sh
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
### run script for the operator benchmark
#source activate pytorch-mingfei
# jemalloc:
export MALLOC_CONF="oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:-1,muzzy_decay_ms:-1";
export LD_PRELOAD=/home/mingfeim/packages/jemalloc-5.2.1/lib/libjemalloc.so
#
# tcmalloc:
#export LD_PRELOAD=/home/mingfeim/packages/gperftools-2.8/install/lib/libtcmalloc.so
if [ $# -lt 1 ]; then
echo "usage: ./run.sh [xxx.py] for inference"
echo " ./run.sh [xxx.py] --train for training"
exit
fi
INPUT_FILE=$1
CORES=`lscpu | grep Core | awk '{print $4}'`
SOCKETS=`lscpu | grep Socket | awk '{print $2}'`
TOTAL_CORES=`expr $CORES \* $SOCKETS`
LAST_CORE=`expr $CORES - 1`
#KMP_SETTING="KMP_AFFINITY=granularity=fine,compact,1,0"
KMP_BLOCKTIME=1
if [ $# -ge 2 ]; then
#export $KMP_SETTING
export KMP_BLOCKTIME=$KMP_BLOCKTIME
#echo -e "\n### using $KMP_SETTING"
echo -e "### using KMP_BLOCKTIME=$KMP_BLOCKTIME\n"
echo -e "\n### using OMP_NUM_THREADS=$CORES"
PREFIX="numactl --physcpubind=0-$LAST_CORE --membind=0"
echo -e "### using $PREFIX\n"
OMP_NUM_THREADS=$CORES $PREFIX python -u $INPUT_FILE --train
exit
fi
PREFIX="numactl --physcpubind=0-$LAST_CORE --membind=0"
#export $KMP_SETTING
export KMP_BLOCKTIME=$KMP_BLOCKTIME
#echo -e "\n### using $KMP_SETTING"
echo -e "### using KMP_BLOCKTIME=$KMP_BLOCKTIME\n"
## single socket test
echo -e "\n### using OMP_NUM_THREADS=$CORES"
PREFIX="numactl --physcpubind=0-$LAST_CORE --membind=0"
echo -e "### using $PREFIX\n"
OMP_NUM_THREADS=$CORES $PREFIX python -u $INPUT_FILE
### quad threads test
#echo -e "\n### using OMP_NUM_THREADS=4"
#PREFIX="numactl --physcpubind=0-3 --membind=0"
#echo -e "### using $PREFIX\n"
#OMP_NUM_THREADS=4 $PREFIX python -u $INPUT_FILE
### single thread test
#echo -e "\n### using OMP_NUM_THREADS=1"
#PREFIX="numactl --physcpubind=0 --membind=0"
#echo -e "### using $PREFIX\n"
#OMP_NUM_THREADS=1 $PREFIX python -u $INPUT_FILE