test.sh 3.87 KB
Newer Older
German Leon's avatar
German Leon committed
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
!/bin/bash

dir=`grep ^"dir = " config.py | cut -d"\"" -f2`
name=`grep ^"exeFile = " config.py | cut -d"\"" -f2`
size=`grep ^"size = " config.py | cut -d"\"" -f2`
#blk=`grep ^"blk =" config.py | cut -d"\"" -f2`
totalFiNumber=`grep ^"totalFiNumber = " config.py | cut -d"=" -f2`
cpufreq=`grep ^"cpufreq = " config.py | cut -d"=" -f2`
gpufreq=`grep ^"gpufreq = " config.py | cut -d"=" -f2`
PATH=${MYHOME}/bin:$PATH
rm -f goldens
ln -s ${dir}/goldens goldens

rm -f ${name}
ln -s ${dir}/${name} ${name}


echo >> results/res.out
echo "==================================" >> results/res.out
echo `date` >> results/res.out
echo "Experiment: " $name " size: " $size " cpufreq: " $cpufreq  "gpufreq: " $gpufreq >> results/res.out
echo "==================================" >> results/res.out
echo >> results/res.out


if [ ${cpufreq} -ne -1 ]
then
#  echo "initial CPUfreq: " `cpufreq-info | grep "current CPU" | cut -d"s" -f2 | cut -d"(" -f1` > ./results/res.out
  sudo cpufreq-set -c 0 -d ${cpufreq} -u ${cpufreq}
  echo "CPUfreq set to: " `cpufreq-info | grep "current CPU" | cut -d"s" -f2 | cut -d"(" -f1` >> results/res.out
  echo "CPUfreq set to: " `cpufreq-info | grep "current CPU" | cut -d"s" -f2 | cut -d"(" -f1` > /dev/ttyS0
fi

if [ ${gpufreq} -ne -1 ]
then
#  echo "initial GPUfreq: " `/home/buntu/bin/gpufreq-info` >> ./results/res.out
  echo "Setting GPUFreq to: " ${gpufreq} >> results/res.out
  sudo ${MYHOME}/bin/gpufreq-set ${gpufreq}
  echo "GPUfreq set to: " `gpufreq-info` >> results/res.out
fi

if [ -f "lastFiNumber" ]
then # por si hemos rearrancado el test.sh sin acabar el anterior
  fiNumber=$((`cat lastFiNumber` + 1))
else
  fiNumber=1
fi

#if [ -f "lastFiNumber" ]
#then
#  rm lastFiNumber
#fi

sudo killall iamalive_ini
sudo ${MYHOME}/bin/iamalive > /dev/ttyS0 &

if [ $totalFiNumber -eq -1 ]
then
  forever=1
else
  forever=0
fi

tIni=`date +%H%M%S`
###########  WARMING, WARMING ################ 
./${name} -s  ${size}  -v
###########  WARMING, WARMING ################ 

if [ ${gpufreq} -ne -1 ]
then
#  echo "initial GPUfreq: " `/home/ubuntu/bin/gpufreq-info` >> ./results/res.out
  echo "After warming. Setting GPUFreq to: " ${gpufreq} >> results/res.out
  sudo ${MYHOME}/bin/gpufreq-set ${gpufreq}
  echo "GPUfreq set to: " `gpufreq-info` >> results/res.out
fi

while [ $forever -eq 1 ]  || [ $fiNumber -le $totalFiNumber ]
do
  tIni=`date +%H%M%S`

  if [ $gpufreq -eq -1 ]
  then
    sufix=""
  else
    g=`${MYHOME}/bin/gpufreq-info`
    sufix="_"${g%"000000"}
  fi

  fileName=${name}"_"${size}${sufix}
  echo $fileName >> results/res.out
  echo "===========" >> results/res.out
#  fileName=${name}"_"${size}"_b"${blk}

#  gzip -f results/*.log
#  gzip -f results/*.tar

  if [ $# -eq 1 ] # parametro gdb
  then
    ./test_gdb.py $fileName $fiNumber $tIni #| tee ./results/${fileName}_${tIni}.out
  else
    ./test.py $fileName $fiNumber $tIni #| tee  ./results/${fileName}_${tIni}.out
  fi

  echo "GPUfreq after test: " `gpufreq-info` >> results/res.out
  echo "===========" >> results/res.out

  status=$?

  if [ $status -eq 3 ]  # tres timeouts seguidos
  then
    sudo reboot now
    sleep 30 
    sudo reboot now
    exit 1
  elif [ $status -eq 2 ]  # interrupcion por teclado del test
  then
    fiNumber=$totalFiNumber + 1 # provocar el fin del test
    forever=0
  else 
    fiNumber=$((`cat lastFiNumber` + 1))
#    pgrep $name
#    kill -9 `pgrep $name`
#    echo "Relaunching test after " $fiNumber " iterations."
  fi
done # end while

if [ $cpufreq -ne -1 ]
then
  # coloca la CPU a la maxima frecuencia
  sudo cpufreq-set -c 0 -d 2065500 -u 2065500
fi

sudo killall iamalive
sudo iamalive_ini 120 10 &
sudo killall -2 reset
echo "Status after while loop: " $status

if [ -f "lastFiNumber" ]
then
  echo "Delete lastFiNumber. Reset index" > /dev/ttyS0
  sudo rm lastFiNumber
fi

#if [ $status != 2 ] # si no se ha interrumpido por teclado
#then
mv ${MYHOME}/startup_script.sh ${MYHOME}/startup_script_noactivo.sh
#fi