eval_subdiv_smt.sh 5.79 KB
Newer Older
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
#!/bin/bash


##############################################################################
#                                                                            #
# SMT Interval Arithmetic Experiments for FMCAD 2018 paper                   #
# First run Daisy on all files found in the folder given as third argument   #
# certificates and log roundoff errors in a csv file.                        #
# Then benchmark each of the FloVer implementations by measuring runtime     #
# when checking the generated certificate.                                   #
#                                                                            #
##############################################################################

TIMECMD=""

unameOut="$(uname -s)"
case "${unameOut}" in
    Linux*)     TIMECMD=/usr/bin/time;;
    Darwin*)    TIMECMD=/usr/local/bin/time;;
    # CYGWIN*)    machine=Cygwin;;
    # MINGW*)     machine=MinGw;;
    # *)          machine="UNKNOWN:${unameOut}"
esac

#PROVERS=(coq hol4 binary)
PROVERS=(coq)

arr=()
while IFS=  read -r -d $'\0'; do
    arr+=("$REPLY")
# FIXME: Use a proper directory or a parameter?
done < <(find $3 -name "*.scala" -print0)

DATE=`date +%H%M%d%m%y`

mkdir /tmp/artifact_$DATE

#echo "Creating HOL4 heap for evaluation" >>$2
#cd ./hol4/output/
#Holmake heap >>$2
#cd ../../

#echo "Daisy Coq,  Daisy HOL4, Daisy Binary, Coq1, Coq2, Coq3, HOL4_1, HOL4_2, HOL4_3, CakeML1, CakeML2, CakeML3, Coqbin1, Coqbin2, Coqbin3" >>$1
echo "Daisy Coq, Coq1, Coq2, Coq3" >>$1

for file in "${arr[@]}"
do
  #Get the filename
  FILEPATH=${file/daisy\//.\/}
  FILE=${file/*\//}
  FILENAME=${FILE/.scala/}
  FILENAME=${FILENAME/Let/}
  PMAP=${FILE/scala/txt}
  CERTNAME="certificate_$FILENAME"
  # Generate a certificate with Daisy
  echo -n $FILENAME >>$1
  cd ./daisy
  if [ ! -f testcases/daisy-mixed-precision-maps/$PMAP ];
  then
      echo "Doing single precision eval for $FILENAME" >>$2
      for prv in "${PROVERS[@]}"
      do
          RESULT=$( { $TIMECMD -f ", %e" \
                                    ./daisy $FILEPATH --certificate=$prv \
                                    --rangeMethod=smt \
                                    --errorMethod=interval \
                                    --subdiv \
68
69
                                    --divLimit=5 \
                                    --totalOpt=150 \
70
71
72
73
74
75
76
77
78
79
80
81
82
83
                                    --results-csv=$FILENAME.csv \
                                    >>$2 \
                      ; } 2>&1 )
          echo -n $RESULT >> $1
      done
  else
      echo "Doing mixed-precision eval for $FILENAME" >>$2
      for prv in "${PROVERS[@]}"
      do
          RESULT=$( { $TIMECMD -f ", %e" \
                                    ./daisy $FILEPATH --certificate=$prv \
                                    --rangeMethod=smt \
                                    --errorMethod=interval \
                                    --subdiv \
84
85
                                    --divLimit=5 \
                                    --totalOpt=150 \
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
                                    --mixed-precision=testcases/daisy-mixed-precision-maps/$PMAP \
                                    --results-csv=$FILENAME.csv \
                                    >>$2 \
                      ; } 2>&1)
          echo -n $RESULT >> $1
      done
  fi

  mv ./output/$FILENAME.csv /tmp/artifact_$DATE

  cd ..

  #run coq checker 3 times
  echo "Working on Coq $CERTNAME" >>$2
  RESULT=$( { $TIMECMD -f ", %e" coqc -R ./coq Flover \
                            ./daisy/output/$CERTNAME.v; } 2>&1)
  echo -n $RESULT >>$1
  rm ./daisy/output/$CERTNAME.vo
  rm ./daisy/output/$CERTNAME.glob

  RESULT=$( { $TIMECMD -f ", %e" coqc -R ./coq Flover \
                            ./daisy/output/$CERTNAME.v; } 2>&1)
  echo -n $RESULT >>$1
  rm ./daisy/output/$CERTNAME.vo
  rm ./daisy/output/$CERTNAME.glob

  RESULT=$( { $TIMECMD -f ", %e" coqc -R ./coq Flover \
                            ./daisy/output/$CERTNAME.v; } 2>&1)
  echo -n $RESULT >>$1

#  #run HOL4 checker 3 times
#  cp ./daisy/output/*Script.sml ./hol4/output/
#  cd ./hol4/output/
#  echo "Working on $CERTNAME Theory.sig" >>$2
#  RESULT=$( { $TIMECMD -f "M1, %e M2" Holmake $CERTNAME"Theory.sig"; } 2>&1)
#  RESULT=${RESULT#*M1}
#  RESULT=${RESULT%%M2*}
#  echo -n $RESULT >>$1
#
#  rm ./certificate_*Theory*
#
#  RESULT=$( { $TIMECMD -f "M1, %e M2" Holmake $CERTNAME"Theory.sig"; } 2>&1)
#  RESULT=${RESULT#*M1}
#  RESULT=${RESULT%%M2*}
#  echo -n $RESULT >>$1
#
#  rm ./certificate_*Theory*
#
#  RESULT=$( { $TIMECMD -f "M1, %e M2" Holmake $CERTNAME"Theory.sig"; } 2>&1)
#  RESULT=${RESULT#*M1}
#  RESULT=${RESULT%%M2*}
#  echo -n $RESULT >>$1
#
#  rm ./certificate_*
#  cd ../../
#
#  #run HOL4 binary 3 times
#  echo "Working on CakeML $CERTNAME"
#  RESULT=$( { $TIMECMD -f ", %e" hol4/binary/cake_checker \
#                            ./daisy/output/certificate_*".txt" >>$2; } 2>&1)
#  echo -n $RESULT >>$1
#
#  RESULT=$( { $TIMECMD -f ", %e" hol4/binary/cake_checker \
#                            ./daisy/output/certificate_*".txt" >>$2; } 2>&1)
#  echo -n $RESULT >>$1
#
#  RESULT=$( { $TIMECMD -f ", %e" hol4/binary/cake_checker \
#                            ./daisy/output/certificate_*".txt" >>$2; } 2>&1)
#  echo -n $RESULT >>$1
#
#  # #run Coq binary
#  echo "Working on Coq binary $CERTNAME"
#  RESULT=$( { $TIMECMD -f ", %e" coq/binary/coq_checker_native \
#                            ./daisy/output/certificate_*".txt" >>$2; } 2>&1)
#
#  echo $RESULT >>$1
#
#  RESULT=$( { $TIMECMD -f ", %e" coq/binary/coq_checker_native \
#                            ./daisy/output/certificate_*".txt" >>$2; } 2>&1)
#
#  echo $RESULT >>$1
#
#  RESULT=$( { $TIMECMD -f ", %e" coq/binary/coq_checker_native \
#                            ./daisy/output/certificate_*".txt" >>$2; } 2>&1)
#
#  echo $RESULT >>$1

  echo "" >>$1
  mv ./daisy/output/certificate_* /tmp/artifact_$DATE/

done