1
- #! /usr/bin/env python
2
- # -*- coding: utf-8 -*-
1
+ #!/usr/bin/env python3
3
2
4
3
5
4
###############################################################################
6
5
# lapack_testing.py
7
6
###############################################################################
8
7
9
- from __future__ import print_function
10
8
from subprocess import Popen , STDOUT , PIPE
11
9
import os , sys , math
12
10
import getopt
13
11
# Arguments
14
12
try :
15
13
opts , args = getopt .getopt (sys .argv [1 :], "hd:b:srep:t:n" ,
16
- ["help" , "dir" , "bin" , "short" , "run" , "error" ,"prec=" ,"test=" ,"number" ])
14
+ ["help" , "dir= " , "bin= " , "short" , "run" , "error" ,"prec=" ,"test=" ,"number" ])
17
15
18
16
except getopt .error as msg :
19
17
print (msg )
20
18
print ("for help use --help" )
21
19
sys .exit (2 )
22
20
23
- short_summary = 0
24
- with_file = 1
25
- just_errors = 0
21
+ short_summary = False
22
+ with_file = True
23
+ just_errors = False
26
24
prec = 'x'
27
25
test = 'all'
28
- only_numbers = 0
26
+ only_numbers = False
29
27
test_dir = 'TESTING'
30
28
bin_dir = 'bin/Release'
31
29
34
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]" )
35
33
print (" - h is to print this message" )
36
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" )
37
- print (" - d [dir] is to indicate where is the LAPACK testing directory (.out files). By default, the script will use ." )
38
- print (" - b [bin] is to indicate where is the LAPACK binary files are located . By default, the script will use ." )
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 ) )
39
37
print (" LEVEL OF OUTPUT" )
40
- print (" - x is to print a detailed summary" )
41
38
print (" - e is to print only the error summary" )
42
39
print (" - s is to print a short summary" )
43
40
print (" - n is to print the numbers of failing tests (turn on summary mode)" )
63
60
print (" Will return the numbers of failed tests in REAL precision by running the LAPACK Tests then analyzing the output" )
64
61
print (" ./lapack_testing.py -n -p s -t eig " )
65
62
print (" Will return the numbers of failed tests in REAL precision by analyzing only the LAPACK output of EIGEN testings" )
66
- print ("Written by Julie Langou (June 2011) " )
67
63
sys .exit (0 )
68
64
else :
69
65
if o in ("-s" , "--short" ):
70
- short_summary = 1
66
+ short_summary = True
71
67
if o in ("-r" , "--run" ):
72
- with_file = 0
68
+ with_file = False
73
69
if o in ("-e" , "--error" ):
74
- just_errors = 1
70
+ just_errors = True
75
71
if o in ( '-p' , '--prec' ):
76
72
prec = a
77
73
if o in ( '-b' , '--bin' ):
81
77
if o in ( '-t' , '--test' ):
82
78
test = a
83
79
if o in ( '-n' , '--number' ):
84
- only_numbers = 1
85
- short_summary = 1
80
+ only_numbers = True
81
+ short_summary = True
86
82
87
83
# process options
88
84
89
- abs_bin_dir = os .path .normpath ( os . path . join ( os . getcwd (), bin_dir ) )
85
+ abs_bin_dir = os .path .abspath ( bin_dir )
90
86
91
87
os .chdir (test_dir )
92
88
@@ -108,7 +104,7 @@ def run_summary_test( f, cmdline, short_summary):
108
104
nb_test_illegal = 0
109
105
nb_test_info = 0
110
106
111
- if ( with_file ) :
107
+ if with_file :
112
108
if not os .path .exists (cmdline ):
113
109
error_message = cmdline + " file not found"
114
110
r = 1
@@ -145,16 +141,16 @@ def run_summary_test( f, cmdline, short_summary):
145
141
whereisrun = words_in_line .index ("run)" )
146
142
nb_test_run += int (words_in_line [whereisrun - 2 ])
147
143
if (line .find ("out of" )!= - 1 ):
148
- if ( short_summary == 0 ) : print (line , end = ' ' )
144
+ if not short_summary : print (line , end = ' ' )
149
145
whereisout = words_in_line .index ("out" )
150
146
nb_test_fail += int (words_in_line [whereisout - 1 ])
151
147
if ((line .find ("illegal" )!= - 1 ) or (line .find ("Illegal" )!= - 1 )):
152
- if ( short_summary == 0 ): print (line , end = ' ' )
148
+ if not short_summary : print (line , end = ' ' )
153
149
nb_test_illegal += 1
154
150
if (line .find (" INFO" )!= - 1 ):
155
- if ( short_summary == 0 ): print (line , end = ' ' )
151
+ if not short_summary : print (line , end = ' ' )
156
152
nb_test_info += 1
157
- if ( with_file == 1 ) :
153
+ if with_file :
158
154
pipe .close ()
159
155
160
156
f .flush ();
@@ -169,7 +165,7 @@ def run_summary_test( f, cmdline, short_summary):
169
165
except IOError :
170
166
f = sys .stdout
171
167
172
- if ( short_summary == 0 ) :
168
+ if not short_summary :
173
169
print (" " )
174
170
print ("---------------- Testing LAPACK Routines ----------------" )
175
171
print (" " )
@@ -203,6 +199,8 @@ def run_summary_test( f, cmdline, short_summary):
203
199
range_prec = [1 ,3 ]
204
200
elif test == 'rfp' :
205
201
range_test = [18 ]
202
+ elif test == 'dmd' :
203
+ range_test = [20 ]
206
204
elif test == 'eig' :
207
205
range_test = list (range (16 ))
208
206
else :
@@ -219,7 +217,7 @@ def run_summary_test( f, cmdline, short_summary):
219
217
letter = dtypes [0 ][dtype ]
220
218
name = dtypes [1 ][dtype ]
221
219
222
- if ( short_summary == 0 ) :
220
+ if not short_summary :
223
221
print (" " )
224
222
print ("------------------------- %s ------------------------" % name )
225
223
print (" " )
@@ -231,19 +229,19 @@ def run_summary_test( f, cmdline, short_summary):
231
229
letter + "gd" ,letter + "sb" ,letter + "sg" ,
232
230
letter + "bb" ,"glm" ,"gqr" ,
233
231
"gsv" ,"csd" ,"lse" ,
234
- letter + "test" , letter + dtypes [0 ][dtype - 1 ]+ "test" ,letter + "test_rfp" ),
232
+ letter + "test" , letter + dtypes [0 ][dtype - 1 ]+ "test" ,letter + "test_rfp" , letter + "dmd" ),
235
233
("Nonsymmetric-Eigenvalue-Problem" , "Symmetric-Eigenvalue-Problem" , "Symmetric-Eigenvalue-Problem-2-stage" , "Singular-Value-Decomposition" ,
236
234
"Eigen-Condition" ,"Nonsymmetric-Eigenvalue" ,"Nonsymmetric-Generalized-Eigenvalue-Problem" ,
237
235
"Nonsymmetric-Generalized-Eigenvalue-Problem-driver" , "Symmetric-Eigenvalue-Problem" , "Symmetric-Eigenvalue-Generalized-Problem" ,
238
236
"Banded-Singular-Value-Decomposition-routines" , "Generalized-Linear-Regression-Model-routines" , "Generalized-QR-and-RQ-factorization-routines" ,
239
237
"Generalized-Singular-Value-Decomposition-routines" , "CS-Decomposition-routines" , "Constrained-Linear-Least-Squares-routines" ,
240
- "Linear-Equation-routines" , "Mixed-Precision-linear-equation-routines" ,"RFP-linear-equation-routines" ),
238
+ "Linear-Equation-routines" , "Mixed-Precision-linear-equation-routines" ,"RFP-linear-equation-routines" , "Dynamic-Mode-Decomposition" ),
241
239
(letter + "nep" , letter + "sep" , letter + "se2" , letter + "svd" ,
242
240
letter + "ec" ,letter + "ed" ,letter + "gg" ,
243
241
letter + "gd" ,letter + "sb" ,letter + "sg" ,
244
242
letter + "bb" ,letter + "glm" ,letter + "gqr" ,
245
243
letter + "gsv" ,letter + "csd" ,letter + "lse" ,
246
- letter + "test" , letter + dtypes [0 ][dtype - 1 ]+ "test" ,letter + "test_rfp" ),
244
+ letter + "test" , letter + dtypes [0 ][dtype - 1 ]+ "test" ,letter + "test_rfp" , letter + "dmd" ),
247
245
)
248
246
249
247
@@ -252,22 +250,25 @@ def run_summary_test( f, cmdline, short_summary):
252
250
# NEED TO SKIP SOME PRECISION (namely s and c) FOR PROTO MIXED PRECISION TESTING
253
251
if dtest == 17 and (letter == "s" or letter == "c" ):
254
252
continue
255
- if ( with_file == 1 ) :
253
+ if with_file :
256
254
cmdbase = dtests [2 ][dtest ]+ ".out"
257
255
else :
258
256
if dtest == 16 :
259
257
# LIN TESTS
260
- cmdbase = "LIN/ xlintst" + letter + " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
258
+ cmdbase = "xlintst" + letter + " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
261
259
elif dtest == 17 :
262
260
# PROTO LIN TESTS
263
- cmdbase = "LIN/ xlintst" + letter + dtypes [0 ][dtype - 1 ]+ " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
261
+ cmdbase = "xlintst" + letter + dtypes [0 ][dtype - 1 ]+ " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
264
262
elif dtest == 18 :
265
263
# PROTO LIN TESTS
266
- cmdbase = "LIN/xlintstrf" + letter + " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
264
+ cmdbase = "xlintstrf" + letter + " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
265
+ elif dtest == 20 :
266
+ # DMD EIG TESTS
267
+ cmdbase = "xdmdeigtst" + letter + " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
267
268
else :
268
269
# EIG TESTS
269
- cmdbase = "EIG/ xeigtst" + letter + " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
270
- if ( not just_errors and not short_summary ) :
270
+ cmdbase = "xeigtst" + letter + " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
271
+ if not just_errors and not short_summary :
271
272
print ("Testing " + name + " " + dtests [1 ][dtest ]+ "-" + cmdbase , end = ' ' )
272
273
# Run the process: either to read the file or run the LAPACK testing
273
274
nb_test = run_summary_test (f , cmdbase , short_summary )
@@ -277,19 +278,19 @@ def run_summary_test( f, cmdline, short_summary):
277
278
list_results [3 ][dtype ]+= nb_test [3 ]
278
279
got_error = nb_test [1 ]+ nb_test [2 ]+ nb_test [3 ]
279
280
280
- if ( not short_summary ) :
281
- if ( nb_test [0 ]> 0 and just_errors == 0 ) :
281
+ if not short_summary :
282
+ if nb_test [0 ] > 0 and not just_errors :
282
283
print ("passed: " + str (nb_test [0 ]))
283
- if ( nb_test [1 ]> 0 ) :
284
+ if nb_test [1 ] > 0 :
284
285
print ("failing to pass the threshold: " + str (nb_test [1 ]))
285
- if ( nb_test [2 ]> 0 ) :
286
+ if nb_test [2 ] > 0 :
286
287
print ("Illegal Error: " + str (nb_test [2 ]))
287
- if ( nb_test [3 ]> 0 ) :
288
+ if nb_test [3 ] > 0 :
288
289
print ("Info Error: " + str (nb_test [3 ]))
289
- if ( got_error > 0 and just_errors == 1 ) :
290
+ if got_error > 0 and just_errors :
290
291
print ("ERROR IS LOCATED IN " + name + " " + dtests [1 ][dtest ]+ " [ " + cmdbase + " ]" )
291
292
print ("" )
292
- if ( just_errors == 0 ) :
293
+ if not just_errors :
293
294
print ("" )
294
295
# elif (got_error>0):
295
296
# print dtests[2][dtest]+".out \t"+str(nb_test[1])+"\t"+str(nb_test[2])+"\t"+str(nb_test[3])
@@ -307,7 +308,7 @@ def run_summary_test( f, cmdline, short_summary):
307
308
list_results [2 ][4 ]+= list_results [2 ][dtype ]
308
309
list_results [3 ][4 ]+= list_results [3 ][dtype ]
309
310
310
- if only_numbers == 1 :
311
+ if only_numbers :
311
312
print (str (list_results [1 ][4 ])+ "\n " + str (list_results [2 ][4 ]+ list_results [3 ][4 ]))
312
313
else :
313
314
print (summary )
0 commit comments