test.sh 3.86 KB
Newer Older
German Leon's avatar
German Leon committed
1
2
3
4
5
6
7
#!/bin/bash
if [ -z "${MYHOME}" ]
then	
	MYHOME=$HOME
fi
PYTHONPATH=/usr/bin
#dir=`grep ^"dir = " config.py | cut -d"\"" -f2`
German Leon's avatar
German Leon committed
8
name=`grep ^"exeFile = " config.py | cut -d"\"" -f2`
German Leon's avatar
German Leon committed
9
10
11
12
13
14
15
grid=`grep ^"grid = " config.py | cut -d"\"" -f2`
blk=`grep ^"blk =" config.py | cut -d"\"" -f2`
bench=`grep ^"bench =" config.py | cut -d"\"" -f2`
argcampo=`grep ^"duration =" config.py | cut -d"\"" -f2`

campo=`grep ^"scale =" config.py | cut -d"\"" -f2`

German Leon's avatar
German Leon committed
16
17
18
19
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
German Leon's avatar
German Leon committed
20
21
#rm -f goldens
#ln -s ${dir}/goldens goldens
German Leon's avatar
German Leon committed
22

German Leon's avatar
German Leon committed
23
24
#rm -f ${name}
#ln -s ${dir}/${name} ${name}
German Leon's avatar
German Leon committed
25
26
27
28
29


echo >> results/res.out
echo "==================================" >> results/res.out
echo `date` >> results/res.out
German Leon's avatar
German Leon committed
30
echo "Experiment: " $bench " grid: " $grid  " blk: " $blk  "cpufreq: " $cpufreq  "gpufreq: " $gpufreq $campo":" $argcampo>> results/res.out
German Leon's avatar
German Leon committed
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
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 "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
German Leon's avatar
German Leon committed
63
${MYHOME}/bin/iamalive.sh # > /dev/ttyS0 &
German Leon's avatar
German Leon committed
64
65
66
67
68
69
70
71
72

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

tIni=`date +%H%M%S`
German Leon's avatar
German Leon committed
73
# Tengo dudas
German Leon's avatar
German Leon committed
74
###########  WARMING, WARMING ################ 
German Leon's avatar
German Leon committed
75
#./${name} -s  ${size}  -v
German Leon's avatar
German Leon committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
###########  WARMING, WARMING ################ 

if [ ${gpufreq} -ne -1 ]
then
  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

German Leon's avatar
German Leon committed
97
  fileName=${bench}"_"${grid}"_b"${blk}"_"${sufix}
German Leon's avatar
German Leon committed
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
  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))
German Leon's avatar
German Leon committed
128
129
    fiNumber=$((`cat lastFiNumber` + 1))
    fiNumber=$((`cat lastFiNumber` + 1))
German Leon's avatar
German Leon committed
130
131
132
133
134
135
136
137
138
139
  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
German Leon's avatar
German Leon committed
140
${MYHOME}/bin/iamalive_ini.sh # 120 10 &
German Leon's avatar
German Leon committed
141
142
143
144
145
146
147
148
149
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