CheckRun.sh 3.75 KB
Newer Older
1
2
3
4
5
6
7
8
9
#!/bin/bash

dir="/home/martini/malleability_benchmark/"
codeDir="Codes/"
execDir="Exec/"
ResultsDir="Results/"

ResultsDirName=$1
maxIndex=$2
10
cantidadGrupos=$3 #Contando a los padres
11
12
totalEjGrupo=$4 #Total de ejecuciones por grupo
maxTime=$5 #Maximo tiempo que se considera válido
13

14
15
16
17
18
19
20
if [ $# -lt 3 ]
then
  echo "Faltan argumentos"
  echo "Uso -> bash CheckRun NombreDirectorio IndiceMaximo Grupos"
  exit -1
fi

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
cd $dir$ResultsDir
if [ ! -d $ResultsDirName ]
then
  echo "La carpeta de resultados $ResultsDirName no existe. Abortando"
  exit -1
fi
cd $ResultsDirName

#Comprobar si hay errores
#Si los hay, salir
grep -i -e fatal -e error -e abort -e == */slurm* > errores2.txt
qty=$(wc -l errores2.txt | cut -d ' ' -f1)

if [ $qty -gt 0 ]
then
  echo "Se han encontrado errores de ejecución graves. Abortando"
37
  echo "Revisar archivo errores2.txt en el directorio $ResultsDirName"
38
39
40
41
  exit -2
fi
rm errores2.txt

42
43
44
45
46
47
qtyG=$(ls R*/R*_Global.out | wc -l)
qtyG=$(($qtyG * 2))
qtyL=$(ls R*/R*_G?N*.out | wc -l)
if [ $qtyG == $qtyL ]
then
  echo "El numero de ficheros G($qtyG) y L($qtyL) coincide"
48
49
else
  #Si faltan archivos, se indican cuales faltan
50
  echo "Faltan ejecuciones Locales o globales"
51
52
53
54
55
56
57
58
59
60
61
  for ((i=1; i<$maxIndex; i++))
  do
    qtyEx=$(grep Tex -r Run$i | wc -l)
    qtyIt=$(grep Top -r Run$i | wc -l)
    qtyEx=$(($qtyEx * 2))
    if [ $qtyEx -ne $qtyIt ] 
    then
      diff=$(($totalEjGrupo-$qtyEx))
      echo "Faltan archivos en Run$i"
    fi
  done
62
63
64
  exit -1
fi

65
66
#grep -rn "2.\." R* TODO Testear que el tiempo teorico maximo es valido?

67
68
69
70
71
72
73
74
#Comprobar si hay runs con tiempo negativos
#Si los hay, reejecutar e informar de cuales son
grep - */R* | grep Tex > errores.txt
qty=$(wc -l errores.txt | cut -d ' ' -f1)
if [ $qty -gt 0 ]
then
  echo "Se han encontrado errores de ejecución leves. Volviendo a ejecutar"

75
  while IFS="" read -r lineRun || [ -n "$lineRun" ]
76
  do
77
    #Obtener datos de una ejecución erronea
78
    run=$(echo $lineRun | cut -d 'R' -f3 | cut -d '_' -f1)
79
    if [ $run -gt $maxIndex ]
80
    then #Indice de ejecuciones posteriores echas a mano -- FIXME Eliminar?
81
82
83
84
85
86
87
      realRun=$(($run - $maxIndex))
      index=$run
    else # Indice de las primeras ejecuciones
      realRun=$run
      index=$(($run + $maxIndex))
    fi

88
    echo "Run $run"
89
90
91
92
93
94
95
96
97
98
99
100
101
102
    cd Run$realRun

    #Arreglar ejecuccion

    #1 - Borrar lineas erroneas
    qty=$(grep -n - R* | grep Tex | wc -l)
    for ((i=0; i<qty; i++))
    do 
      fin=$(grep -n - R* | grep Tex | cut -d ':' -f2 | head -n1)
      init=$(($fin - 6))
      sed -i ''$init','$fin'd' R${realRun}_Global.out

      aux=$(($fin / 7)) #Utilizado para saber de entre las ejecuciones del fichero, cual es la erronea
      fin=$(($aux * 5))
103
      init=$(($fin - 4))
104
105
106
107
108
109
      for ((j=0; j<cantidadGrupos; j++)); do
        sed -i ''$init','$fin'd' R${realRun}_G${j}*
      done
    done

    #2 - Reelanzar ejecucion
110
111
112
113
114
115
116
117
118
119
120
121
    proc_list=$(grep Procs R${realRun}_Global.out | cut -d '=' -f3 | cut -d ',' -f1)
    proc_parents=$(echo $proc_list | cut -d ' ' -f1)
    proc_children=$(echo $proc_list | cut -d ' ' -f2)
    nodes=8 # Maximo actual
    if [ $procs_parents -gt $procs_children ]
    then
      nodes=$(($procs_parents / 20))
    else
      nodes=$(($procs_children / 20))
    fi

    sbatch -N $nodes $dir$execDir./singleRun.sh config$realRun.ini $index
122
123
    cd $dir$ResultsDir$ResultsDirName

124
  done < errores.txt
125
126
  exit 0
fi
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

#Comprobar que todas las ejecuciones tienen todas las ejecucciones que tocan
#Solo es necesario comprobar el global.
qty_missing=0
for ((i=1; i<$maxIndex; i++))
do
  qtyEx=$(grep Tex -r Run$i | wc -l)
  if [ $qtyEx -ne $totalEjGrupo ]
  then
    diff=$(($totalEjGrupo-$qtyEx))
    qty_missing=$(($qty_missing+1))
    echo "Faltan en $i, $diff ejecuciones"
  fi
done

if [ $qty_missing -eq 0 ]
then
  echo "Todos los archivos tienen $totalEjGrupo ejecuciones"
fi