1 |
commit: edbbe2d009d1cc7139d30348694eac3274426306 |
2 |
Author: Andrea Arteaga <andyspiros <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Feb 20 19:53:54 2012 +0000 |
4 |
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com> |
5 |
CommitDate: Mon Feb 20 19:53:54 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=edbbe2d0 |
7 |
|
8 |
Fixed reports, added -d switchl, better failure checks. |
9 |
|
10 |
--- |
11 |
blastests.xml | 45 +++++++++++++++++++ |
12 |
numbench/PortageUtils.py | 55 ++++++++++++----------- |
13 |
numbench/benchconfig.py | 72 ++++++++++++------------------ |
14 |
numbench/confinput/xmlinput.py | 11 +++-- |
15 |
numbench/main.py | 23 +++++----- |
16 |
numbench/modules/internal/blasBase.py | 16 +++--- |
17 |
numbench/modules/internal/btlBase.py | 38 ++++++++++++---- |
18 |
numbench/modules/internal/lapackBase.py | 6 +- |
19 |
numbench/report.py | 47 +++++++++++--------- |
20 |
numbench/utils/btl.py | 2 +- |
21 |
10 files changed, 186 insertions(+), 129 deletions(-) |
22 |
|
23 |
diff --git a/blastests.xml b/blastests.xml |
24 |
new file mode 100644 |
25 |
index 0000000..75f5ba4 |
26 |
--- /dev/null |
27 |
+++ b/blastests.xml |
28 |
@@ -0,0 +1,45 @@ |
29 |
+<tests> |
30 |
+ <test id="reference"> |
31 |
+ <pkg>sci-libs/blas-reference-20120215-r1</pkg> |
32 |
+ <emergeenv> |
33 |
+ <var name="FFLAGS">-O3</var> |
34 |
+ </emergeenv> |
35 |
+ </test> |
36 |
+ |
37 |
+<!-- |
38 |
+ <test id="atlas"> |
39 |
+ <pkg>sci-libs/atlas-3.9.67</pkg> |
40 |
+ <emergeenv> |
41 |
+ <var name="USE">threads</var> |
42 |
+ </emergeenv> |
43 |
+ </test> |
44 |
+--> |
45 |
+ |
46 |
+ <test id="eigen"> |
47 |
+ <pkg>dev-cpp/eigen-3.0.5</pkg> |
48 |
+ <emergeenv> |
49 |
+ <var name="FFLAGS">-O3</var> |
50 |
+ </emergeenv> |
51 |
+ </test> |
52 |
+ |
53 |
+<!-- |
54 |
+ <test id="openblas"> |
55 |
+ <pkg>sci-libs/openblas-0.1_alpha2</pkg> |
56 |
+ <emergeenv> |
57 |
+ <var name="TARGET">NEHALEM</var> |
58 |
+ <var name="FFLAGS">-O3</var> |
59 |
+ </emergeenv> |
60 |
+ </test> |
61 |
+--> |
62 |
+ |
63 |
+ <test id="mkl"> |
64 |
+ <pkg>sci-libs/mkl-10.3.7.256</pkg> |
65 |
+ <skip>mkl32-dynamic</skip> |
66 |
+ <skip>mkl32-dynamic-openmp</skip> |
67 |
+ <skip>mkl32-gfortran</skip> |
68 |
+ <skip>mkl32-gfortran-openmp</skip> |
69 |
+ <skip>mkl32-intel</skip> |
70 |
+ <skip>mkl32-intel-openmp</skip> |
71 |
+ </test> |
72 |
+ |
73 |
+</tests> |
74 |
|
75 |
diff --git a/numbench/PortageUtils.py b/numbench/PortageUtils.py |
76 |
index abc2ce1..1da968d 100644 |
77 |
--- a/numbench/PortageUtils.py |
78 |
+++ b/numbench/PortageUtils.py |
79 |
@@ -26,7 +26,7 @@ class InstallException(Exception): |
80 |
self.package = package |
81 |
self.command = command |
82 |
self.logfile = logfile |
83 |
- |
84 |
+ |
85 |
def _getEnv(root='/', envAdds={}): |
86 |
#denv = os.environ.copy() |
87 |
denv = {} |
88 |
@@ -36,40 +36,40 @@ def _getEnv(root='/', envAdds={}): |
89 |
if os.environ.has_key('PATH'): |
90 |
denv['PATH'] += ':' + os.environ['PATH'] |
91 |
denv['ROOTPATH'] = denv['PATH'] |
92 |
- |
93 |
+ |
94 |
#LIBRARY_PATH |
95 |
denv['LIBRARY_PATH'] = ':'.join([pjoin(root, i) for i in \ |
96 |
('usr/lib', 'usr/lib64', 'usr/lib32')]) |
97 |
if os.environ.has_key('LIBRARY_PATH'): |
98 |
denv['LIBRARY_PATH'] += ':' + os.environ['LIBRARY_PATH'] |
99 |
- |
100 |
+ |
101 |
#LD_LIBRARY_PATH |
102 |
denv['LD_LIBRARY_PATH'] = ':'.join([pjoin(root, i) for i in \ |
103 |
('usr/lib', 'usr/lib64', 'usr/lib32')]) |
104 |
if os.environ.has_key('LD_LIBRARY_PATH'): |
105 |
denv['LD_LIBRARY_PATH'] += ':' + os.environ['LD_LIBRARY_PATH'] |
106 |
- |
107 |
+ |
108 |
#INCLUDE_PATH |
109 |
denv['INCLUDE_PATH'] = ':'.join([pjoin(root, i) for i in ('usr/include',)]) |
110 |
if os.environ.has_key('INCLUDE_PATH'): |
111 |
denv['INCLUDE_PATH'] += ':' + os.environ['INCLUDE_PATH'] |
112 |
- |
113 |
+ |
114 |
# Adds |
115 |
for k,v in envAdds.items(): |
116 |
denv[k] = v |
117 |
- |
118 |
+ |
119 |
return denv |
120 |
|
121 |
def availablePackages(pattern): |
122 |
"""Returns a list of packages matching the given pattern. |
123 |
- |
124 |
+ |
125 |
The packages are returned as (category, package, version, revision) tuple. |
126 |
No test for keywords or mask is performed. The function just returns |
127 |
every matching pattern in the portage tree and installed overlays. |
128 |
""" |
129 |
return [portage.catpkgsplit(l) \ |
130 |
for l in cmd.getoutput('equery -q list -po ' + pattern).split()] |
131 |
- |
132 |
+ |
133 |
def normalize_cpv(cpv): |
134 |
if type(cpv) == type(''): |
135 |
try: |
136 |
@@ -82,8 +82,8 @@ def normalize_cpv(cpv): |
137 |
return '%s/%s-%s-%s' % cpv |
138 |
else: |
139 |
return '%s/%s-%s' % cpv[:-1] |
140 |
- |
141 |
- |
142 |
+ |
143 |
+ |
144 |
def getDependencies(package, env={}, split=False): |
145 |
pkg = normalize_cpv(package) |
146 |
cmd = ['emerge', '--ignore-default-opts', '='+pkg, '-poq'] |
147 |
@@ -103,10 +103,10 @@ def getDependencies(package, env={}, split=False): |
148 |
def installDependencies(test): |
149 |
# Adjust environment |
150 |
denv = _getEnv(test['root'], dict(PKGDIR=test['pkgdir'])) |
151 |
- |
152 |
+ |
153 |
# Retrieve dependencies |
154 |
deps = getDependencies(test['package'], denv, False) |
155 |
- |
156 |
+ |
157 |
for i,d in enumerate(deps): |
158 |
logfile = pjoin(test['logdir'], 'emergedep_%i.log' % i) |
159 |
installPackage(test, package=d, env=test['dependenv'], logfile=logfile) |
160 |
@@ -117,20 +117,20 @@ def installDependencies(test): |
161 |
def installPackage(test, package=None, env=None, logfile=None): |
162 |
# TODO: rewrite docstring |
163 |
"""Emerge a package in the given root. |
164 |
- |
165 |
+ |
166 |
package is the package to be emerged. It has to be a tuple |
167 |
(category, package, version, revision). |
168 |
- |
169 |
+ |
170 |
env is a dictionary of KEY:VALUE pairs describing the environment changes |
171 |
the package will be emerged with. It is useful to specifiy the compilers and |
172 |
compiler flags. It is safe to use ACCEPT_KEYWORDS=* for testing purposes. |
173 |
- |
174 |
+ |
175 |
root is the directory where the packaged will be emerged. A non-root user |
176 |
can use this function, provided he has write access to that directory. |
177 |
- |
178 |
+ |
179 |
pkgdir is the directory where the binary package will be placed. The user |
180 |
has to be able to write in this directory. |
181 |
- |
182 |
+ |
183 |
The function has no return value and raises an exception in case of building |
184 |
or emerging failure. Note: dependencies will NOT be emerged! |
185 |
""" |
186 |
@@ -140,43 +140,44 @@ def installPackage(test, package=None, env=None, logfile=None): |
187 |
env = test['emergeenv'] |
188 |
if logfile is None: |
189 |
logfile = pjoin(test['logdir'], 'emerge.log') |
190 |
- |
191 |
+ |
192 |
envAdds = env.copy() |
193 |
envAdds['PKGDIR'] = test['pkgdir'] |
194 |
denv = _getEnv(test['root'], envAdds) |
195 |
del envAdds |
196 |
- |
197 |
+ |
198 |
# Retrieve package string |
199 |
pkg = normalize_cpv(package) |
200 |
- |
201 |
+ |
202 |
# Execute emerge command and log the results |
203 |
benchutils.mkdir(dirname(logfile)) |
204 |
fout = file(logfile, 'w') |
205 |
cmd = ['emerge', '--ignore-default-opts', '-OB', '=' + pkg] |
206 |
p = sp.Popen(cmd, env=denv, stdout=fout, stderr=sp.STDOUT) |
207 |
p.wait() |
208 |
- |
209 |
+ |
210 |
if p.returncode != 0: |
211 |
# In case of error, print the whole emerge command |
212 |
raise InstallException(p, ' '.join(cmd), logfile) |
213 |
- |
214 |
+ |
215 |
fout.write('\n\n' + 80*'#' + '\n\n') |
216 |
- |
217 |
+ |
218 |
# Unpack package onto root |
219 |
+ archive = pjoin(test['pkgdir'], pkg+'.tbz2') |
220 |
benchutils.mkdir(test['root']) |
221 |
- tarcmd = ['tar', 'xjvf', test['archive'], '-C', test['root']] |
222 |
+ tarcmd = ['tar', 'xjvf', archive, '-C', test['root']] |
223 |
fout.write(' '.join(tarcmd) + '\n' + 80*'-' + '\n') |
224 |
p = sp.Popen(tarcmd, stdout=fout, stderr=sp.STDOUT) |
225 |
p.wait() |
226 |
if p.returncode != 0: |
227 |
# In case of error, print the whole emerge command |
228 |
raise InstallException(pkg, ' '.join(tarcmd), logfile) |
229 |
- |
230 |
+ |
231 |
# Close, return |
232 |
fout.close() |
233 |
- |
234 |
+ |
235 |
if __name__ == '__main__': |
236 |
# Just a test |
237 |
from pprint import pprint |
238 |
- |
239 |
+ |
240 |
pprint(get_dependencies('sci-libs/blas-reference-3.3.1-r1')) |
241 |
|
242 |
diff --git a/numbench/benchconfig.py b/numbench/benchconfig.py |
243 |
index 7191892..f4bed38 100644 |
244 |
--- a/numbench/benchconfig.py |
245 |
+++ b/numbench/benchconfig.py |
246 |
@@ -18,20 +18,14 @@ |
247 |
import sys, os, time, subprocess as sp |
248 |
from os.path import join as pjoin |
249 |
|
250 |
-try: |
251 |
- needsinitialization = not initialized #@UndefinedVariable |
252 |
-except NameError: |
253 |
- needsinitialization = True |
254 |
- |
255 |
- |
256 |
-if needsinitialization: |
257 |
+if not locals().has_key('initialized'): |
258 |
initialized = True |
259 |
- |
260 |
+ |
261 |
isroot = os.getuid() == 0 |
262 |
- |
263 |
+ |
264 |
modulename = sys.argv[1] |
265 |
inputfile = os.path.realpath(sys.argv[2]) |
266 |
- |
267 |
+ |
268 |
# Script directories |
269 |
curdir = os.path.abspath('.') |
270 |
scriptdir = os.path.dirname(os.path.realpath(__file__)) |
271 |
@@ -39,7 +33,7 @@ if needsinitialization: |
272 |
btldir = os.environ['BTLDIR'] |
273 |
else: |
274 |
btldir = '/usr/include/btl' |
275 |
- |
276 |
+ |
277 |
# Library directory (lib vs. lib32 vs. lib64) |
278 |
libdir = sp.Popen \ |
279 |
('ABI=$(portageq envvar ABI); echo `portageq envvar LIBDIR_$ABI`', \ |
280 |
@@ -50,38 +44,30 @@ if needsinitialization: |
281 |
libdir = '/usr/' + libdir |
282 |
while libdir[0] == '/': |
283 |
libdir = libdir[1:] |
284 |
- |
285 |
+ |
286 |
+ # Parse arguments |
287 |
+ passargs = sys.argv[3:] |
288 |
+ for i,a in enumerate(passargs): |
289 |
+ if a in ('-d', '--directory'): |
290 |
+ basedir = passargs[i+1] |
291 |
+ passargs = passargs[:i] + passargs[i+2:] |
292 |
+ break |
293 |
+ |
294 |
# Storage directories |
295 |
- basedirb = pjoin(os.environ['HOME'], '.numbench') \ |
296 |
- + '/run_' + modulename + '_' + time.strftime('%Y-%m-%d') |
297 |
- if os.path.exists(basedirb): |
298 |
- n = 1 |
299 |
- while True: |
300 |
- basedir = basedirb + "_%i" % n |
301 |
- if not os.path.exists(basedir): |
302 |
- break |
303 |
- n += 1 |
304 |
- else: |
305 |
- basedir = basedirb |
306 |
- del basedirb |
307 |
- |
308 |
+ if not locals().has_key('basedir'): |
309 |
+ basedirb = pjoin(os.environ['HOME'], '.numbench') \ |
310 |
+ + '/run_' + modulename + '_' + time.strftime('%Y-%m-%d') |
311 |
+ if os.path.exists(basedirb): |
312 |
+ n = 1 |
313 |
+ while True: |
314 |
+ basedir = basedirb + "_%i" % n |
315 |
+ if not os.path.exists(basedir): |
316 |
+ break |
317 |
+ n += 1 |
318 |
+ else: |
319 |
+ basedir = basedirb |
320 |
+ del basedirb |
321 |
+ |
322 |
testsdir, rootsdir, pkgsdir, reportdir, logdir = tuple([pjoin(basedir, i) \ |
323 |
for i in ('tests', 'roots', 'packages', 'report', 'log')]) |
324 |
- |
325 |
- |
326 |
-#def makedirs(): |
327 |
-# bu.mkdir(rootsdir) |
328 |
-# bu.mkdir(testsdir) |
329 |
-# bu.mkdir(pkgsdir) |
330 |
-# bu.mkdir(reportdir) |
331 |
-# bu.mkdir(logdir) |
332 |
-# |
333 |
-#def purgedirs(): |
334 |
-# bu.rmdir(rootsdir) |
335 |
-# bu.rmdir(testsdir) |
336 |
-# bu.rmdir(pkgsdir) |
337 |
-# bu.rmdir(pjoin(reportdir, '..')) |
338 |
-# bu.rmdir(pjoin(logdir, '..')) |
339 |
- |
340 |
- |
341 |
- |
342 |
+ |
343 |
|
344 |
diff --git a/numbench/confinput/xmlinput.py b/numbench/confinput/xmlinput.py |
345 |
index 4d4516c..1d04580 100644 |
346 |
--- a/numbench/confinput/xmlinput.py |
347 |
+++ b/numbench/confinput/xmlinput.py |
348 |
@@ -90,18 +90,19 @@ def parseConf(fname): |
349 |
|
350 |
for t in testNodes: |
351 |
tid = t.getAttribute('id') |
352 |
- |
353 |
+ |
354 |
# Get description |
355 |
descr = None |
356 |
if len(t.getElementsByTagName('descr')) != 0: |
357 |
descr = t.getElementsByTagName('descr')[0].firstChild.data |
358 |
- |
359 |
+ |
360 |
# Get package |
361 |
pkg = portage.catpkgsplit( |
362 |
t.getElementsByTagName('pkg')[0].firstChild.data) |
363 |
normPkg = pu.normalize_cpv(pkg) |
364 |
|
365 |
# Skip implementations |
366 |
+ # TODO: add regexp |
367 |
skip = [i.firstChild.data for i in t.getElementsByTagName('skip')] |
368 |
|
369 |
# Requirements |
370 |
@@ -114,7 +115,7 @@ def parseConf(fname): |
371 |
emergeenv = getEnvFromNode(t, 'emergeenv') |
372 |
compileenv = getEnvFromNode(t, 'compileenv') |
373 |
runenv = getEnvFromNode(t, 'runenv') |
374 |
- |
375 |
+ |
376 |
# Adjust PATH |
377 |
if runenv.has_key('PATH'): |
378 |
runenv['PATH'] += ':' + os.environ['PATH'] |
379 |
@@ -128,12 +129,12 @@ def parseConf(fname): |
380 |
normalizedPackage = normPkg, |
381 |
skip = skip, |
382 |
requires = requires, |
383 |
- |
384 |
+ |
385 |
dependenv = dependenv, |
386 |
emergeenv = emergeenv, |
387 |
compileenv = compileenv, |
388 |
runenv = runenv, |
389 |
- |
390 |
+ |
391 |
pkgdir = pjoin(cfg.pkgsdir, tid), |
392 |
archive = pjoin(cfg.pkgsdir, tid, normPkg+'.tbz2'), |
393 |
root = pjoin(cfg.rootsdir, tid), |
394 |
|
395 |
diff --git a/numbench/main.py b/numbench/main.py |
396 |
index 466d6ec..9ba9ae7 100644 |
397 |
--- a/numbench/main.py |
398 |
+++ b/numbench/main.py |
399 |
@@ -67,7 +67,7 @@ def loadModule(modulename): |
400 |
# except ImportError as e: |
401 |
# sys.stderr.write('Module ' + modulename + ' not found') |
402 |
# exit(1) |
403 |
- |
404 |
+ |
405 |
return tmp |
406 |
|
407 |
|
408 |
@@ -120,37 +120,37 @@ Print("-------------------------------") |
409 |
Print() |
410 |
for tname, ttest in cfg.tests.items(): |
411 |
Print("Test: " + tname) |
412 |
- |
413 |
+ |
414 |
if ttest['descr'] is not None: |
415 |
Print(" - Description: " + ttest['descr']) |
416 |
- |
417 |
+ |
418 |
Print(" - Package: " + ttest['normalizedPackage']) |
419 |
- |
420 |
+ |
421 |
if len(ttest['dependenv']) != 0: |
422 |
Print(" - Dependencies emerge environment: " + \ |
423 |
' '.join([n+'="'+v+'"' for n,v in ttest['dependenv'].items()])) |
424 |
- |
425 |
+ |
426 |
if len(ttest['emergeenv']) != 0: |
427 |
Print(" - Emerge environment: " + \ |
428 |
' '.join([n+'="'+v+'"' for n,v in ttest['emergeenv'].items()])) |
429 |
- |
430 |
+ |
431 |
if len(ttest['compileenv']) != 0: |
432 |
Print(" - Suite compile-time environment: " + \ |
433 |
' '.join([n+'="'+v+'"' for n,v in ttest['compileenv'].items()])) |
434 |
- |
435 |
+ |
436 |
if len(ttest['runenv']) != 0: |
437 |
Print(" - Suite run-time environment: " + \ |
438 |
' '.join([n+'="'+v+'"' for n,v in ttest['runenv'].items()])) |
439 |
- |
440 |
+ |
441 |
if len(ttest['skip']) != 0: |
442 |
Print(" - Skip implementations: " + ' '.join(ttest['skip'])) |
443 |
- |
444 |
+ |
445 |
if len(ttest['requires']) != 0: |
446 |
Print(" - Pkg-config requirements substitutions:", '') |
447 |
for c_0, c_1 in ttest['requires'].items(): |
448 |
Print(c_0 + ':' + c_1, '') |
449 |
Print() |
450 |
- |
451 |
+ |
452 |
Print() |
453 |
Print(80*'=') |
454 |
Print() |
455 |
@@ -196,6 +196,7 @@ for tn,(name,test) in enumerate(cfg.tests.items(),1): |
456 |
Print("Package emerged") |
457 |
|
458 |
# Find implementations |
459 |
+ # TODO: check for regexps |
460 |
impls = [i for i in mod.getImplementations(test) if not i in test['skip']] |
461 |
test['implementations'] = impls |
462 |
|
463 |
@@ -210,7 +211,7 @@ for tn,(name,test) in enumerate(cfg.tests.items(),1): |
464 |
test['results'][impl] = mod.runTest(test, impl) |
465 |
Print.up() |
466 |
# All implementations tested |
467 |
- |
468 |
+ |
469 |
Print.up() |
470 |
print |
471 |
|
472 |
|
473 |
diff --git a/numbench/modules/internal/blasBase.py b/numbench/modules/internal/blasBase.py |
474 |
index 34f2912..5e691e3 100644 |
475 |
--- a/numbench/modules/internal/blasBase.py |
476 |
+++ b/numbench/modules/internal/blasBase.py |
477 |
@@ -31,11 +31,11 @@ defaultTests = ('axpy', 'matrix_vector', 'trisolve_vector', 'matrix_matrix') |
478 |
def init(self, args): |
479 |
passargs = [] |
480 |
tests = [] |
481 |
- |
482 |
+ |
483 |
if len(args) == 0: |
484 |
self.tests = defaultTests |
485 |
return |
486 |
- |
487 |
+ |
488 |
for i in args: |
489 |
if i == '1': |
490 |
tests += avail1 |
491 |
@@ -47,7 +47,7 @@ def init(self, args): |
492 |
tests += avail3 |
493 |
continue |
494 |
passargs.append(i) |
495 |
- |
496 |
+ |
497 |
self.tests = btl.selectTests(availableTests, passargs+tests) |
498 |
|
499 |
|
500 |
@@ -67,10 +67,10 @@ def runTest(self, test, implementation): |
501 |
flags = alt.getFlags(test, self.libname, implementation), |
502 |
tests = self.tests |
503 |
) |
504 |
- |
505 |
- return btlBase.runTest(test, btlconfig) |
506 |
- |
507 |
-getTests btlBase.getTests |
508 |
+ |
509 |
+ return btlBase.runTest(self, test, btlconfig) |
510 |
+ |
511 |
+getTests = btlBase.getTests |
512 |
reportConf = btlBase.reportConf |
513 |
- |
514 |
+ |
515 |
reportConf = btlBase.reportConf |
516 |
|
517 |
diff --git a/numbench/modules/internal/btlBase.py b/numbench/modules/internal/btlBase.py |
518 |
index 63106b7..3c33202 100644 |
519 |
--- a/numbench/modules/internal/btlBase.py |
520 |
+++ b/numbench/modules/internal/btlBase.py |
521 |
@@ -15,26 +15,44 @@ |
522 |
# along with this program; if not, write to the Free Software |
523 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
524 |
# |
525 |
+from os.path import join as pjoin, exists |
526 |
import numbench.utils.btl as btl |
527 |
+from numbench.benchprint import Print |
528 |
|
529 |
-def reportConf(): |
530 |
+def reportConf(*args): |
531 |
return {'type':'semilogx', 'xlabel':'size', 'ylabel':'MFlops'} |
532 |
|
533 |
-def runTest(test, btlconfig): |
534 |
- |
535 |
+ |
536 |
+def runTest(self, test, btlconfig): |
537 |
+ # Check if results already exist |
538 |
+ tmpres = dict( \ |
539 |
+ [(i, pjoin(btlconfig['testdir'], "bench_"+i+"_"+self.libname)) \ |
540 |
+ for i in btlconfig['tests']]) |
541 |
+ |
542 |
+ if all([exists(i) for i in tmpres.values()]): |
543 |
+ Print("Results exist - skipping run") |
544 |
+ return tmpres |
545 |
+ |
546 |
+ # Compile test suite |
547 |
ret = btl.compileTest(test, btlconfig) |
548 |
if ret != 0: |
549 |
- print "Compilation failed with code:", ret |
550 |
+ Print("Compilation failed with code: %i" % ret) |
551 |
+ return None |
552 |
else: |
553 |
- print "Compilation successful" |
554 |
- |
555 |
+ Print("Compilation successful") |
556 |
+ |
557 |
+ # Run test suite |
558 |
ret, result = btl.runTest(test, btlconfig) |
559 |
if ret != 0: |
560 |
- print "Execution failed with code:", ret |
561 |
+ Print("Execution failed with code: %i" % ret) |
562 |
+ Print("The results will be incomplete") |
563 |
+ # TODO: remove this if possible (return incomplete results) |
564 |
+ return None |
565 |
else: |
566 |
- print "Execution successful" |
567 |
- |
568 |
+ Print("Execution successful") |
569 |
+ |
570 |
return result |
571 |
|
572 |
+ |
573 |
def getTests(self): |
574 |
- return self.tests |
575 |
\ No newline at end of file |
576 |
+ return self.tests |
577 |
|
578 |
diff --git a/numbench/modules/internal/lapackBase.py b/numbench/modules/internal/lapackBase.py |
579 |
index c8098fc..e45951d 100644 |
580 |
--- a/numbench/modules/internal/lapackBase.py |
581 |
+++ b/numbench/modules/internal/lapackBase.py |
582 |
@@ -49,8 +49,8 @@ def runTest(self, test, implementation): |
583 |
flags = alt.getFlags(test, self.libname, implementation), |
584 |
tests = self.tests |
585 |
) |
586 |
- |
587 |
- return btlBase.runTest(test, btlconfig) |
588 |
- |
589 |
+ |
590 |
+ return btlBase.runTest(self, test, btlconfig) |
591 |
+ |
592 |
getTests btlBase.getTests |
593 |
reportConf = btlBase.reportConf |
594 |
\ No newline at end of file |
595 |
|
596 |
diff --git a/numbench/report.py b/numbench/report.py |
597 |
index da1b5de..f51905a 100644 |
598 |
--- a/numbench/report.py |
599 |
+++ b/numbench/report.py |
600 |
@@ -1,13 +1,14 @@ |
601 |
-import cfg |
602 |
from os.path import join as pjoin, basename |
603 |
import numpy as np |
604 |
|
605 |
+import benchconfig as cfg |
606 |
+import benchutils as bu |
607 |
from htmlreport import HTMLreport |
608 |
from testdescr import testdescr |
609 |
from benchprint import Print |
610 |
|
611 |
def saveReport(): |
612 |
- |
613 |
+ |
614 |
# Check whether pyplot is working |
615 |
try: |
616 |
plt.figure() |
617 |
@@ -15,10 +16,10 @@ def saveReport(): |
618 |
Print("Unable to generate plots") |
619 |
Print("Please make sure that X is running and $DISPLAY is set") |
620 |
return |
621 |
- |
622 |
+ |
623 |
# Read configuration |
624 |
- conf = mod.reportConf() |
625 |
- |
626 |
+ conf = cfg.mod.reportConf() |
627 |
+ |
628 |
if conf['type'] == 'plot': |
629 |
plotf = plt.plot |
630 |
elif conf['type'] == 'semilogx': |
631 |
@@ -27,44 +28,48 @@ def saveReport(): |
632 |
plotf = plt.semilogy |
633 |
elif conf['type'] == 'loglog': |
634 |
plotf = plt.loglog |
635 |
- |
636 |
+ |
637 |
if conf.has_key('xlabel'): |
638 |
xlabel = conf['xlabel'] |
639 |
else: |
640 |
xlabel = '' |
641 |
- |
642 |
+ |
643 |
if conf.has_key('ylabel'): |
644 |
ylabel = conf['ylabel'] |
645 |
else: |
646 |
ylabel = '' |
647 |
- |
648 |
- |
649 |
+ |
650 |
+ |
651 |
# Open HTML file |
652 |
+ bu.mkdir(cfg.reportdir) |
653 |
htmlfname = pjoin(cfg.reportdir, 'index.html') |
654 |
html = HTMLreport(htmlfname) |
655 |
- |
656 |
+ |
657 |
for operation in cfg.mod.getTests(): |
658 |
plt.figure(figsize=(12,9), dpi=300) |
659 |
- |
660 |
+ |
661 |
for tid,test in cfg.tests.items(): |
662 |
- for impl in test['implementations']: |
663 |
- x,y = np.loadtxt(test['results'][impl][operation], unpack=True) |
664 |
- plotf(x, y, label=tid+'/'+impl, hold=True) |
665 |
- |
666 |
+ if test.has_key('implementations'): |
667 |
+ for impl in test['implementations']: |
668 |
+ if test['results'][impl].has_key(operation): |
669 |
+ resultsFile = test['results'][impl][operation] |
670 |
+ x,y = np.loadtxt(resultsFile, unpack=True) |
671 |
+ plotf(x, y, label=tid+'/'+impl, hold=True) |
672 |
+ |
673 |
plt.legend(loc='best') |
674 |
plt.xlabel(xlabel) |
675 |
plt.ylabel(ylabel) |
676 |
plt.grid(True) |
677 |
- |
678 |
+ |
679 |
fname = pjoin(cfg.reportdir, operation+'.png') |
680 |
plt.savefig(fname, format='png', bbox_inches='tight', transparent=True) |
681 |
html.addFig(testdescr[operation], image=basename(fname)) |
682 |
- |
683 |
+ |
684 |
# Close HTML file |
685 |
html.close() |
686 |
Print('HTML report generated: ' + htmlfname) |
687 |
- |
688 |
- |
689 |
+ |
690 |
+ |
691 |
# Initialize module |
692 |
try: |
693 |
if not locals().has_key('initialized'): |
694 |
@@ -77,5 +82,5 @@ try: |
695 |
except ImportError: |
696 |
sys.stderr.write('Error: matplotlib and numpy are needed' + \ |
697 |
'in order to generate the reports!\n') |
698 |
- sys.stderr.write('Continue anyway.\n\n') |
699 |
- with_images = False |
700 |
\ No newline at end of file |
701 |
+ sys.stderr.write('Continue anyway.\n\n') |
702 |
+ with_images = False |
703 |
|
704 |
diff --git a/numbench/utils/btl.py b/numbench/utils/btl.py |
705 |
index edb3a18..9865ad5 100644 |
706 |
--- a/numbench/utils/btl.py |
707 |
+++ b/numbench/utils/btl.py |
708 |
@@ -201,7 +201,7 @@ def runTest(test, btlconfig): |
709 |
|
710 |
resfile = errline.split()[-1] |
711 |
operation = resfile.split('_', 1)[-1].rsplit('_', 1)[0] |
712 |
- result[operation] = resfile |
713 |
+ result[operation] = pjoin(btlconfig['testdir'], resfile) |
714 |
Print(operation + " -> " + resfile) |