8from subprocess
import Popen, STDOUT, PIPE
13 opts, args = getopt.getopt(sys.argv[1:],
"hd:b:srep:t:n",
14 [
"help",
"dir=",
"bin=",
"short",
"run",
"error",
"prec=",
"test=",
"number"])
16except getopt.error
as msg:
18 print(
"for help use --help")
31 if o
in (
"-h",
"--help"):
32 print(sys.argv[0]+
" [-h|--help] [-d dir |--dir dir] [-s |--short] [-r |--run] [-e |--error] [-p p |--prec p] [-t test |--test test] [-n | --number]")
33 print(
" - h is to print this message")
34 print(
" - r is to use to run the LAPACK tests then analyse the output (.out files). By default, the script will not run all the LAPACK tests")
35 print(
" - d [dir] indicates the location of the LAPACK testing directory (.out files). By default, the script will use {:s}.".format(test_dir))
36 print(
" - b [bin] indicates the location of the LAPACK binary files. By default, the script will use {:s}.".format(bin_dir))
37 print(
" LEVEL OF OUTPUT")
38 print(
" - e is to print only the error summary")
39 print(
" - s is to print a short summary")
40 print(
" - n is to print the numbers of failing tests (turn on summary mode)")
41 print(
" SECLECTION OF TESTS:")
42 print(
" - p [s/c/d/z/x] is to indicate the PRECISION to run:")
45 print(
" sd=single/double")
47 print(
" z=double complex")
48 print(
" cz=complex/double complex")
49 print(
" x=all [DEFAULT]")
50 print(
" - t [lin/eig/mixed/rfp/all] is to indicate which TEST FAMILY to run:")
51 print(
" lin=Linear Equation")
52 print(
" eig=Eigen Problems")
53 print(
" mixed=mixed-precision")
54 print(
" rfp=rfp format")
55 print(
" all=all tests [DEFAULT]")
57 print(
" ./lapack_testing.py -n")
58 print(
" Will return the numbers of failed tests by analyzing the LAPACK output")
59 print(
" ./lapack_testing.py -n -r -p s")
60 print(
" Will return the numbers of failed tests in REAL precision by running the LAPACK Tests then analyzing the output")
61 print(
" ./lapack_testing.py -n -p s -t eig ")
62 print(
" Will return the numbers of failed tests in REAL precision by analyzing only the LAPACK output of EIGEN testings")
65 if o
in (
"-s",
"--short"):
67 if o
in (
"-r",
"--run"):
69 if o
in (
"-e",
"--error"):
71 if o
in (
'-p',
'--prec' ):
73 if o
in (
'-b',
'--bin' ):
75 if o
in (
'-d',
'--dir' ):
77 if o
in (
'-t',
'--test' ):
79 if o
in (
'-n',
'--number' ):
85abs_bin_dir=os.path.abspath(bin_dir)
90summary=
"\n\t\t\t--> LAPACK TESTING SUMMARY <--\n";
91if with_file: summary+=
"\t\tProcessing LAPACK Testing output found in the "+test_dir+
" directory\n";
92summary+=
"SUMMARY \tnb test run \tnumerical error \tother error \n";
93summary+=
"================ \t===========\t=================\t================ \n";
98os.environ[
"PATH"] = os.environ[
"PATH"]+
":."
108 if not os.path.exists(cmdline):
109 error_message=cmdline+
" file not found"
111 if short_summary:
return [nb_test_run,nb_test_fail,nb_test_illegal,nb_test_info]
113 pipe = open(cmdline,
'r')
116 cmdline = os.path.join(abs_bin_dir, cmdline)
118 outfile=cmdline.split()[4]
120 p = Popen(cmdline, shell=
True)
124 pipe = open(outfile,
'r')
125 error_message=cmdline+
" did not work"
127 if r != 0
and not with_file:
128 print(
"---- TESTING " + cmdline.split()[0] +
"... FAILED(" + error_message +
") !")
129 for line
in pipe.readlines():
131 elif r != 0
and with_file
and not short_summary:
132 print(
"---- WARNING: please check that you have the LAPACK output : "+cmdline+
"!")
133 print(
"---- WARNING: with the option -r, we can run the LAPACK testing for you")
136 for line
in pipe.readlines():
138 words_in_line=line.split()
139 if (line.find(
"run")!=-1):
141 whereisrun=words_in_line.index(
"run)")
142 nb_test_run+=int(words_in_line[whereisrun-2])
143 if (line.find(
"out of")!=-1):
144 if not short_summary: print(line, end=
' ')
145 whereisout= words_in_line.index(
"out")
146 nb_test_fail+=int(words_in_line[whereisout-1])
147 if ((line.find(
"illegal")!=-1)
or (line.find(
"Illegal")!=-1)):
148 if not short_summary: print(line, end=
' ')
150 if (line.find(
" INFO")!=-1):
151 if not short_summary: print(line, end=
' ')
158 return [nb_test_run,nb_test_fail,nb_test_illegal,nb_test_info]
162filename =
"testing_results.txt"
164 f = open(filename,
'w')
170 print(
"---------------- Testing LAPACK Routines ----------------")
172 print(
"-- Detailed results are stored in", filename)
176(
"REAL ",
"DOUBLE PRECISION",
"COMPLEX ",
"COMPLEX16 "),
193 range_prec=list(range(4))
203 range_test=list(range(16))
205 range_test=list(range(19))
214for dtype
in range_prec:
215 letter = dtypes[0][dtype]
216 name = dtypes[1][dtype]
218 if not short_summary:
220 print(
"------------------------- %s ------------------------" % name)
225 (
"nep",
"sep",
"se2",
"svd",
226 letter+
"ec",letter+
"ed",letter+
"gg",
227 letter+
"gd",letter+
"sb",letter+
"sg",
228 letter+
"bb",
"glm",
"gqr",
230 letter+
"test", letter+dtypes[0][dtype-1]+
"test",letter+
"test_rfp"),
231 (
"Nonsymmetric-Eigenvalue-Problem",
"Symmetric-Eigenvalue-Problem",
"Symmetric-Eigenvalue-Problem-2-stage",
"Singular-Value-Decomposition",
232 "Eigen-Condition",
"Nonsymmetric-Eigenvalue",
"Nonsymmetric-Generalized-Eigenvalue-Problem",
233 "Nonsymmetric-Generalized-Eigenvalue-Problem-driver",
"Symmetric-Eigenvalue-Problem",
"Symmetric-Eigenvalue-Generalized-Problem",
234 "Banded-Singular-Value-Decomposition-routines",
"Generalized-Linear-Regression-Model-routines",
"Generalized-QR-and-RQ-factorization-routines",
235 "Generalized-Singular-Value-Decomposition-routines",
"CS-Decomposition-routines",
"Constrained-Linear-Least-Squares-routines",
236 "Linear-Equation-routines",
"Mixed-Precision-linear-equation-routines",
"RFP-linear-equation-routines"),
237 (letter+
"nep", letter+
"sep", letter+
"se2", letter+
"svd",
238 letter+
"ec",letter+
"ed",letter+
"gg",
239 letter+
"gd",letter+
"sb",letter+
"sg",
240 letter+
"bb",letter+
"glm",letter+
"gqr",
241 letter+
"gsv",letter+
"csd",letter+
"lse",
242 letter+
"test", letter+dtypes[0][dtype-1]+
"test",letter+
"test_rfp"),
246 for dtest
in range_test:
249 if dtest==17
and (letter==
"s" or letter==
"c"):
252 cmdbase=dtests[2][dtest]+
".out"
256 cmdbase=
"xlintst"+letter+
" < "+dtests[0][dtest]+
".in > "+dtests[2][dtest]+
".out"
259 cmdbase=
"xlintst"+letter+dtypes[0][dtype-1]+
" < "+dtests[0][dtest]+
".in > "+dtests[2][dtest]+
".out"
262 cmdbase=
"xlintstrf"+letter+
" < "+dtests[0][dtest]+
".in > "+dtests[2][dtest]+
".out"
265 cmdbase=
"xeigtst"+letter+
" < "+dtests[0][dtest]+
".in > "+dtests[2][dtest]+
".out"
266 if not just_errors
and not short_summary:
267 print(
"Testing "+name+
" "+dtests[1][dtest]+
"-"+cmdbase, end=
' ')
270 list_results[0][dtype]+=nb_test[0]
271 list_results[1][dtype]+=nb_test[1]
272 list_results[2][dtype]+=nb_test[2]
273 list_results[3][dtype]+=nb_test[3]
274 got_error=nb_test[1]+nb_test[2]+nb_test[3]
276 if not short_summary:
277 if nb_test[0] > 0
and not just_errors:
278 print(
"passed: "+str(nb_test[0]))
280 print(
"failing to pass the threshold: "+str(nb_test[1]))
282 print(
"Illegal Error: "+str(nb_test[2]))
284 print(
"Info Error: "+str(nb_test[3]))
285 if got_error > 0
and just_errors:
286 print(
"ERROR IS LOCATED IN "+name+
" "+dtests[1][dtest]+
" [ "+cmdbase+
" ]")
294 if (list_results[0][dtype] > 0 ):
295 percent_num_error=float(list_results[1][dtype])/float(list_results[0][dtype])*100
296 percent_error=float(list_results[2][dtype]+list_results[3][dtype])/float(list_results[0][dtype])*100
300 summary+=name+
"\t"+str(list_results[0][dtype])+
"\t\t"+str(list_results[1][dtype])+
"\t("+
"%.3f" % percent_num_error+
"%)\t"+str(list_results[2][dtype]+list_results[3][dtype])+
"\t("+
"%.3f" % percent_error+
"%)\t""\n"
301 list_results[0][4]+=list_results[0][dtype]
302 list_results[1][4]+=list_results[1][dtype]
303 list_results[2][4]+=list_results[2][dtype]
304 list_results[3][4]+=list_results[3][dtype]
307 print(str(list_results[1][4])+
"\n"+str(list_results[2][4]+list_results[3][4]))
310 if (list_results[0][4] > 0 ):
311 percent_num_error=float(list_results[1][4])/float(list_results[0][4])*100
312 percent_error=float(list_results[2][4]+list_results[3][4])/float(list_results[0][4])*100
317 print(
"--> ALL PRECISIONS\t"+str(list_results[0][4])+
"\t\t"+str(list_results[1][4])+
"\t("+
"%.3f" % percent_num_error+
"%)\t"+str(list_results[2][4]+list_results[3][4])+
"\t("+
"%.3f" % percent_error+
"%)\t""\n")
318 if list_results[0][4] == 0:
319 print(
"NO TESTS WERE ANALYZED, please use the -r option to run the LAPACK TESTING")
run_summary_test(f, cmdline, short_summary)